Repository navigation
Conversation
A HEAD miss is forwarded upstream as HEAD. A presigned GET URL includes the method in its signature, so S3-compatible stores answer HEAD with 403 even when GET would return the object, and servers without a HEAD route answer 405 or 501. Clients probing through the cache then got an error for an object they could download, including when the upstream redirects to such a URL. When the HEAD miss gets 403, 405 or 501, the probe is repeated as a GET and only its status and headers are used. The handler never reads the body and caches nothing; closing it drops the connection, although Go 1.27's transport first drains a body of up to 256 KiB to reuse it. The GET asks for identity encoding when the client didn't send Accept-Encoding, since otherwise the transport requests gzip and drops Content-Length as it decompresses. Other statuses, including 401, 404, 429 and server errors, are returned as before. Signed-off-by: Ravi Agarwal <ravi@perplexity.ai> Co-authored-by: Perplexity <noreply@perplexity.ai>
43d6381 to
42903a0
Compare
|
@codex review Created with Perplexity |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42903a03ff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: Ravi Agarwal <ravi@perplexity.ai> Co-authored-by: Perplexity <noreply@perplexity.ai>
|
@codex review Created with Perplexity |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
A
HEADmiss is forwarded upstream asHEAD, and the client gets whatever the upstream answers. Some upstreams refuseHEADfor objects they serve onGET:GETURL includes the method in its signature, so S3-compatible stores answerHEADwith 403 whether or not the object exists. This also applies when the upstream redirects to such a URL, because Go's client follows the redirect withHEAD.GETanswer 405 or 501.A client probing through the cache, for example for the size before a download, then sees an error for an object it can download.
Change
HEADmiss gets 403, 405 or 501,forwardHeadrepeats the probe as aGETand answers with that response's status and headers.GETbody and caches nothing. Closing the response drops the HTTP/1.1 connection or resets the HTTP/2 stream. Since Go 1.27, the transport first drains a body of up to 256 KiB in the background, for at most 50 ms, so it can reuse the connection.Accept-Encoding, theGETsendsAccept-Encoding: identity. Otherwise Go's transport asks for gzip on its own, which it never does forHEAD, and when the server compresses, the transport decompresses and removesContent-Length, so the probe would lose the size. A client that sendsAccept-Encodinghas it forwarded unchanged, as before.HEAD. For these upstreams a refused revalidation already counts as changed and refetches the entry, so that path stays correct.Behaviour changes
HEADmiss that gets 403, 405 or 501 now costs a second upstream request, and the client gets theGETresponse's status and headers.Testing
TestHeadMissRefusedByUpstreamserves aHEADmiss from an upstream that answersHEADandGETwith different statuses. It covers:GET, and 403 followed by 404;GETbody back until the client hangs up. The test checks the status,Content-Length,Content-Encoding, which methods reached the upstream, and that the probe hung up without waiting for the body.main, the five cases whereHEADis refused fail. Without the identity encoding, the successfulGETcases that don't sendAccept-EncodingloseContent-Length. If the probe reads the body, every case with a successfulGETfails.cachewdfrommainand from this branch, withhoststrategies in front of MinIO and of a local server:HEADthroughcachewdmainGETURL, object existsContent-Length: 7, ETagGETURL, object missingGETURLContent-Length: 7, ETagHEADwith 405, gzip-capableContent-LengthAccept-Encoding: gzipContent-Encoding: gzip, compressed lengthHEADanswers 404GETHEADanswers 403For the 1 GiB object, the upstream had sent at most 384 KiB over HTTP/1.1 when the connection closed, and at most 64 KiB over HTTP/2 when the stream was reset.
Created with Perplexity