无法从Android中的httpResponse检索所有数据

时间:2012-03-15 07:15:16

标签: java android apache http response

    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 response.i从服务器获取所有数据。只获得最小数据大小..

1 个答案:

答案 0 :(得分:1)

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