HttpClient POST 获取 html 页面的速度比浏览器慢约 2.5 倍

发布于 2024-09-25 13:42:00 字数 358 浏览 5 评论 0原文

当我在伦敦旅程规划器上点击搜索时(例如从霍尔本到萨沃伊码头) ),我在大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静若繁花 2024-10-02 13:42:00

如果没有看到执行测试和测量的代码,很难说你的问题是什么。

对于使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文