【发布时间】:2014-02-19 13:08:17
【问题描述】:
我正在尝试从我的办公室服务器获得响应。响应至少有 50,000 行。但我没有得到完整的回应。我不知道哪里出错了。是否完整的数据没有下载或我的 InputStream 有任何其他问题?
HttpClient httpClient = new DefaultHttpClient();
HttpContext httpcontext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(mUrl);
HttpResponse mResponse = httpClient.execute(httpPost, httpcontext);
InputStream mResponseStream = mResponse.getEntity().getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(mResponseStream));
String line = "";
while ((line = br.readLine()) != null) {
line = line.replaceAll("[\r\n]", "");
Log.v("Response", line);
}
必填回复:
02-17 18:32:14.000: D/Lib(4121): Starts
02-17 18:32:14.010: D/Lib(4121): 12080964|~|1370.00
02-17 18:32:14.010: D/Lib(4121): 12083142|~|500.00
02-17 18:32:14.020: D/Lib(4121): 13051372|~|100.00
02-17 18:32:14.020: D/Lib(4121): 13040457|~|12.00
02-17 18:32:14.060: D/Lib(4121): 12010037|~|170.00
02-17 18:32:14.060: D/Lib(4121): .........
02-17 18:32:14.060: D/Lib(4121): Ends
得到响应:
02-17 18:32:14.000: D/Lib(4121): Starts
02-17 18:32:14.010: D/Lib(4121): 12080964|~|1370.00
02-17 18:32:14.010: D/Lib(4121): 12083142|~|500.00
02-17 18:32:14.020: D/Lib(4121): 13051372|~|100.00
02-17 18:32:14.020: D/Lib(4121): 13040457|~|12.00
02-17 18:32:14.060: D/Lib(4121): 12010037|~|170.00
02-17 18:32:14.060: D/Lib(4121): .........
我的回复总是以Starts 关键字开头,以Ends 关键字结尾。总是我没有得到Ends 关键字。响应在第 25,000 到 33,000 行停止。谢谢。
【问题讨论】:
-
当您手动请求或通过 curl 等其他工具请求时会得到什么? (顺便说一句:你应该做 GET 请求,而不是 POST - 你发送任何需要 POST 的东西)
-
尝试为 BufferedReader 分配大小
-
@MarcinOrlowski 我正在发送数据进行身份验证,但我没有使用 curl。
-
@SathishKumar 使用 curl 看看那里的输出是什么
-
@MarcinOrlowski 抱歉,我不知道 curl,
标签: android