Skip to content
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

Merged
merged 2 commits into from Apr 17, 2023
Merged

Fix range requests #279

merged 2 commits into from Apr 17, 2023

Conversation

ChrisSchinnerl
Copy link
Member

No description provided.

if err != nil {
jc.Error(err, http.StatusRequestedRangeNotSatisfiable)
return
}
if length < obj.Size() {
jc.ResponseWriter.WriteHeader(http.StatusPartialContent)
Copy link
Member Author

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")
Copy link
Member Author

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) {
Copy link
Member Author

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

@ChrisSchinnerl ChrisSchinnerl marked this pull request as ready for review April 13, 2023 15:48
@peterjan peterjan merged commit c878228 into master Apr 17, 2023
6 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the chris/fix-range-requests branch April 17, 2023 07:44
@peterjan peterjan mentioned this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants