gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:12:42 27 4
gpt4 key购买 nike

    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 响应从服务器获取所有数据。我只得到了最小大小的数据..

最佳答案

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

关于java - 无法从 Android 中的 httpResponse 检索所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9715364/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com