Commit 3ec9de61 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'httprs-fork' into 'master'

Update httprs for broken range implementations

See merge request gitlab-org/gitlab-workhorse!266
parents 44689559 2fc4c24d
......@@ -111,8 +111,15 @@ func (r *HttpReadSeeker) Read(p []byte) (n int, err error) {
//
// May return ErrRangeRequestsNotSupported, ErrInvalidRange or ErrContentHasChanged
func (r *HttpReadSeeker) ReadAt(p []byte, off int64) (n int, err error) {
var nn int
r.Seek(off, 0)
return r.Read(p)
for n < len(p) && err == nil {
nn, err = r.Read(p[n:])
n += nn
}
return
}
// Close closes the response body
......@@ -202,7 +209,12 @@ func (r *HttpReadSeeker) rangeRequest() error {
case http.StatusRequestedRangeNotSatisfiable:
return ErrInvalidRange
case http.StatusOK:
return ErrContentHasChanged
// some servers return 200 OK for bytes=0-
if r.pos > 0 ||
(etag != "" && etag != res.Header.Get("ETag")) {
return ErrContentHasChanged
}
fallthrough
case http.StatusPartialContent:
r.r = res.Body
return nil
......
......@@ -97,10 +97,12 @@
"revisionTime": "2017-08-26T09:06:48Z"
},
{
"checksumSHA1": "6TbprMZzwDk+SaW+JxdxvnauyDk=",
"checksumSHA1": "mb0MqzDyYEQMgh8+qwVm1RV4cxc=",
"path": "github.com/jfbus/httprs",
"revision": "32cf48c14a79f94eb3d8100efc00e773c5c8b160",
"revisionTime": "2017-11-08T13:45:55Z"
"revision": "7861a11508467e8d1575182d6456065e6402d8fc",
"revisionTime": "2018-06-14T10:08:21Z",
"version": "master",
"versionExact": "master"
},
{
"checksumSHA1": "oIkoHb8+rM5Etur5HhZVY/sDQKQ=",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment