1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00

fix: Use HTTP error if upload to Artifactory failes

In a former commit we respected the error of the Close()
call for a HTTP response. The fix was to introduce named
return values (e.g. err for error).
The problem: We defered the resp.Close() via
err = resp.Close()
This had the effect of always overwrite the real error
that happen when the HTTP call failes (due to checkResponse func).
This commit is contained in:
Andy Grunwald 2017-12-02 21:29:59 +01:00
parent b282c84df3
commit 37bc09f2bc

View File

@ -278,8 +278,8 @@ func newUploadRequest(target, username, secret string, reader io.Reader, size in
}
// executeHTTPRequest processes the http call with respect of context ctx
func executeHTTPRequest(ctx *context.Context, req *http.Request, v interface{}) (resp *http.Response, err error) {
resp, err = http.DefaultClient.Do(req)
func executeHTTPRequest(ctx *context.Context, req *http.Request, v interface{}) (*http.Response, error) {
resp, err := http.DefaultClient.Do(req)
if err != nil {
// If we got an error, and the context has been canceled,
// the context's error is probably more useful.
@ -292,9 +292,7 @@ func executeHTTPRequest(ctx *context.Context, req *http.Request, v interface{})
return nil, err
}
defer func() {
err = resp.Body.Close()
}()
defer resp.Body.Close() // nolint: errcheck
err = checkResponse(resp)
if err != nil {