URL 参数和 post body 在同一个 Apache httpclient 请求中?
我通常使用这个:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(postURL);
...
HttpResponse responsePOST = client.execute(post);
是否可以在同一请求中以 GET 和 POST 组合的方式传递参数? 我的意思是有些参数可能很长......我不想使用 GET,我想要 POST,但对某些参数我确实想要 GET。
所以?
I usually use this:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(postURL);
...
HttpResponse responsePOST = client.execute(post);
Is it possible to pass parameters in a combination of GET and POST in the same request?
I mean some parameters might be pretty long... and I dont want to use GET, I want POST, but to some I do want the GET.
So?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GET 和 POST 是互斥的,您可以选择其中之一(或 HEAD、PUT 等)。一个请求不能两者兼而有之。
GET and POST are mutually exclusive, you do one or the other (or HEAD, PUT etc). A request cannot be both.
根据协议,单个 HTTP 请求可以是 GET 或 POST。无法同时为两者构建 HTTP 标头。
但是
将 POST 请求定向到带有查询参数(?后面的内容)的 URL,并且服务器可以读取它们。
GET 请求可以包含内容,服务器可以读取它。
A single HTTP request, according to the protocol, is either GET or POST. There is no way to construct an HTTP header for both at the same time.
However
A POST request be directed to a URL with query parameters (the stuff after the ?) and the server can read them.
a GET request can have content, and the server can read it.