开发者

URL parameters and post body in the same Apache httpclient request?

开发者 https://www.devze.com 2023-04-12 09:53 出处:网络
I usually use this: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(postURL);

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 lon开发者_JS百科g... and I dont want to use GET, I want POST, but to some I do want the GET.

So?


GET and POST are mutually exclusive, you do one or the other (or HEAD, PUT etc). A request cannot be both.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号