diff options
| author | Andy Balholm <andybalholm@gmail.com> | 2017-04-17 11:58:30 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-04-17 22:32:05 +0000 |
| commit | 668cca6cb4fbf217b9e00f306d5e8a6f80134288 (patch) | |
| tree | f358c847a12c5cff2c5dd3c197a23c3a978b75fa /src/net/http/response_test.go | |
| parent | 533ed967c6e842b4f9b9b503d20b3af698a4e022 (diff) | |
| download | go-git-668cca6cb4fbf217b9e00f306d5e8a6f80134288.tar.gz | |
net/http: ignore extra space between response version and status code
Reading a response with a status line like "HTTP/1.0 401 Unauthorized"
(with two spaces after the version) has been returning an error. Now the
extra space will be ignored.
Fixes #19989
Change-Id: I0c88a6ef7562ba80e2e2635be2070dd1b5b671a7
Reviewed-on: https://go-review.googlesource.com/40933
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/response_test.go')
| -rw-r--r-- | src/net/http/response_test.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/net/http/response_test.go b/src/net/http/response_test.go index 660d51791b..8b8c90ef50 100644 --- a/src/net/http/response_test.go +++ b/src/net/http/response_test.go @@ -318,7 +318,7 @@ var respTests = []respTest{ { "HTTP/1.0 303\r\n\r\n", Response{ - Status: "303 ", + Status: "303", StatusCode: 303, Proto: "HTTP/1.0", ProtoMajor: 1, @@ -532,6 +532,29 @@ some body`, }, "\x1f\x8b\b\x00\x00\x00\x00\x00\x00\x00s\xf3\xf7\a\x00\xab'\xd4\x1a\x03\x00\x00\x00", }, + + // Issue 19989: two spaces between HTTP version and status. + { + "HTTP/1.0 401 Unauthorized\r\n" + + "Content-type: text/html\r\n" + + "WWW-Authenticate: Basic realm=\"\"\r\n\r\n" + + "Your Authentication failed.\r\n", + Response{ + Status: "401 Unauthorized", + StatusCode: 401, + Proto: "HTTP/1.0", + ProtoMajor: 1, + ProtoMinor: 0, + Request: dummyReq("GET"), + Header: Header{ + "Content-Type": {"text/html"}, + "Www-Authenticate": {`Basic realm=""`}, + }, + Close: true, + ContentLength: -1, + }, + "Your Authentication failed.\r\n", + }, } // tests successful calls to ReadResponse, and inspects the returned Response. |
