Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Move delete to be method with body. #8567

Closed
phillip-haydon opened this issue Aug 11, 2014 · 11 comments
Closed

Move delete to be method with body. #8567

phillip-haydon opened this issue Aug 11, 2014 · 11 comments

Comments

@phillip-haydon
Copy link

http://tools.ietf.org/html/rfc7231

This states:

A 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.

So shouldn't delete be removed from:

createShortMethods('get', 'delete', 'head', 'jsonp');

And added to:

createShortMethodsWithData('post', 'put', 'patch');

(discussion doesn't include how a server may or may not handle this type of request)

This is in regards to:

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

In June 2014, the WG released an updated six-part specification obsoleting RFC 2616

@pkozlowski-opensource
Copy link
Member

Well, if specs don't define precisely semantics here I guess we shouldn't be preventing people from sending DELETE requests with body. I recall several other issues being opened for this.

@awerlang
Copy link

Actually the same is stated about GET.

http://tools.ietf.org/html/rfc7231#section-4.3.1

Sometimes, when I want to perform a query and need to send a bunch of data, I end up writing a POST method for the ability to send a payload.

@rcollette
Copy link

While future behavior is being discussed, at least the documentation should reflect the current behavior. I lost a bunch of time and eventually had to debug into angular code to figure out what was going on. Not a straight forward task with digest/callbacks.

@pkozlowski-opensource
Copy link
Member

@rcollette The delete method is currently documented as delete(url, [config]); - that is - as one without any data argument. But if you thin that more explicit mention is needed, we would love to see a PR!

@caitp
Copy link
Contributor

caitp commented Jun 17, 2015

I don't see anything in fetch or xhr that would forbid or ignore the request body for delete --- I think this was more about best practices and maybe browser compat. If it works correctly on all supported browsers, then we can talk about whether it makes sense as a best practice

@pkozlowski-opensource
Copy link
Member

@caitp last time I looked at various specs (mostly HTTP) it wasn't clear if it is at allowed on HTTP level to have DELETE with body. It seems like some servers ignore body even if sent, some other process it.

But I agree that we should try to see if things are not exploding on XHR-level in all browsers and if not, we could move this method to the set of ones with allowed body. Unless someone finds a spec that forbids this.

@caitp
Copy link
Contributor

caitp commented Jun 17, 2015

yes, and it's arguably not a best-practice to include a body in DELETE requests because some backends discard them --- but I don't believe there's anything in the RFCs or the WHATWG specs for the clientside that enforce any of this

@ifbbprochris
Copy link

hey body, I use $reosure to delete, it doesn't send a body ,it put params in url.

is it possible to change, and how?

@ifbbprochris
Copy link

Also I think it is reasonable to put the body in $resource detele request.

People can choose the way they put the params.

@gkalpak
Copy link
Member

gkalpak commented Sep 25, 2016

For reasons explained here (and in other threads) I believe it is better to consider delete a non-body method by default. Note that there are more things that need to be configured (e.g. the Content-Type header); things that are possible to cause unexpected behavior with some backends.

While we might revisit this decision at a later point, atm treating delete as a non-body by default seems to be the most reasonable choice.

Also note that it is already possible to send a payload with delete, but you might need to manually configure the Content-Type header (either per request, or globally in $http.defaults.headers.delete). E.g.:

$http({
  method: 'delete',
  url: '/some/url',
  headers: {'Content-Type': 'application/json'},
  data: {some: 'payload'}
});

// or

$http.delete('/some/url', {
  headers: {'Content-Type': 'application/json'},
  data: {some: 'payload'}
});

There is also some discussion in #3207 with more details.

@gkalpak gkalpak closed this as completed Sep 25, 2016
@ifbbprochris
Copy link

@gkalpak Thanks for you answering,I really appreciate that, that helps me a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants