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
Fix range requests #279
Fix range requests #279
Conversation
430f242
to
5bf9f74
Compare
if err != nil { | ||
jc.Error(err, http.StatusRequestedRangeNotSatisfiable) | ||
return | ||
} | ||
if length < obj.Size() { | ||
jc.ResponseWriter.WriteHeader(http.StatusPartialContent) |
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.
This was the issue. Writing the header first before setting all the other fields.
} | ||
jc.ResponseWriter.Header().Set("Content-Length", strconv.FormatInt(length, 10)) | ||
jc.ResponseWriter.Header().Set("Accept-Ranges", "bytes") |
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.
Added this for good measure.
@@ -48,66 +49,6 @@ const ( | |||
queryStringParamTotalShards = "totalshards" | |||
) | |||
|
|||
// parseRange parses a Range header string as per RFC 7233. Only the first range | |||
// is returned. If no range is specified, parseRange returns 0, size. | |||
func parseRange(s string, size int64) (offset, length int64, _ error) { |
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.
replaced with standard library call
No description provided.