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

Relaxed 304 If-None-Match test to support weak key #65

Merged
merged 1 commit into from
Mar 23, 2023
Merged

Conversation

colinbendell
Copy link

@colinbendell colinbendell commented Mar 22, 2023

HTTP Requests with If-None-Match should support quoted, weak and arrays of entity tags. This PR enables a more generous match for eTags to increase 304 responses.

Specifically, given an etag: abc123 value, the following if-none-match requests should yield a 304:

  • if-none-match: abc123
  • if-none-match: "abc123"
  • if-none-match: W/"abc123"
  • if-none-match: "abc123", "def456"

@colinbendell colinbendell self-assigned this Mar 22, 2023
@colinbendell colinbendell marked this pull request as ready for review March 22, 2023 21:39
@colinbendell colinbendell requested a review from a team as a code owner March 22, 2023 21:39
# If-None-Match: "abc"
# If-None-Match: W/"abc"
# If-None-Match: "abc", "def"
if !@env["HTTP_IF_NONE_MATCH"].nil? && @env["HTTP_IF_NONE_MATCH"].include?(cache_key_hash)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that matching way too lose?

cache_key_hash = "b"

If-None-Match: W/"abc" shouldn't match IMO.

I think this method need actual parsing of the header, String#include? doesn't.

@colinbendell colinbendell merged commit 82ca12e into main Mar 23, 2023
@colinbendell colinbendell deleted the weak_304 branch March 23, 2023 19:28
@casperisfine
Copy link

@colinbendell you didn't address my comment...

@colinbendell
Copy link
Author

colinbendell commented Mar 23, 2023 via email

@casperisfine
Copy link

I fixed it anyway: #66

@shopify-shipit shopify-shipit bot temporarily deployed to rubygems March 27, 2023 14:41 Inactive
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

Successfully merging this pull request may close these issues.

3 participants