Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(74)

Issue 4523058: code review 4523058: http: fix two Transport gzip+persist crashes (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years ago by bradfitz
Modified:
13 years ago
Reviewers:
CC:
rsc, uggedal, golang-dev
Visibility:
Public.

Description

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 issue 1725 Fixes issue 1804

Patch Set 1 #

Patch Set 2 : diff -r b751683cc600 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r b751683cc600 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r b751683cc600 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -30 lines) Patch
M src/pkg/http/persist.go View 1 2 3 4 chunks +7 lines, -4 lines 0 comments Download
M src/pkg/http/transport.go View 1 2 3 8 chunks +39 lines, -26 lines 0 comments Download
M src/pkg/http/transport_test.go View 1 2 chunks +13 lines, -0 lines 0 comments Download

Messages

Total messages: 5
bradfitz
Hello rsc, eivind@uggedal.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years ago (2011-05-11 22:45:28 UTC) #1
bradfitz
Hello rsc, eivind@uggedal.com (cc: golang-dev@googlegroups.com), Please take another look.
13 years ago (2011-05-12 00:13:19 UTC) #2
bradfitz
(I changed the commit message substantially (it ended up fixing two issues), but codereview didn't ...
13 years ago (2011-05-12 00:15:08 UTC) #3
rsc
LGTM Please let me submit it.
13 years ago (2011-05-12 02:25:37 UTC) #4
rsc
13 years ago (2011-05-12 02:33:20 UTC) #5
*** Submitted as http://code.google.com/p/go/source/detail?r=ea6ff96a4c34 ***

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 issue 1725
Fixes issue 1804

R=rsc, eivind
CC=golang-dev
http://codereview.appspot.com/4523058

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b