【问题标题】:unable to retrieve all data from httpResponse in Android无法从 Android 中的 httpResponse 检索所有数据
【发布时间】:2012-03-15 07:15:15
【问题描述】:
    HttpParams params = new BasicHttpParams();

                    // Set the timeout in milliseconds until a connection is established.
                    // The default value is zero, that means the timeout is not used. 
                    int timeoutConnection = 60000;
                    HttpConnectionParams.setConnectionTimeout(params, timeoutConnection);

                    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
                            HttpVersion.HTTP_1_1);

                    // Set the default socket timeout (SO_TIMEOUT) 
                    // in milliseconds which is the timeout for waiting for data.
                    int timeoutSocket = 60000;
                    HttpConnectionParams.setSoTimeout(params, timeoutSocket);

                    httpclient = new DefaultHttpClient(params);
response = httpclient.execute(httppost);
                byte[] buffer = new byte[1024];
                int bufferLength = 0; 
                InputStream inputStream = response.getEntity().getContent();
                totalSize = 0;
                while ((bufferLength = inputStream.read(buffer)) > 0) {
                    totalSize += bufferLength;
//                  onProgressTitleUpdate("Calculating size...");
                }

在这里我无法使用 http 响应从服务器获取所有数据。我只得到了最小大小的数据..

【问题讨论】:

    标签: java android apache http response


    【解决方案1】:

    检查 BasicHttpParams 是否设置了 gzip 接受编码。如果是这样,您的回复可能会被压缩。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      相关资源
      最近更新 更多