Skip to content
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::Util::Headers.normalize_headers modifies underscores in headers #958

Open
bmo opened this issue Nov 3, 2021 · 1 comment
Open

Comments

@bmo
Copy link

bmo commented Nov 3, 2021

Related: #863

Headers like SYNCHRONOUS_ONLY are normalized to Synchronous-Only, which will break any tests verifying an underscore in a header (there are existing APIs that expect underscores in certain headers, commercial example: https://developer.blackhawknetwork.com/hawkmarketplace/docs/placing-egift-real-time-orders).

WebMock::Util::Headers.normalize_headers({'SYNCHRONOUS_ONLY'=>'true'})
=> {"Synchronous-Only"=>"true"}

I note that other libraries intentionally or inadvertently provide a means of bypassing this behavior. For example, the key that is being normalized could be checked for string-like characteristics, and normalization skipped if so.

The Faraday gem, also subject to an MIT license, handles it this way: https://github.com/lostisland/faraday/blob/d0efa092829362f95d4b71d3bcd3c52189b74277/lib/faraday/utils/headers.rb#L41
By using the hash-rocket syntax to define a header (e.g. 'SYNCHRONOUS_ONLY' => 'true') the header name could pass unmolested.

@bmo
Copy link
Author

bmo commented Nov 4, 2021

Sorry, with better looking, I now note that this is a duplicate of #474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant