-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request: read body from file if the method is DELETE #274
Conversation
Currently Request.from_file ignore the body of a request if the method is DELETE. This fixes that by using the dictionary we have to know if a request might have a body or not.
As far as I can tell an HTTP DELETE with a body is unspecified and is not supported by many clients [1]. Also you changed some code in webob that explicitly forbade having a body for a DELETE in the This PR changes some fundamental parts of the request processing by modifying [1] http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request |
Having a body in DELETE is nowadays often used in REST API, which is my case here. So having WebOb ignoring entirely it just because most client out there don't handle it either sounds like a weak argument. Though I recognize it does change a previous assumption, but as you said, since it's not in the hot route, I don't think it's a big issue. |
To be clear, I said you're changing webob's hot route as a side effect of changing
This is not my experience with using REST APIs that support DELETE requests. As you can see in the StackOverflow link I provided, the body is ignored on several platforms and is not merely an issue of client libraries. I realize this SO post is from 2008 and things may have changed since then. However I don't see any movement or updates on RFC2616 which leaves this as undefined behavior. There were apparently some drafts where they made it allowed, but nothing that has been approved. I personally don't mind if we choose to accept bodies on DELETE requests, but keeping things the way they are is justifiable as well considering it's undefined and webob definitely isn't the only library out there ignoring the body. Anyway, I'll leave this for other reviewers to decide, but I just wanted to be sure to point out the full extent of what this PR affects in webob if it's accepted to avoid anything slipping through the cracks as it does actually affect how webob handles DELETE requests over the wire. As a final comment, I think the PR looks good from a code quality perspective if we choose to merge it. |
RFC7231 (updates RFC2616):
|
@jd am I correct in assuming that there is a use case for this in OpenStack? I personally don't think DELETE should have a body, but I can understand that there may be use cases that I am missing. I want to do a review of |
@bertjwregeer You are correct. FWIW, we use Pecan (http://www.pecanpy.org/) which supports DELETE with a body (and alternate POST ?_method=delete form as a fallback) and (And while I do now what the RFC says, "undefined" and "might reject" is not "forbidden". :-) |
Yeah, the same could be said for a HEAD/GET request for instance, bodies there have no defined semantics either, and some servers may reject it, but I know that ElasticSearch for instance has a body on GET. I am planning to refactor |
So here's the problem, and why the limits were added in the first place:
However, This means when you call This patch as it currently stands to add
with a WSGI server that has |
Currently Request.from_file ignore the body of a request if the method is
DELETE. This fixes that by using the dictionary we have to know if a request
might have a body or not.