是否有任何工具来模拟java中的http请求 [英] is there any tool to simulate http requests in java

查看:116
本文介绍了是否有任何工具来模拟java中的http请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用URL类和HttpURLConnection类模拟Java中的HTTP请求,GET请求很容易模拟,而一些POST请求看起来更难,因为大多数POST请求需要请求头中的Cookie。一些cookie是由Set-Cookie字段中的HTTP响应设置的,我可以通过HttpURLConnection提供的功能获取它们,但我发现其他cookie可能是由JavaScript设置的,我无法处理它们,所以我想知道是有没有用Java模拟HTTP请求的打包工具?

I am trying to simulate HTTP requests in Java with the URL class and the HttpURLConnection class, the GET requests are easy to simulate while some POST requests seem harder because most POST request need Cookie in the request header. Some cookies were set by the HTTP response in the Set-Cookie field and I can get them by the function provided by HttpURLConnection, but I found that other cookies may be set by JavaScript and I have no way to handle them, so I wonder is there any packaged tool to simulate HTTP requests in Java?

推荐答案

尝试Apache commons Httpclient:
http://hc.apache.org/httpclient-3.x/

try Apache commons Httpclient: http://hc.apache.org/httpclient-3.x/

这篇关于是否有任何工具来模拟java中的http请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆