1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-23 21:47:52 +08:00

Return better error code when an http request failed.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
This commit is contained in:
Kevin Atkinson
2018-06-26 04:56:03 -04:00
parent 90972095a9
commit e5189f4230

View File

@ -215,10 +215,11 @@ func (f *FileManager) readURLDataObj(c *cid.Cid, d *pb.DataObj) ([]byte, error)
res, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
return nil, &CorruptReferenceError{StatusFileError, err}
}
if res.StatusCode != http.StatusPartialContent {
return nil, fmt.Errorf("expected HTTP 206 got %d", res.StatusCode)
return nil, &CorruptReferenceError{StatusFileError,
fmt.Errorf("expected HTTP 206 got %d", res.StatusCode)}
}
outbuf := make([]byte, d.GetSize_())