aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/request.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-06-24 16:46:14 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2011-06-24 16:46:14 -0700
commit5d4eea6a2f50e0a07a4878f97146e1e3355523e3 (patch)
tree820d5f9932c3355083b1e6eefbb6839b7a05edee /src/pkg/http/request.go
parente16b74075f49d4bd42d30edb7f7081ea359f364e (diff)
downloadgo-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.go7
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"}
}
}