mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup utils.Download
Docker-DCO-1.0-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
e24e9c09f8
commit
762a0cc472
1 changed files with 2 additions and 5 deletions
|
@ -6,7 +6,6 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"index/suffixarray"
|
"index/suffixarray"
|
||||||
"io"
|
"io"
|
||||||
|
@ -46,14 +45,12 @@ func Go(f func() error) chan error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request a given URL and return an io.Reader
|
// Request a given URL and return an io.Reader
|
||||||
func Download(url string) (*http.Response, error) {
|
func Download(url string) (resp *http.Response, err error) {
|
||||||
var resp *http.Response
|
|
||||||
var err error
|
|
||||||
if resp, err = http.Get(url); err != nil {
|
if resp, err = http.Get(url); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode >= 400 {
|
if resp.StatusCode >= 400 {
|
||||||
return nil, errors.New("Got HTTP status code >= 400: " + resp.Status)
|
return nil, fmt.Errorf("Got HTTP status code >= 400: %s", resp.Status)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue