![]() ![]() It's important to understand that the HTTP methods operate in the domain of "transferring documents across a network", and not in your own custom domain. Since the alternative workaround with DELETE and a body payload is let viable by the HTTP specification and is supported by all modern browsers with fetch and since IE10 with the polyfill, I recommend this way to do batch deletes in a valid and full working way. If either body exists and is non-null or inputBody is non-null, and request’s method is GET or HEAD, then throw a TypeError.Īnd we can confirm it's implemented in the same way for the fetch pollyfill at line 342. It's what the Fetch Standard states at Section 5.3 on Item 34: It's hard to be 100% sure, but a modern request made with fetch just doesn't allow body for GET and HEAD. Unfortunately some existing implementations could reject the request. So, we can conclude that the specification doesn't prevent DELETE from having a body payload. There are many people out there stating that it isn't valid, but let's stick with the Section 4.3.5 of the specification:Ī payload within a DELETE request message has no defined semantics sending a payload body on a DELETE request might cause some existing implementations to reject the request. Here, we arrive to the confusion about using an entity body in a DELETE request. It's almost the same as proposed in the workaround two but instead using the correct HTTP method for deletion. The second proposed workaround:Ībout your second proposed workaround ( POST '/path/abc' with body: I personally believe it's a matter of interpretation here.Ībout your first proposed workaround ( DELETE '/path/abc?itemId=1&itemId=2&itemId=3') we can conclude that it's something discouraged if you think about a resource as a single document in your entity collection while being good to go if you think about a resource as the entity collection itself. Each resource is identified by a Uniform Resource Identifier (URI).īased on it, some may argue that since HTTP does not limite the nature of a resource, a URI containing more than one id would be possible. HTTP does not limit the nature of a resource it merely defines an interface that might be used to interact with resources. The target of an HTTP request is called a "resource". The first proposed workaround:įirst, about resources and the URI itself on Section 2: Since many questions was sent years ago, let's dig into the HTTP 1.1 specification from June 2014 ( RFC 7231), for better understanding of what's clearly discouraged or not. It seems that the accepted answers ranges from " for sure do it" to " its clearly mistreating the protocol". Along the years, many people fell in doubt about it, as we can see in the related questions here aside. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |