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
Rack::Mock#parse_cookies_from_header does not follow SPEC #1629
Comments
It should use |
@mpalmer do you want to submit a PR? Try wrapping the headers in |
Yes, I can whip up a PR. I was thinking of just iterating the |
#has_key? isn't required to be supported by the object in the `headers` element of the response coming back out of the app. This replaces that call with a transmogrification into a HeaderHash so we can use an index as normal. The odd `hash[] || ""` construction is necessary because HeaderHash#fetch doesn't respect header name case insensitivity.
A wild PR appears! It strikes! |
HeaderHash is memoized can you please check if in the typical case it can be almost a no-op. |
If I'm understanding you correctly, then yes, if what gets passed into the |
Sorry, was putting kids to bed, that makes sense! |
`#has_key?` isn't required to be supported by the object in the `headers` element of the response coming back out of the app. This replaces that call with a transmogrification into a `HeaderHash` so we can use an index as normal. The odd `hash[] || ""` construction is necessary because `HeaderHash#fetch` doesn't respect header name case insensitivity.
`#has_key?` isn't required to be supported by the object in the `headers` element of the response coming back out of the app. This replaces that call with a transmogrification into a `HeaderHash` so we can use an index as normal. The odd `hash[] || ""` construction is necessary because `HeaderHash#fetch` doesn't respect header name case insensitivity.
It just makes good sense in general, but it specifically makes the proximate fix for rack#1629 a lot cleaner.
`#has_key?` isn't required to be supported by the object in the `headers` element of the response coming back out of the app. This replaces that call with a transmogrification into a `HeaderHash` so we can use an index as normal. The odd `hash[] || ""` construction is necessary because `HeaderHash#fetch` doesn't respect header name case insensitivity.
Rack::MockResponse inherits from Rack::Response, which already uses a HeaderHash for the headers. The original_headers were only used for cookie parsing, which for some reason was happening before the call to super in initialize (so the headers weren't available yet). There seems to be no reason why the cookie parsing can't happen after the call to super, in which case we can use the headers directly. Co-Authored-By: Matt Palmer <mpalmer@hezmatt.org> Fixes rack#1629 Fixes rack#1630
Rack::MockResponse inherits from Rack::Response, which already uses a HeaderHash for the headers. The original_headers were only used for cookie parsing, which for some reason was happening before the call to super in initialize (so the headers weren't available yet). There seems to be no reason why the cookie parsing can't happen after the call to super, in which case we can use the headers directly. Fixes rack#1629 Fixes rack#1630 Co-authored-by: Matt Palmer <mpalmer@hezmatt.org>
Rack::MockResponse inherits from Rack::Response, which already uses a HeaderHash for the headers. The original_headers were only used for cookie parsing, which for some reason was happening before the call to super in initialize (so the headers weren't available yet). There seems to be no reason why the cookie parsing can't happen after the call to super, in which case we can use the headers directly. Fixes #1629 Fixes #1630 Co-authored-by: Matt Palmer <mpalmer@hezmatt.org>
From SPEC:
However, Rack::Mock#parse_cookies_from_header calls
has_key?
on the headers. As such, this breaks any Rack application which takes the spec at its word, and provides another object which responds toeach
and yields values of key and value (such as, for instance, an array of two-element arrays representing header names and values).The text was updated successfully, but these errors were encountered: