diff options
author | Petar Maymounkov <petarm@gmail.com> | 2010-01-25 18:49:08 -0800 |
---|---|---|
committer | Petar Maymounkov <petarm@gmail.com> | 2010-01-25 18:49:08 -0800 |
commit | 493b72305737b1ce4254d813abe8a09b37114286 (patch) | |
tree | 25f74dae6be34a755aac2333e4f257464d463a3a /src/pkg/http/response.go | |
parent | 28a2effc53619040b3fa045a4218c8902884faf8 (diff) | |
download | golang-493b72305737b1ce4254d813abe8a09b37114286.tar.gz |
http: make Request.Body an io.ReadCloser, matching Response.Body.
R=rsc, rsc1
CC=golang-dev
http://codereview.appspot.com/194046
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/http/response.go')
-rw-r--r-- | src/pkg/http/response.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/http/response.go b/src/pkg/http/response.go index b20a6a003..9a2355ff4 100644 --- a/src/pkg/http/response.go +++ b/src/pkg/http/response.go @@ -134,7 +134,7 @@ func ReadResponse(r *bufio.Reader, requestMethod string) (resp *Response, err os // or close connection when finished, since multipart is not supported yet switch { case chunked(resp.TransferEncoding): - resp.Body = &body{Reader: newChunkedReader(r), resp: resp, r: r, closing: resp.Close} + resp.Body = &body{Reader: newChunkedReader(r), th: resp, r: r, closing: resp.Close} case resp.ContentLength >= 0: resp.Body = &body{Reader: io.LimitReader(r, resp.ContentLength), closing: resp.Close} default: @@ -149,13 +149,13 @@ func ReadResponse(r *bufio.Reader, requestMethod string) (resp *Response, err os // and then reads the trailer if necessary. type body struct { io.Reader - resp *Response // non-nil value means read trailer + th interface{} // non-nil (Response or Request) value means read trailer r *bufio.Reader // underlying wire-format reader for the trailer closing bool // is the connection to be closed after reading body? } func (b *body) Close() os.Error { - if b.resp == nil && b.closing { + if b.th == nil && b.closing { // no trailer and closing the connection next. // no point in reading to EOF. return nil @@ -172,7 +172,7 @@ func (b *body) Close() os.Error { } return err } - if b.resp == nil { // not reading trailer + if b.th == nil { // not reading trailer return nil } |