Process all method like POST (with body).#165
Process all method like POST (with body).#165IgorGalarraga wants to merge 1 commit intoetr:masterfrom
Conversation
Originally this example: curl -v -XGET --data 'test' 'http://localhost:8080/service' does not finalize connection with client. With this change, connection closes and responds correctly.
Codecov Report
@@ Coverage Diff @@
## master #165 +/- ##
=========================================
- Coverage 95.31% 95.3% -0.02%
=========================================
Files 35 35
Lines 3225 3196 -29
=========================================
- Hits 3074 3046 -28
+ Misses 151 150 -1
Continue to review full report at Codecov.
|
|
Thanks for notifying about this bug. I still feel that GET (and GET-like) methods shouldn't support body provided in input. See: https://tools.ietf.org/html/rfc7231#section-4.3.1 "A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request." This commit ( b8f6578 ) going through travis right now should fix the bug you report but enforces the correct semantic of GET. It should be on head soon. Thanks again! |
I agree with reject as malformed method..., but, this is the answer of a stardards committe (I will omit which one) about their recommendation to 'post' body content using GET method:
So, I think the best solution is to support GETs with body AND have the functions to retrieve received data like in POST method: If I use POST I can request 'body' but I can't retreive that info if a GET is received. What do you think? Is there another function to retrieve body content when a GET is received? Best regards, |
|
I have to say that I disagree. Mostly on two points:
Even in this I understand how others have taken different approaches and consider my view - e.g. Elasticsearch allowing for body in GET because they felt that using POST might be inappropriate instead (mostly based on naming of the method).
For the above, I believe that syntactically the webserver should be immune from erroring when receiving a body (unless specified by the business logic above) but shouldn't support this use-case. As a general case though, I am quite fond to allow for ideas in disagreement with my recommended view of the world and of how this API should behave. In general, I like to segregate these behaviors using preprocessor directives so that "non-standard" behaviors can be supported to allow for specific needs. I am going to push the current change I have on the separate branch I linked (see: #166). I will be happy to receive a follow-up change from you to support the body-processing use-case if that is kept isolated within preprocessor option. Would that work? |
|
Thank you for your full explanation, I totally agree. I didn't realize that processing the body has an extra cost, I thought you could look early if the body has any size or not to evaluate processing or not the body, dinamically but without extra complexity. But after your explanation, I wouldn't make the decision to worsen all requests to support a few exceptions using not recommended semantics. I think, the preprocessor option (adding a new parameter into 'configure') would be a sufficient and adequate solution. It should also be documented for its easy identification, when the special need arises. |
Description of the Change
Originally this example:
curl -v -XGET --data 'test' 'http://localhost:8080/service'
(GET metoth + data on body of request)
does not finalize connection with client.
Quantitative Performance Benefits
With this change, connection closes and responds correctly.
I am not completely sure that it is the best solution.
Verification Process
Using examples/service:
curl -v -XGET --data 'test' 'http://localhost:8080/service'
Applicable Issues
Release Notes