[
https://issues.apache.org/jira/browse/HTTPCLIENT-1703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15055131#comment-15055131
]
Konstantin Ignatyev commented on HTTPCLIENT-1703:
-------------------------------------------------
That is the danger of ambiguous language, everyone sees what they want.
I think that better interpretation is that GET request is not prohibited from
having a body, it is just semantics is not defined by the spec.
>From semantics perspective:
- is there any other semantically suitable way to send structured query? POST,
PUT?
- ability to send properly structured data in the body is a very valuable
ability for READ ONLY requests like search when they have quite complex
criteria. Without that ability we are running into a need to create
fratten/unflatten code and run into length limitations of URL and need to write
potentially buggy code;
blindly sticking to 2616 does not seem to make much sense IMO especially
because 5.0 is not released.
Workaround is simple but less than elegant because it requires override to be
in the org.apache.http.client.fluent package
package org.apache.http.client.fluent
import java.net.URI
import org.apache.http.client.methods.HttpGet
/**
* Patch for fluent http client to allow get body
* should be removed when http client will fix
https://issues.apache.org/jira/browse/HTTPCLIENT-1703 or 5.0 version released
*
* Created by kgignatyev on 12/13/15.
*/
object EnclosingGet {
def apply(uri:String):Request = {
new Request(new InternalEntityEnclosingHttpRequest(HttpGet.METHOD_NAME,
URI.create(uri)))
}
}
> GET request should support body
> -------------------------------
>
> Key: HTTPCLIENT-1703
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1703
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Fluent HC
> Affects Versions: 4.5.1
> Reporter: Konstantin Ignatyev
>
> I have discovered that fluent client does not allow BODY for a get request
> java.lang.IllegalStateException: GET request cannot enclose an entity
> at org.apache.http.client.fluent.Request.body(Request.java:348)
> at org.apache.http.client.fluent.Request.bodyString(Request.java:375)
> at
> kgi.mcytravel.wsite.services.FullTextSearchService.fullTextSearch(FullTextSearchService.scala:72)
> Which is not correct, spec does not prohibit GET request from having a body.
> It seems a bit unconventional but makes perfect sense considering complex
> search requests use case. And it is utilized by ElasticSearch for example
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html
> curl -XGET 'http://localhost:9200/twitter/tweet/_search?routing=kimchy' -d '{
> "query": {
> "bool" : {
> "must" : {
> "query_string" : {
> "query" : "some query string here"
> }
> },
> "filter" : {
> "term" : { "user" : "kimchy" }
> }
> }
> }
> }
> '
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]