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

Issue 58240043: code review 58240043: net/http: read as much as possible (including EOF) duri... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by bradfitz
Modified:
10 years, 2 months ago
Reviewers:
adg
CC:
adg, golang-codereviews
Visibility:
Public.

Description

net/http: read as much as possible (including EOF) during chunked reads This is the chunked half of https://codereview.appspot.com/49570044 . We want full reads to return EOF as early as possible, when we know we're at the end, so http.Transport client connections are eagerly re-used in the common case, even if no Read or Close follows. To do this, make the chunkedReader.Read fill up its argument p []byte buffer as much as possible, as long as that doesn't involve doing any more blocking reads to read chunk headers. That means if we have a chunk EOF ("0\r\n") sitting in the incoming bufio.Reader, we see it and set EOF on our final Read.

Patch Set 1 #

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

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

Total comments: 3

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+329 lines, -85 lines) Patch
M src/pkg/net/http/chunked.go View 1 2 3 2 chunks +39 lines, -19 lines 0 comments Download
M src/pkg/net/http/chunked_test.go View 1 2 3 5 chunks +74 lines, -3 lines 0 comments Download
M src/pkg/net/http/httputil/chunked.go View 1 2 3 4 chunks +46 lines, -28 lines 0 comments Download
M src/pkg/net/http/httputil/chunked_test.go View 1 2 3 6 chunks +78 lines, -9 lines 0 comments Download
A src/pkg/net/http/httputil/httputil.go View 1 2 3 1 chunk +32 lines, -0 lines 0 comments Download
M src/pkg/net/http/httputil/persist.go View 1 2 3 1 chunk +0 lines, -2 lines 0 comments Download
M src/pkg/net/http/transfer_test.go View 1 2 chunks +27 lines, -0 lines 0 comments Download
M src/pkg/net/http/transport_test.go View 1 1 chunk +33 lines, -24 lines 0 comments Download

Messages

Total messages: 3
bradfitz
Hello adg@golang.org (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
10 years, 2 months ago (2014-01-29 11:16:05 UTC) #1
adg
LGTM https://codereview.appspot.com/58240043/diff/40001/src/pkg/net/http/chunked.go File src/pkg/net/http/chunked.go (right): https://codereview.appspot.com/58240043/diff/40001/src/pkg/net/http/chunked.go#newcode71 src/pkg/net/http/chunked.go:71: if cr.err != nil { you can delete ...
10 years, 2 months ago (2014-01-29 12:10:11 UTC) #2
bradfitz
10 years, 2 months ago (2014-01-29 12:44:26 UTC) #3
*** Submitted as https://code.google.com/p/go/source/detail?r=08918ee18957 ***

net/http: read as much as possible (including EOF) during chunked reads

This is the chunked half of https://codereview.appspot.com/49570044 .

We want full reads to return EOF as early as possible, when we
know we're at the end, so http.Transport client connections are eagerly
re-used in the common case, even if no Read or Close follows.

To do this, make the chunkedReader.Read fill up its argument p []byte
buffer as much as possible, as long as that doesn't involve doing
any more blocking reads to read chunk headers. That means if we
have a chunk EOF ("0\r\n") sitting in the incoming bufio.Reader,
we see it and set EOF on our final Read.

LGTM=adg
R=adg
CC=golang-codereviews
https://codereview.appspot.com/58240043
Sign in to reply to this message.

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