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:
@ -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_())
|
||||
|
Reference in New Issue
Block a user