@cryptotaxi247 / kubo / commits / 726d18fd3

urlstore: Accept "200 OK" in addition to "206 Partial Content".

Some servers seem to return 200 OK when range header covers entire file. If the content is wrong we will detect later so there is no harm in accepting either response. License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Jul 25, 2018 at 14:51 UTC 726d18fd35161c81f7428c49ae3a53430de9c686
1 file changed +2 -2
filestore/fsrefstore.go
+2 -2
@@ -216,9 +216,9 @@ func (f *FileManager) readURLDataObj(c *cid.Cid, d *pb.DataObj) ([]byte, error)
216 if err != nil {
217 return nil, &CorruptReferenceError{StatusFileError, err}
218 }
219 - if res.StatusCode != http.StatusPartialContent {
219 + if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusPartialContent {
220 return nil, &CorruptReferenceError{StatusFileError,
221 - fmt.Errorf("expected HTTP 206 got %d", res.StatusCode)}
221 + fmt.Errorf("expected HTTP 200 or 206 got %d", res.StatusCode)}
222 }
223
224 outbuf := make([]byte, d.GetSize_())