diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2011-06-24 16:46:14 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2011-06-24 16:46:14 -0700 |
| commit | 5d4eea6a2f50e0a07a4878f97146e1e3355523e3 (patch) | |
| tree | 820d5f9932c3355083b1e6eefbb6839b7a05edee /src/pkg/http/request.go | |
| parent | e16b74075f49d4bd42d30edb7f7081ea359f364e (diff) | |
| download | go-5d4eea6a2f50e0a07a4878f97146e1e3355523e3.tar.xz | |
http: better handling of 0-length Request.Body
As rsc suggested after change 58a6bdac3d12 was committed, we
now read the first byte of Request.Body when the
Request.ContentLength is 0 to disambiguate between a truly
zero-length body and a body of unknown length where the user
didn't set the ContentLength field.
This was also causing the reverse proxy problem where incoming
requests (which always have a body, of private type http.body,
even for 0-lengthed requests) were being relayed to the http
Transport for fetching, which was serializing the request as a
chunked request (since ContentLength was 0 and Body was
non-nil)
Fixes #1999
R=golang-dev, kevlar
CC=golang-dev
https://golang.org/cl/4628063
Diffstat (limited to 'src/pkg/http/request.go')
| -rw-r--r-- | src/pkg/http/request.go | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/pkg/http/request.go b/src/pkg/http/request.go index 183a35c712..cd6965fa5d 100644 --- a/src/pkg/http/request.go +++ b/src/pkg/http/request.go @@ -511,13 +511,6 @@ func NewRequest(method, url string, body io.Reader) (*Request, os.Error) { req.ContentLength = int64(v.Len()) case *bytes.Buffer: req.ContentLength = int64(v.Len()) - default: - req.ContentLength = -1 // chunked - } - if req.ContentLength == 0 { - // To prevent chunking and disambiguate this - // from the default ContentLength zero value. - req.TransferEncoding = []string{"identity"} } } |
