Repository navigation
assets: match If-None-Match lists and "*", and skip If-Modified-Since when If-None-Match is present - #4027
Merged
Conversation
… when If-None-Match is present
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4027 +/- ##
=========================================
Coverage 94.18% 94.19%
- Complexity 6656 6665 +9
=========================================
Files 432 432
Lines 20897 20909 +12
Branches 2096 2099 +3
=========================================
+ Hits 19682 19695 +13
+ Misses 762 759 -3
- Partials 453 455 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AssetHandlerhandles conditional requests in three ways that differ from RFC 9110.If-None-Matchis compared as one string. The field is*or a comma-separated list of entity tags, compared with the weak comparison function, soW/"x"and"x"match (section 13.1.2). Today these requests get a full200for an unchanged asset:If-None-Match: "x", W/"<etag>"If-None-Match: *If-None-Match: "<etag>", the ETag withoutW/If-Modified-Sinceis checked even whenIf-None-Matchis present. Section 13.2.2 says it is only evaluated when the request has noIf-None-Match. As a result,If-None-Match: "stale"together with the asset's ownLast-Modifiedgets304, and a cache keeps a response whose ETag the server no longer has. ETags are more precise than dates (one-second resolution), which is why they take precedence.If-Modified-Sincethat isn't a date is a400.If-Modified-Since: yesterdaythrowsTypeMismatchExceptionfromValue.longValue. Section 13.1.3 says the recipient must ignore a value that isn't a valid HTTP-date.The change:
If-None-Matchwith a newetagMatches(): an exact match as before, or*, or a list element equal to the ETag onceW/is removed from both.If-Modified-Sinceonly when the request has noIf-None-Match.If-Modified-Sinceas absent.A
304still has noETag, asFeaturedTestexpects.The new
AssetHandlerTest(Mockito, like the other handler tests) runs nine header combinations against a mockedAsset. Without the change, six of them fail: the strong form, both lists and*get200, the stale tag plus date gets304, andyesterdaythrows.mvn -pl jooby testpasses (1307 tests), andspotless:checkreports no violations in the changed files.