fix: negotiate HEAD content type on bucket root - #26
Merged
Conversation
Follow-up to #25: HEAD /{bucket}/ returned application/xml unconditionally, while GET on the same URL serves the browse UI to clients that prefer HTML. Reuse _prefers_html so HEAD reports the content type GET would have sent, and set Vary: Accept since the response now varies on it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Follow-up to the item noted as out-of-scope in #25:
HEAD /{bucket}/returnscontent-type: application/xmlunconditionally, whileGET /{bucket}/negotiates onAcceptand serves the browse UI (text/html) to browsers. Per RFC 9110 §9.3.2, HEAD should report the same headers GET would have sent.Fix
In
head_object's bucket-root branch, negotiate the content type with the same_prefers_html()helper GET uses, and setVary: Acceptsince the response now varies on it (same reasoning as #24/#25 — the nginx proxy cache stores HEAD responses too).The unbrowseable 403 path is unchanged, matching GET's non-negotiated
AccessDeniedresponse.HEAD /{bucket}/subdir/is left alone: it maps to HeadObject on the key and 404s (tested behavior intest_head_object), which matches real S3 semantics even though GET serves a listing there.Testing
Added
test_head_bucket_root_indexmirroringtest_head_root_index: asserts status, negotiated content type, andVaryfor bothAccepttypes, and compares HEAD against GET on the same URL. Verified it fails without the app change and passes with it.Full suite: 73 passed.
@StephanPreibisch @neomorphic