]> Cypherpunks repositories - gostls13.git/commit
http: fix two Transport gzip+persist crashes
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 12 May 2011 02:33:15 +0000 (22:33 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 12 May 2011 02:33:15 +0000 (22:33 -0400)
commitfa23a70044dba2cc23bfa22cb739e552258700cd
tree95607d756dbb96bc3a86098156e2a8c09eeb38be
parentd080a1cf147b9377edc25b108d28fad4ced46e31
http: fix two Transport gzip+persist crashes

There were a couple issues:

-- HEAD requests were attempting to be ungzipped,
   despite having no content.  That was fixed in
   the previous patch version, but ultimately was
   fixed as a result of other refactoring:

-- persist.go's ClientConn "lastbody" field was
   remembering the wrong body, since we were
   mucking with it later. Instead, ditch
   ClientConn's readRes func field and add a new
   method passing it in, so we can use a closure
   and do all our bodyEOFSignal + gunzip stuff
   in one place, simplifying a lot of code and
   not requiring messing with ClientConn's innards.

-- closing the gzip reader didn't consume its
   contents.  if the caller wasn't done reading
   all the response body and ClientConn closed it
   (thinking it'd move past those bytes in the
   TCP stream), it actually wouldn't.  so introduce
   a new wrapper just for gzip reader to have its
   Close method do an ioutil.Discard on its body
   first, before the close.

Fixes #1725
Fixes #1804

R=rsc, eivind
CC=golang-dev
https://golang.org/cl/4523058
src/pkg/http/persist.go
src/pkg/http/transport.go
src/pkg/http/transport_test.go