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

Issue 4529050: code review 4529050: http: fix transport bug with zero-length bodies (Closed)

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

Description

http: fix transport bug with zero-length bodies An optimization in Transport which re-uses TCP connections early in the case where there is no response body interacted poorly with ErrBodyReadAfterClose. Upon recycling the TCP connection early we would Close the Response.Body (in case the user forgot to), but in the case of a zero-lengthed body, the user's handler might not have run yet. This CL makes sure the Transport doesn't try to Close requests when we're about to immediately re-use the TCP connection. This also includes additional tests I wrote while debugging.

Patch Set 1 #

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

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

Total comments: 1

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

Patch Set 5 : diff -r e02bcde2458d https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+81 lines, -2 lines) Patch
M src/pkg/http/serve_test.go View 1 1 chunk +44 lines, -0 lines 0 comments Download
M src/pkg/http/transport.go View 1 2 3 4 1 chunk +11 lines, -0 lines 0 comments Download
M src/pkg/io/multi_test.go View 1 1 chunk +3 lines, -2 lines 0 comments Download
M src/pkg/mime/multipart/multipart_test.go View 1 1 chunk +23 lines, -0 lines 0 comments Download

Messages

Total messages: 10
bradfitz
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 6 months ago (2011-05-11 11:57:47 UTC) #1
rsc
http://codereview.appspot.com/4529050/diff/4001/src/pkg/http/persist.go File src/pkg/http/persist.go (right): http://codereview.appspot.com/4529050/diff/4001/src/pkg/http/persist.go#newcode373 src/pkg/http/persist.go:373: // We don't call close on a 'noBodyReader', though, ...
13 years, 6 months ago (2011-05-11 14:35:50 UTC) #2
bradfitz
I didn't want to change the behavior from the handler's/clients's point of view. The API ...
13 years, 6 months ago (2011-05-11 17:11:32 UTC) #3
rsc
but you're not changing the API. do you mean that the client might not get ...
13 years, 6 months ago (2011-05-11 17:33:38 UTC) #4
bradfitzgoog
Read shouldn't work after Close. I don't want to sometimes allow it and sometimes not. ...
13 years, 6 months ago (2011-05-11 17:45:39 UTC) #5
rsc
On Wed, May 11, 2011 at 13:45, Brad Fitzpatrick <bradfitz@google.com> wrote: > Read shouldn't work ...
13 years, 6 months ago (2011-05-11 17:48:30 UTC) #6
rsc
On Wed, May 11, 2011 at 13:45, Brad Fitzpatrick <bradfitz@google.com> wrote: > Read shouldn't work ...
13 years, 6 months ago (2011-05-11 17:49:03 UTC) #7
bradfitz
Hello rsc, bradfitzgoog (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 6 months ago (2011-05-11 19:02:08 UTC) #8
rsc
LGTM
13 years, 6 months ago (2011-05-11 19:03:50 UTC) #9
bradfitz
13 years, 6 months ago (2011-05-11 19:11:40 UTC) #10
*** Submitted as http://code.google.com/p/go/source/detail?r=2887dd36b6f8 ***

http: fix transport bug with zero-length bodies

An optimization in Transport which re-uses TCP
connections early in the case where there is
no response body interacted poorly with
ErrBodyReadAfterClose.  Upon recycling the TCP
connection early we would Close the Response.Body
(in case the user forgot to), but in the case
of a zero-lengthed body, the user's handler might
not have run yet.

This CL makes sure the Transport doesn't try
to Close requests when we're about to immediately
re-use the TCP connection.

This also includes additional tests I wrote
while debugging.

R=rsc, bradfitzgoog
CC=golang-dev
http://codereview.appspot.com/4529050
Sign in to reply to this message.

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