Signed-off-by: Daniel Nephin <dnephin@docker.com> Upstream-commit: a6ac5495e11d34b1887476ca89f841df1056249a Component: engine
18 lines
360 B
Go
18 lines
360 B
Go
package httputils
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
// Download requests a given URL and returns an io.Reader.
|
|
func Download(url string) (resp *http.Response, err error) {
|
|
if resp, err = http.Get(url); err != nil {
|
|
return nil, err
|
|
}
|
|
if resp.StatusCode >= 400 {
|
|
return nil, fmt.Errorf("Got HTTP status code >= 400: %s", resp.Status)
|
|
}
|
|
return resp, nil
|
|
}
|