Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
8b990263
Commit
8b990263
authored
Jul 24, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11057 from liggitt/close_body
Close resp.Body before returning error
parents
18466bfc
39a5e1b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
request.go
pkg/client/request.go
+3
-0
roundtripper.go
pkg/util/httpstream/spdy/roundtripper.go
+1
-0
No files found.
pkg/client/request.go
View file @
8b990263
...
@@ -614,6 +614,9 @@ func (r *Request) Stream() (io.ReadCloser, error) {
...
@@ -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
{
...
...
pkg/util/httpstream/spdy/roundtripper.go
View file @
8b990263
...
@@ -134,6 +134,7 @@ func (s *SpdyRoundTripper) NewConnection(resp *http.Response) (httpstream.Connec
...
@@ -134,6 +134,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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment