lib/proxy: log response body on non-200 response code

This should improve debuggability for https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1179
This commit is contained in:
Aliaksandr Valialkin 2021-04-03 03:02:52 +03:00
parent 2256b79a89
commit 43f9842b6f

View File

@ -159,7 +159,7 @@ func sendConnectRequest(proxyConn net.Conn, proxyAddr, dstAddr, authHeader strin
return nil, fmt.Errorf("cannot read CONNECT response for dstAddr=%q: %w", dstAddr, err)
}
if statusCode := res.Header.StatusCode(); statusCode != 200 {
return nil, fmt.Errorf("unexpected status code received: %d; want: 200", statusCode)
return nil, fmt.Errorf("unexpected status code received: %d; want: 200; response body: %q", statusCode, res.Body())
}
return conn, nil
}