Repository navigation
Do not write manifests on HEAD requests - #4286
Merged
joaodrp merged 1 commit intoFeb 29, 2024
Merged
Conversation
jaimem88
force-pushed
the
fix-do-not-write-manifest-head-requests
branch
2 times, most recently
from
February 28, 2024 05:12
6206998 to
2e0bdf3
Compare
Contributor
Author
|
@joaodrp can you please have a look here as well? |
Collaborator
|
according the distribution spec outlined in the heading and manifest, it makes sense to me. |
Collaborator
|
@jaimem88 please help to fix the CI failure. |
Member
|
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) |
Member
|
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 <[email protected]>
jaimem88
force-pushed
the
fix-do-not-write-manifest-head-requests
branch
from
February 29, 2024 00:16
5cb0f8d to
2763ba1
Compare
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.
The
GetManifesthandler is used for bothHEADandGETrequests. ForHEADrequests, 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
curldoes this and simply skips it.This PR adds a check to the
GetManifesthandler to return early when the request method is aHEAD. This would prevent wasting resources writing to the response writer.The
ServeBlobmethod of theblobServeruses the standard libraryhttp.ServeContentwhich 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.