]> Cypherpunks repositories - gostls13.git/commit
net/http: read as much as possible (including EOF) during chunked reads
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 29 Jan 2014 12:44:21 +0000 (13:44 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 29 Jan 2014 12:44:21 +0000 (13:44 +0100)
commitff29be14c4c63912963c442109da56a98960ea2d
treef03267c2d8fb88a15c9158b84e1102b9ea3a2e3d
parent01e3b4fc6aa13e126f61782ad42aa51ba490b302
net/http: read as much as possible (including EOF) during chunked reads

This is the chunked half of https://golang.org/cl/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://golang.org/cl/58240043
src/pkg/net/http/chunked.go
src/pkg/net/http/chunked_test.go
src/pkg/net/http/httputil/chunked.go
src/pkg/net/http/httputil/chunked_test.go
src/pkg/net/http/httputil/httputil.go [new file with mode: 0644]
src/pkg/net/http/httputil/persist.go
src/pkg/net/http/transfer_test.go
src/pkg/net/http/transport_test.go