1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-31 14:51:57 +00:00

response nil check

This commit is contained in:
Luther Monson
2019-08-29 14:24:11 -07:00
committed by Craig Jellick
parent cbeaf3e5bf
commit 7317090b9b

View File

@@ -27,16 +27,19 @@ func connectToProxy(proxyURL string, headers http.Header, auth ConnectAuthorizer
}
ws, resp, err := dialer.Dial(proxyURL, headers)
if err != nil {
rb, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Couldn't read response body (err: %v)", resp.StatusCode, resp.Status, err2)
if resp == nil {
logrus.WithError(err).Errorf("Failed to connect to proxy. Empty dialer response")
} else {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Response body: %s", resp.StatusCode, resp.Status, rb)
rb, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Couldn't read response body (err: %v)", resp.StatusCode, resp.Status, err2)
} else {
logrus.WithError(err).Errorf("Failed to connect to proxy. Response status: %v - %v. Response body: %s", resp.StatusCode, resp.Status, rb)
}
}
return err
}
defer ws.Close()
defer resp.Body.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()