-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(pgs): initial support for conditional requests #178
Conversation
To test, follow the new instructions in dev.md to sign up and upload a file. Then:
|
Thanks so much for your contribution! I think we might want to take a stab at getting I'd really like align Thoughts? |
Alright, I quickly looked into it, I think we should just continue with your approach because converting |
Right if you update |
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.
Overall looks good since most of the changes are from fs.go
.
How hard would it be to add a test to web_test.go
that ensures things are working as intended?
5fb09f6
to
b9682df
Compare
Sure I can work on a test, thanks for reviewing! |
Tests added! |
cdb13a7
to
28e4b85
Compare
28e4b85
to
329e6a3
Compare
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.
Looks great, thanks!
This PR provides initial support for conditional requests.
I copied the important RFC-compliant bits from https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/net/http/fs.go and used that to parse and set the right headers and status codes for conditional requests.
The alternative would be using
http.ServeContent
, but that requires anio.ReadSeeker
which wouldn't work with files obtained from imgproxy since that returns anio.ReadCloser
.Ref: #177
If-Not-Modified
headers (Revalidation with If-Modified-Since not working (always returning 200) darkweak/souin#588), but this issue is technically not a blocker because browsers generally send bothIf-Modified-Since
andIf-None-Match
, where theIf-None-Match
takes precedence (which souin does handle), making the conditional request flow work as expected. This is all allowed by the RFCs as far as I can tell.