java - GET HTTP request payload -
i designing api , wonder if fine send json payload on request?
in other question payloads of http request methods, can find according this link:
- head - no defined body semantics.
- get - no defined body semantics.
- put - body supported.
- post - body supported.
- delete - no defined body semantics.
- trace - body not supported.
- options - body supported no semantics (maybe in future).
does mean should not send request payload? there risks so?
- like having http client libraries incapable of sending such payload?
- or java api code not being portable on application servers?
- anything else?
i found out elasticsearch using such payload on request:
$ curl -xget 'http://localhost:9200/twitter/tweet/_search?routing=kimchy' -d '{ "query": { "filtered" : { "query" : { "query_string" : { "query" : "some query string here" } }, "filter" : { "term" : { "user" : "kimchy" } } } } } ' so if popular libary , nobody complains, perhaps can same?
by way, i know if ok mix querystring parameters , json payload? elasticsearch query does. if so, there rules know arguments should querystring parameters, or payload parameters?
here can read: http request body
roy fielding's comment including body request.
yes. in other words, http request message allowed contain message body, , must parse messages in mind. server semantics get, however, restricted such body, if any, has no semantic meaning request. requirements on parsing separate requirements on method semantics.
so, yes, can send body get, , no, never useful so.
this part of layered design of http/1.1 become clear again once spec partitioned (work in progress).
....roy
then don't understand why never useful, because makes sense in opinion send complex queries server wouldn't fit on queryparam or matrixparam. think elasticsearch api designers think same...
i planning design api can called that:
curl -xget 'http://localhost:9000/documents/inbox?pageindex=0&pagesize=10&sort=title' curl -xget 'http://localhost:9000/documents/trash?pageindex=0&pagesize=10&sort=title' curl -xget 'http://localhost:9000/documents/search?pageindex=0&pagesize=10&sort=title' -d '{ "somesearchfilter1":"filtervalue1", "somesearchfilter2":"filtervalue2", "somesearchfilterlist": ["filtervalue3","xxx"] ... lot more ... } ' does seem fine you? based on above considerations.
having response vary based on request body break caching. don't go there.
Comments
Post a Comment