【发布时间】: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