-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
HTTP DELETE requests with JSON body don't work #484
Comments
Thanks @doktor500, it might be an issue with the underlying Ruby process. Will need to investigate. |
Last time I checked this, I thought HTTP DELETE wasn't valid with a body (I believe HTTP 1.1 says that they may have a body, but the server might refuse the request). |
That was my thoughts briefly, but a cursory google seems to indicate its up to the server implementation. Further digging needed but it seems likely it should be supported. |
So, here's the current delete spec: https://tools.ietf.org/html/rfc7231#section-4.3.5
This is like the body in GET - you're allowed to include one, but it doesn't mean anything, and it might mean a spec-compliant server rejects the request. We had a similar discussion about GET, where I argued that we shouldn't support this. (see here: pact-foundation/pact-js-core#183 ) We also had this same issue reported earlier, where I thought it was fixed upstream (but didn't check the spec at that time): pact-foundation/pact-js-core#183 I'm starting to change my mind on this one, since we get this question a lot, and it's clear what the user intends (even if it's not spec compliant). I think the biggest challenge is cross-language support, since implementations are allowed to reject deletes with bodies. I think the ideal behaviour is to allow the user to specify DELETE with body (and to have a mock server that allows this), but to warn that it's not valid. What do you think? |
Ideally it would be nice to offer that functionality, but unless Rack Test supports it, it can't actually be done in the Ruby Implementation. It might need to wait until we move to Rust. |
I haven't tried myself, but if you're game, you could try https://github.com/pact-foundation/pact-js/#pact-js-v3 a go (it's in beta, but is supported so we will fix bugs etc.). |
This could be tested with the latest 10.x.x library. I suspect it will suffer the same fate. |
I think you could close this one. There isn't any meaning to a delete body. |
I agree with you that's how it should be interpreted, but my reading of the RFC is that it's undefined - so a server can interpret that how it wishes. As a framework, we should be cautious expressing too strong of an opinion there. I've dropped the |
I’ve tested this out in pact-python both via the ruby and rust core, both in generating pact files with a DELETE req with JSON body, and verifying it on the provider side. Consumer side:- pactflow/example-consumer-python@master...test/delete_req_with_body Generated Pacts Verification with latest ruby CLI - https://github.com/pactflow/example-provider-python/blob/37d695ff9af8c66dc75b4e9f8961b480633a1e43/docker-compose.yml#L25 Verification with latest rust CLI - https://github.com/pactflow/example-provider-python/blob/37d695ff9af8c66dc75b4e9f8961b480633a1e43/docker-compose.yml#L47 JavaScript example here - pactflow/example-provider@master...refs/heads/delete_req_with_body |
Issue Classification
Bug Report
Contracts for HTTP
DELETE
requests that contain a JSON body can't be verified in the provider.Software versions
@pact-foundation/pact": "^9.11.0
@pact-foundation/pact": "^9.11.0
v12.10.0
Issue Checklist
Confirm the following:
Expected behaviour
A contract for an HTTP DELETE request with a JSON body can be verified in the provider
Actual behaviour
A contract for an HTTP DELETE request with a JSON body can't be verified in the provider
Steps to reproduce
https://github.com/doktor500/pact-delete-bug
Relevant log files
The text was updated successfully, but these errors were encountered: