AsyncHttpClient - 奇怪的响应,就像错误的字符集

时间:2015-08-24 05:41:47

标签: asynchttpclient

图书馆对我来说非常合适,直到我昨天遇到这个问题。我试过版本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)
    }
});

并回复: }iw6 H-%q7qbL4IyS $ A< 9S7" V 6xfVz9I {NXA< P&安培;我 Ě8mo( N] CQ P {Qऴaԙrؚ4҉Ӹ cHtMpJc3 +njl'Ltj70vZa/ M4 ȱ<7Mg4Ұ1qqc9JՄ; ?ρB 4 4 Nb ^ 0) &L Ў qh i an ³1 L 춢Q ad(,! Owx1b9M-ίUl`Ϣ{ Ӄ 帮助我,谢谢

1 个答案:

答案 0 :(得分: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(...)