in internal/httprange/http_reader.go [124:150]
func (r *Reader) setResponse(res *http.Response) error {
// TODO: add metrics https://gitlab.com/gitlab-org/gitlab-pages/-/issues/448
switch res.StatusCode {
case http.StatusOK:
// some servers return 200 OK for bytes=0-
// TODO: should we handle r.Resource.Last-Modified as well?
if r.offset > 0 || r.Resource.ETag != "" && r.Resource.ETag != res.Header.Get("ETag") {
r.Resource.setError(ErrRangeRequestsNotSupported)
return ErrRangeRequestsNotSupported
}
case http.StatusNotFound:
r.Resource.setError(ErrNotFound)
return ErrNotFound
case http.StatusPartialContent:
// Requested `Range` request succeeded https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206
break
case http.StatusRequestedRangeNotSatisfiable:
r.Resource.setError(ErrRangeRequestsNotSupported)
return ErrRangeRequestsNotSupported
default:
return fmt.Errorf("httprange: read response %d: %q", res.StatusCode, res.Status)
}
r.res = res
return nil
}