5 ms·
POST represents a non-idempotent operation. The other HTTP verbs (GET, PUT, PATCH etc) are idempotent. The awkwardness surrounding PUT/PATCH stems from the need
by uiri 9y ago
POST represents a non-idempotent operation. The other HTTP verbs (GET, PUT, PATCH etc) are idempotent. The awkwardness surrounding PUT/PATCH stems from the need to ensure that those requests remain idempotent.
Nothing bothers me more than an idempotent request (e.g. a search query) using POST. If you design your API starting with "what should happen if the client makes this request multiple times?", then it becomes much easier to model with HTTP.
HTTP 401 Unauthorized actually means Unauthenticated. 403 Forbidden actually means Unauthorized. Yeah, it is a bit of a mess but the referer header is misspelt so what can you do.
- IanCal 9y agoCan I send a large request body with a GET? That's usually the reason I end up with POSTs.
- jwilk 9y ago> Can I send a large request body with a GET? Why not?
- deniska 9y agoHTTP server following the spec can omit the body from a GET request.
- hamilyon2 9y agoI'd love to see a document defining this. I could not find such to the date.
- IanCal 9y agoI'm not too up on which documents here are current but at least: > 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. https://tools.ietf.org/html/rfc7231#section-4.3.1 https://tools.ietf.org/html/rfc7231#section-4.3.1
- jwilk 9y agoRFC 2616 §4.3 (https://tools.ietf.org/html/rfc2616#section-4.3 https://tools.ietf.org/html/rfc2616#section-4.3): if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request. Now, RFC 2616 is obsolete, and I couldn't find such explicit wording in the superseding RFC 7231. But §4.3.1 (https://tools.ietf.org/html/rfc7231#section-4.3.1 https://tools.ietf.org/html/rfc7231#section-4.3.1) says: 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.
- niftich 9y agoA GET request's body has no defined semantics, so your server is firmly in the realm of "nonstandard implementation detail" if you choose to take into account the body in your decision-making.
- rahoulb 9y agoSlight aside but I tend to use POST to create a new "search results document" and the GET that document to see the actual results.
- jwilk 9y agoPATCH is not idempotent. Source: https://tools.ietf.org/html/rfc5789#section-2 https://tools.ietf.org/html/rfc5789#section-2