-
Notifications
You must be signed in to change notification settings - Fork 556
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
Webmock stubs treat HEADER keys slightly differently than real Net::HTTP?? #686
Comments
@lastobelus what version of WebMock are you using with VCR? have cassettes been recorded using the same version of WebMock? |
I ran into this issue today, using WebMock 3.4.2 and VCR 4.0.0. I tracked this down to some non-standards-conforming behavior in
If a header name contains underscores, this will convert those to dashes. The HTTP/1.1 spec only discusses case-insensitivity and whitespace, but doesn't prescribe any other forms of normalization (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). Therefore, underscores should be treated as distinct from dashes. Perhaps a better header name normalization might simply be:
Funny enough, my problem was with the same HTTP header as @lastobelus. Shopify produces this unconventionally-named header server-side and consumes it in their Ruby API. Real interactions were working fine, but VCR'd ones weren't. I'm happy to put together a pull request for this. |
After looking at this briefly, I feel this would be difficult to fix without breaking a lot of existing WebMock usage. There are many cases where symbols of the form For my case, I've fixed my issue by setting up a |
I'm also having this issue, I needed to stub a response with a header key has underscores and webmock is converting them to dashes. |
WebMock stubs have dasherized keys when using
request[xxx]
, whileNet::HTTP
responses have underscored keys:To illustrate here are a real call and a mocked call compared:
I am using a gem that uses the second form.
Ruby 2.3.1, but the code in the gem that uses
response['underscored_header_name']
form is 4 year old code.The text was updated successfully, but these errors were encountered: