Repository navigation
Conversation
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.
Closes #18
DocumentRoot::checkPreconditions()compared the timestamps the wrong way round: it answered304 Not Modifiedwhen the file's mtime was newer thanIf-Modified-Since, i.e. exactly when the file had changed. Clients with a stale cache got an empty 304 instead of the new content, and clients with a fresh cache got a full 200.The fix flips the comparison, so a 304 is sent only when
mtime <= If-Modified-Since.While in there I also made
If-Modified-Sincebe ignored wheneverIf-None-Matchis present, as RFC 9110 section 13.1.3 requires. A matchingIf-None-Matchstill returns 304 early; a non-matching one no longer falls through to the date check. It is a one-line change, but happy to split it out if you prefer.If-Unmodified-Sinceis untouched.Tests (in
test/DocumentRootTest.php):If-Modified-Sinceolder than the mtime returns 200 with the bodyIf-None-Matchplus a newerIf-Modified-Sincereturns 200testPreconditionNotModifiedasserted the buggy behaviour (anIf-Modified-Sinceof 1970 giving 304), so it now sends the file's own mtime instead. The new tests fail on current 2.x and pass with this change; the full suite is green.Heads up: the repo's CI currently fails at setup because of
actions/cache@v2, as noted on #22, so the checks here will not show green for that reason alone.