-
Notifications
You must be signed in to change notification settings - Fork 70
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 header names mangled even if conformant to RFC #78
Comments
The reason this transformation is going on is that the Ruby Rack protocol passes the headers from the "outside world" to all Rack compatible apps by producing a single environment hash that has all the HTTP header and request information in it. Here is an example:
All the HTTP headers are turned into keys named This is a tricky one, because pact terms only work on header values, not header names. I'm going to have to give it some thought. What package of the mock service are you using? (ie. pure ruby, or one of the wrapped implementations, or docker) |
I am using @pact-foundation/pact-node. Thanks for the hint with Rack. I found a page explaining that Rack does this to stay compatible with CGI. I am not a Ruby person. Is CGI used here at all? If not, maybe we can ask Rack to provide an option to not mangle the names in the first place? |
Rack is the Ruby defacto standard for interfacing between web applications
and their http servers. They won't be changing their interface for anyone.
I haven't giving up on working out a more elegant solution yet, but the
best I can think of at the moment is giving you a way to monkey patch the
code at runtime.
|
I may have come up with a work around, ping me if I don't reply in few
days.
|
I've got something in the works that will allow you to monkeypatch the method you need to fix. |
I try to help the guys over there with this fork/PR: pact-foundation/pact-js-core#60. Maybe you can try your changes against it already? |
I upgraded to the current versions of involved libraries, copied from your test to my patch file, and all works like a charm. A big thanks, also to @mefellows for merging pact-foundation/pact-js-core#60 there! I believe the other issue you mentioned in pact-foundation/pact-js#123 which you said you did not remember must be #38. (The OP of it says in pact-foundation/pact-js-core#24 that they changed the format of their headers in the meantime.) |
I am (indirectly) using pact-mock_service to test against a REST service that I do not control that requires HTTP header names of the form /[a-z]+(_[a-z]+)/, e.g., 'my_header'. These tests fail, and I find that somewhere between the client sending the request and the pact mock receiving it, header names get rewritten to the form /[A_Z][a-z](-[A-Z][a-z])/, e.g., 'My-Header'.
While the latter form is most common in the wild, the former seems still to be according to the following definitions from RFC 7230 (https://tools.ietf.org/html/rfc7230#page-22):
In https://github.com/pact-foundation/pact-mock_service/blob/7d4fd1f8ec6b6f6f118aae56fe6373ebc4f83972/lib/pact/consumer/mock_service/rack_request_helper.rb, I find:
All is well if I change the function to read,
I do not completely understand what is happening. What is the purpose of the original transformation? Can we do with my version?
Thank you!
The text was updated successfully, but these errors were encountered: