mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Close resp.Body before returning error
This commit is contained in:
parent
fbc85e9838
commit
39a5e1b929
@ -614,6 +614,9 @@ func (r *Request) Stream() (io.ReadCloser, error) {
|
|||||||
return resp.Body, nil
|
return resp.Body, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// ensure we close the body before returning the error
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// we have a decent shot at taking the object returned, parsing it as a status object and returning a more normal error
|
// we have a decent shot at taking the object returned, parsing it as a status object and returning a more normal error
|
||||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -132,6 +132,7 @@ func (s *SpdyRoundTripper) NewConnection(resp *http.Response) (httpstream.Connec
|
|||||||
connectionHeader := strings.ToLower(resp.Header.Get(httpstream.HeaderConnection))
|
connectionHeader := strings.ToLower(resp.Header.Get(httpstream.HeaderConnection))
|
||||||
upgradeHeader := strings.ToLower(resp.Header.Get(httpstream.HeaderUpgrade))
|
upgradeHeader := strings.ToLower(resp.Header.Get(httpstream.HeaderUpgrade))
|
||||||
if !strings.Contains(connectionHeader, strings.ToLower(httpstream.HeaderUpgrade)) || !strings.Contains(upgradeHeader, strings.ToLower(HeaderSpdy31)) {
|
if !strings.Contains(connectionHeader, strings.ToLower(httpstream.HeaderUpgrade)) || !strings.Contains(upgradeHeader, strings.ToLower(HeaderSpdy31)) {
|
||||||
|
defer resp.Body.Close()
|
||||||
responseError := ""
|
responseError := ""
|
||||||
responseErrorBytes, err := ioutil.ReadAll(resp.Body)
|
responseErrorBytes, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user