HttpClient POST 获取 html 页面的速度比浏览器慢约 2.5 倍
当我在伦敦旅程规划器上点击搜索时(例如从霍尔本到萨沃伊码头) ),我在大约 4 秒内得到结果。当我使用 POST 方法使用 HttpClient 执行此操作时,此行大约需要 10 秒:
InputStream is = httpClient.execute(httpPost).getEntity().getContent();
有什么想法可能是什么问题吗?我发送与浏览器相同的参数,并且还将 User-Agent 设置为 Chrome。
When I hit Search on London journey planner (e.g from Holborn to Savoy Pier), I get result in about 4 secs. When I do that with HttpClient using POST method, this line takes about 10 secs:
InputStream is = httpClient.execute(httpPost).getEntity().getContent();
Any ideas what can be the problem? I'm sending the same parameters as browser and I have also set User-Agent to Chrome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到执行测试和测量的代码,很难说你的问题是什么。
对于使用 HttpClient 进行故障排除的一个建议:使用日志记录。
并且,为了消除此比较中的人为错误,建议使用某些命令行工具(例如 wget)而不是浏览器来执行比较 POST。
Difficult to say, what is your problem, without seeing the code that performs the test and the measurement.
One suggestion, for troubleshooting with HttpClient: use logging.
And, to remove human errors from this comparison, it would be advisable to use some command-line tool (e.g. wget) instead of the browser to perform the comparative POST.