-
Notifications
You must be signed in to change notification settings - Fork 498
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
DELETE does not allow POST-style data #91
Comments
I checked the source after reading the ticket and thought this might be the case. Drats. So, the issue here isn't really whether it's a bug, but rather how to accommodate this in a backwards compatible way with the API. Technically, GET and HEAD can also have entity bodies (only TRACE disallows it), but it's convenient to pass in an array of data and have that squashed into a query string. This is also inconsistent with POST, PATCH and PUT, since you can't add query parameters there. I'd also hate to add in a parameter like Unless you've got a better idea of how to handle this, here's what I'm thinking:
Comments welcome, as always. :) |
Thanks for looking into this!
|
Currently encountering this behavior/bug in my API testing. Any decisions on the implementation strategy, or assignment of the coding work? Personally I rather enjoy the convenience of automatic parsing of the data into a query string, and would opt for a boolean option to indicate when this should be done. Default for the option is a toss up. |
One of our API calls using method DELETE requires JSON in a POST field. We had been doing it with straight cURL. When transitioning to Requests, I tried the delete method but that didn't allow data to be passed. Then, I attempted to just use the request method.
URL:
https://REMOVED/terminus.php?site=UUID&path=code-branch
headers:
data:
method: DELETE
options:
That caused:
https://github.com/rmccue/Requests/blob/master/library/Requests/Transport/cURL.php#L327
I believe the problem is at:
https://github.com/rmccue/Requests/blob/022400b23f697792fa340c93d250257293c6ec37/library/Requests/Transport/cURL.php#L224
This assumes that DELETE won't be POSTing. Additionally:
https://github.com/rmccue/Requests/blob/master/library/Requests/Transport/cURL.php#L241
cURL isn't setting options for CURLOPT_POST or CURLOPT_POSTFIELDS.
I'll admit that this is a bit edge-case. However, it doesn't seem to be against RFC. http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request gets into that in greater detail.
I have no problem setting an additional option or calling the request method in a different way.
Let me know if you have any questions or if you need more context! Thanks in advance.
The text was updated successfully, but these errors were encountered: