【问题标题】:AsyncHttpClient - Strange response, like incorrect charsetAsyncHttpClient - 奇怪的响应,例如不正确的字符集
【发布时间】:2015-08-24 05:41:47
【问题描述】:

图书馆对我来说非常完美,直到我昨天遇到这个问题。我尝试了 1.4.5 和 1.4.8 版本。我在真机模拟器上进行了测试。我还创建了一个新项目,只连接到 Google:

AsyncHttpClient client = new AsyncHttpClient();
client.get("https://www.google.com", new AsyncHttpResponseHandler() {

    @Override
    public void onSuccess(int statusCode, Header[] headers, byte[] response) {
        // called when response HTTP status is "200 OK"
        Log.e("TEST", new String(response));
    }

    @Override
    public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
        // called when response HTTP status is "4XX" (eg. 401, 403, 404)
    }
});

然后响应:����������������}iw۶���� ������H-�%��q�7q����������bL�4IyS������$A����

【问题讨论】:

标签: asynchttpclient


【解决方案1】:

这是 AsyncHttpClient 中的已知问题(请参阅 https://github.com/loopj/android-async-http/issues/932)。您可以禁用 gzip 作为临时解决方法:

AsyncHttpClient client = new AsyncHttpClient();
client.addHeader("Accept-Encoding", "identity"); // disable gzip
client.get(...)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 2013-01-25
    相关资源
    最近更新 更多