-
Notifications
You must be signed in to change notification settings - Fork 13
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
Prefer lower case headers. #3
Conversation
2e1a8cb
to
6efa762
Compare
6efa762
to
1c97581
Compare
@@ -34,11 +34,11 @@ def lookup(request, entity_store) | |||
|
|||
# find a cached entry that matches the request. | |||
env = request.env | |||
match = entries.detect{ |req,res| requests_match?((res['Vary'] || res['vary']), env, req) } | |||
match = entries.detect{ |req,res| requests_match?((res['vary'] || res['vary']), env, req) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it intentional to check the same value twice? Before, it was checking if there was a match for both the Capitalized Vary
and the lowercase vary
. But now that everything is lowercase, we only need to check one of them, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct, do you have time to submit a PR fixing this? Thanks!
requests_match?(vary, env, stored_env) | ||
end | ||
|
||
headers = persist_response(response) | ||
headers.delete('Age') | ||
headers.delete('age') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here. Is it necessary to delete the same header twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if you can submit a PR to fix this, please do! Thanks!
In PR rack#3, headers were converted to lowercase, which resulted in the same action being performed twice. This PR removes those duplicate actions.
In PR #3, headers were converted to lowercase, which resulted in the same action being performed twice. This PR removes those duplicate actions. Co-authored-by: Moncef Belyamani <[email protected]>
return nil if match.nil? | ||
|
||
_, res = match | ||
if body = entity_store.open(res['X-Content-Digest']) | ||
if body = entity_store.open(res['x-content-digest']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, after deploying with the updated version of this gem, you can end up in a scenario where a long-term cached item still exists in the metastore with the capitalized header, but when it goes to get the key here using the lowercase header, it returns nil, and passes nil to the open method, resulting in an exception further down, and since on lookups on exceptions, it calls pass
instead of fetch
, it isn't going to store the response with the updated header and will continue to hit the error
Could check here for both cases, but I think another fine option is just letting people know they should flush their cache if they're upgrading from an earlier version to this one or later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind creating an issue for this?
See rack/rack#1812 for more details.