Does okhttp support "get" methods with "body"?
No. The spec forbids this.
Is it the Http protocol spec
Yes. What's your use case?
SpringCloud feignclient USES the @getmapping + @requestbody annotation with the exception "method GET must not have a request body"
https://www.elastic.co/guide/en/elasticsearch/guide/current/_empty_search.html#get_vs_post
The truth is that RFC 7231—the RFC that deals with HTTP semantics and content—does not define what should happen to a GET request with a body
GET+body is a bad practice for sure, but it's not forbidden by specs. And while I don't like it but it is used by some APIs in the wild.
Thanks for your answer. I changed the get request to a post request.
------------------ 原始邮件 ------------------
发件人: "Andrej Urvantsev"<[email protected]>;
发送时间: 2020年3月6日(星期五) 下午5:57
收件人: "square/okhttp"<[email protected]>;
抄送: "渟畱是莪仅剩の骄傲"<[email protected]>;"Author"<[email protected]>;
主题: Re: [square/okhttp] Does okhttp support "get" methods with "body"? (#5803)
https://www.elastic.co/guide/en/elasticsearch/guide/current/_empty_search.html#get_vs_post
The truth is that RFC 7231—the RFC that deals with HTTP semantics and content—does not define what should happen to a GET request with a body
GET+body is a bad practice for sure, but it's not forbidden by specs. And while I don't like it but it is used by some APIs in the wild.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Good for you - I'm stuck with 3rd-party APIs where I don't have any power :(
@lazystone I have a pull request on this but I'm not sure that they would accept it as there is a controversy about that feature cf https://stackoverflow.com/questions/978061/http-get-with-request-body
But with elasticsearch there is a workaround that is using source/source_content_type with urlencoding the ES query like :
curl 'http://elasticsearch:9200/_search?source=%7B%22query%22%3A%7B%22match_all%22%3A%7B%7D%7D%7D&source_content_type=application/json'
Could that help ?
@bamthomas Thanks but I ditched okhttp/mockwebserver in favor of https://www.mock-server.com/
If one library does not support real-life cases, then there is a better library to use.
Most helpful comment
@bamthomas Thanks but I ditched okhttp/mockwebserver in favor of https://www.mock-server.com/
If one library does not support real-life cases, then there is a better library to use.