Commit 750b6c63 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http: close underlying gzip Reader too

Fixes #1724

R=rsc
CC=golang-dev
https://golang.org/cl/4443056
parent a1f5f3f1
......@@ -532,12 +532,12 @@ func (pc *persistConn) roundTrip(req *Request) (resp *Response, err os.Error) {
re.res.Header.Del("Content-Encoding")
re.res.Header.Del("Content-Length")
re.res.ContentLength = -1
var err os.Error
re.res.Body, err = gzip.NewReader(re.res.Body)
gzReader, err := gzip.NewReader(re.res.Body)
if err != nil {
pc.close()
return nil, err
}
re.res.Body = &readFirstCloseBoth{gzReader, re.res.Body}
}
return re.res, re.err
......@@ -606,3 +606,18 @@ func (es *bodyEOFSignal) Close() (err os.Error) {
}
return
}
type readFirstCloseBoth struct {
io.ReadCloser
io.Closer
}
func (r *readFirstCloseBoth) Close() os.Error {
if err := r.ReadCloser.Close(); err != nil {
return err
}
if err := r.Closer.Close(); err != nil {
return err
}
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment