mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http: ignore Transfer-Encoding for HTTP/1.0 responses
Fixes #12785 Change-Id: Iae4383889298c6a78b1ba41bd2cda70b0758fcba Reviewed-on: https://go-review.googlesource.com/15737 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
2961cab965
commit
2d823fdebf
2 changed files with 70 additions and 11 deletions
|
|
@ -456,6 +456,55 @@ some body`,
|
|||
|
||||
"",
|
||||
},
|
||||
|
||||
// Issue 12785: HTTP/1.0 response with bogus (to be ignored) Transfer-Encoding.
|
||||
// Without a Content-Length.
|
||||
{
|
||||
"HTTP/1.0 200 OK\r\n" +
|
||||
"Transfer-Encoding: bogus\r\n" +
|
||||
"\r\n" +
|
||||
"Body here\n",
|
||||
|
||||
Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Proto: "HTTP/1.0",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 0,
|
||||
Request: dummyReq("GET"),
|
||||
Header: Header{},
|
||||
Close: true,
|
||||
ContentLength: -1,
|
||||
},
|
||||
|
||||
"Body here\n",
|
||||
},
|
||||
|
||||
// Issue 12785: HTTP/1.0 response with bogus (to be ignored) Transfer-Encoding.
|
||||
// With a Content-Length.
|
||||
{
|
||||
"HTTP/1.0 200 OK\r\n" +
|
||||
"Transfer-Encoding: bogus\r\n" +
|
||||
"Content-Length: 10\r\n" +
|
||||
"\r\n" +
|
||||
"Body here\n",
|
||||
|
||||
Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: 200,
|
||||
Proto: "HTTP/1.0",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 0,
|
||||
Request: dummyReq("GET"),
|
||||
Header: Header{
|
||||
"Content-Length": {"10"},
|
||||
},
|
||||
Close: true,
|
||||
ContentLength: 10,
|
||||
},
|
||||
|
||||
"Body here\n",
|
||||
},
|
||||
}
|
||||
|
||||
func TestReadResponse(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue