]> Cypherpunks repositories - gostls13.git/commit
http: better handling of 0-length Request.Body
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 24 Jun 2011 23:46:14 +0000 (16:46 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 24 Jun 2011 23:46:14 +0000 (16:46 -0700)
commit5d4eea6a2f50e0a07a4878f97146e1e3355523e3
tree820d5f9932c3355083b1e6eefbb6839b7a05edee
parente16b74075f49d4bd42d30edb7f7081ea359f364e
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
src/pkg/http/request.go
src/pkg/http/requestwrite_test.go
src/pkg/http/reverseproxy_test.go
src/pkg/http/transfer.go