-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Do not write manifests on HEAD requests #4286
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
Do not write manifests on HEAD requests #4286
Conversation
6206998
to
2e0bdf3
Compare
@joaodrp can you please have a look here as well? |
according the distribution spec outlined in the heading and manifest, it makes sense to me.
|
@jaimem88 please help to fix the CI failure. |
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.
LGTM, thanks!
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.
Thanks, LGTM.
I recalled there was some discussion about HEAD requests, but that was not about body. And looking back at my comments there, the http RFC even marks it as "MUST NOT send a body"; #3691 (comment) |
changes LGTM, but could you squash the commits? Looks like the second one is fixing an issue that was introduced in the first commit, so we don't need to preserve that fix up in history |
Signed-off-by: Jaime Martinez <jmartinez@gitlab.com>
5cb0f8d
to
2763ba1
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.
lgtm
The
GetManifest
handler is used for bothHEAD
andGET
requests. ForHEAD
requests, the handler also callsw.Write()
on the response writer.This is not needed as HEAD requests should not include a response body. Most clients will actually just ignore the body, for example
curl
does this and simply skips it.This PR adds a check to the
GetManifest
handler to return early when the request method is aHEAD
. This would prevent wasting resources writing to the response writer.The
ServeBlob
method of theblobServer
uses the standard libraryhttp.ServeContent
which internally has a check to only copy the result if the request method is notHEAD
. So this change will follow the same approach as the blobs handler.The change has also been recently merged to GitLab's Container Registry via https://gitlab.com/gitlab-org/container-registry/-/merge_requests/1585.