-
Notifications
You must be signed in to change notification settings - Fork 386
fix(api): bytes head entity headers #5551
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
base: master
Are you sure you want to change the base?
Changes from all commits
7f644bc
25c3a21
38ea652
9c9b79a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -794,6 +794,10 @@ func (s *Service) downloadHandler(logger log.Logger, w http.ResponseWriter, r *h | |
| w.Header().Add(AccessControlExposeHeaders, ContentDispositionHeader) | ||
|
|
||
| if headersOnly { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Early-returning 200 OK here bypasses Go's http.ServeContent, which causes HEAD requests containing a Range header (e.g. HEAD /bytes/ with Range: bytes=0-99) to return 200 OK with the total content length and no Content-Range header. In contrast, a GET request with Range: bytes=0-99 returns 206 Partial Content with Content-Range: bytes 0-99/ and Content-Length: 100. According to RFC 9110 Section 9.3.2, HEAD requests must return identical entity headers to GET. Conditional HEAD requests (If-None-Match, If-Modified-Since) also fail to return 304 Not Modified for the same reason. |
||
| // http.ServeContent would set this, but the GET path is not reached here. | ||
| // "bytes" is the range unit, not the endpoint. | ||
| w.Header().Set(AcceptRangesHeader, "bytes") | ||
| w.Header().Add(AccessControlExposeHeaders, AcceptRangesHeader) | ||
| w.WriteHeader(http.StatusOK) | ||
| return | ||
| } | ||
|
|
||
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.
Could we add a test case to TestBytesHead for HEAD requests with a Range header (e.g. Range: bytes=0-10)?