requests icon indicating copy to clipboard operation
requests copied to clipboard

No data parameter in requests.delete()

Open apetresc opened this issue 15 years ago • 4 comments

The requests.delete() method does not support having a data parameter. The HTTP spec for DELETE does not give much guidance about whether this is allowed, but in practical situations, it is often used. There is currently no way to access such services using requests.

(In particular it's worth noting that curl -X DELETE -d "data" works without issue)

apetresc avatar Oct 07 '11 06:10 apetresc

According to the HTTP spec, "The DELETE method requests that the origin server delete the resource identified by the Request-URI."

This would seem to negate the usefulness of passing data in the request body, as the resource should be solely identified by the Request-URI.

sergedomk avatar Oct 08 '11 01:10 sergedomk

I agree that a theoretical discussion can be had about this, and I'd probably be on your side, @sergedomk. However, we cannot ignore that, in reality servers can and do use data in the request body even for DELETE requests, and other standard tools (like curl) support this.

If you want an example, here's the first one that comes to mind: http://docs.gnip.com/w/page/23733233/Rules%20Methods%20Documentation#deleterules

apetresc avatar Oct 08 '11 02:10 apetresc

I'd say this is a point for theoretical discussion.

Submitting a DELETE with data is already possible using requests.

requests.request('DELETE', url, data="data")

So the discussion is whether or not it should be included in the DELETE method as well. It's a question of where to draw a boundary on adhering to the spec vs. not.

curl is a great example of this as it has no adherence to the HTTP spec at all. curl -V FOOBAR -d "data" also works perfectly fine. And FOOBAR is definitely not a HTTP method.

sergedomk avatar Oct 08 '11 04:10 sergedomk

Oh, interesting. I didn't know about requests.request. That certainly mitigates my issue, and makes me agree with you even more.

I'm okay with closing this issue if @kennethreitz is.

apetresc avatar Oct 08 '11 04:10 apetresc