【问题标题】:Https get call results in 400 Bad Request in androidHttps在android中获取400 Bad Request中的调用结果
【发布时间】:2014-09-30 10:50:27
【问题描述】:

所以我有一个网页,我试图通过 HttpsURLConnection 访问它。颁发的证书是由 Digicert CA-3 颁发的。但是我总是得到 400 的响应。android 开发者网站 wikipedia example 工作正常。这个网站也可以在设备上的 chrome 上打开。我想知道这是否可能是一个我如何调用呼叫的问题。或者可能是什么问题

    URL url = new URL(strUrl);
    HttpsURLConnection urlConnection = (HttpsURLConnection) url
            .openConnection();
    SSLContext sslcontext = SSLContext.getDefault();
    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    urlConnection.setDoOutput(false);
    urlConnection.setDoInput(true);
    urlConnection.setSSLSocketFactory(sslcontext.getSocketFactory());
    int code = urlConnection.getResponseCode(); //always 400 :(

【问题讨论】:

    标签: android ssl httpsurlconnection


    【解决方案1】:

    可能你应该仔细检查你正在使用的 URL.. 这主要是因为客户端的错误请求..

    【讨论】:

    • 在设备上使用了来自 chrome 的相同 url。这很有效。它甚至可以在 web 视图中使用
    • 尝试从您的设备中的APP调试您的URL
    • @Femil..如果它可以通过 webview 工作。为什么不能通过休息客户端工作?
    猜你喜欢
    • 2021-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 2019-08-01
    相关资源
    最近更新 更多