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 downcases characters in header keys #863

Open
ulyssesrex opened this issue Nov 27, 2019 · 5 comments

Comments

@ulyssesrex
Copy link

This stub, chained with with(), will never match its intended request...

stub_request(:post, /urlmatcher/).
  with(headers: { 
    "SOAPAction" => "https://some.soap.endpoint/where/things/happen" 
  })

because the stub's HeadersPattern has been normalized and no longer matches the given header. Note Soapaction instead of SOAPAction.

#<WebMock::HeadersPattern:0x00007fe38db8b078                                                                                                             
     @pattern={"Soapaction"=>"https://www.assuresign.net/Services/DocumentNOW/Envelopes/IEnvelopeService/CreateEnvelope"}>
@bblimke
Copy link
Owner

bblimke commented Dec 27, 2019

@ulyssesrex thank you for pointing that. SOAPAction is indeed a culprit. I guess this can be changed in WebMock but with major version change in WebMock as I it would break many existing WebMock setups, where people set header expectations using e.g lowercase.

@ioquatix
Copy link
Contributor

ioquatix commented Jan 6, 2020

The normalized form of headers which is enforced by HTTP/2 is lowercase.

@bblimke
Copy link
Owner

bblimke commented Jan 6, 2020

Thank you for the input @ioquatix It's only for HTTP/2 right?

@ioquatix
Copy link
Contributor

ioquatix commented Jan 6, 2020

It's also for HTTP/1.

https://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive

HTTP/2 just makes it an error and servers will drop the connection.

@ioquatix
Copy link
Contributor

Just FYI, this will become standard rack behaviour too: rack/rack#1592

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

3 participants