diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2018-11-05 16:26:45 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-11-14 21:07:02 +0000 |
| commit | bfd9b94069e74b0c6516a045cbb83bf1024a1269 (patch) | |
| tree | ba017b7c5b061b122f2f4d889bd88c761bfa220d /src/net/http/requestwrite_test.go | |
| parent | 0c7762cd184649552309c82671bf81f89d215ff7 (diff) | |
| download | go-bfd9b94069e74b0c6516a045cbb83bf1024a1269.tar.xz | |
net/http: make Transport respect {X-,}Idempotency-Key header
Fixes #19943
Change-Id: I5e0fefe44791d7b3556095d726c2a753ec551ef2
Reviewed-on: https://go-review.googlesource.com/c/147457
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/net/http/requestwrite_test.go')
| -rw-r--r-- | src/net/http/requestwrite_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/net/http/requestwrite_test.go b/src/net/http/requestwrite_test.go index 246fb4e65d..7dbf0d4e8a 100644 --- a/src/net/http/requestwrite_test.go +++ b/src/net/http/requestwrite_test.go @@ -544,6 +544,38 @@ var reqWriteTests = []reqWriteTest{ "User-Agent: Go-http-client/1.1\r\n" + "\r\n", }, + + // Verify that a nil header value doesn't get written. + 23: { + Req: Request{ + Method: "GET", + URL: mustParseURL("/foo"), + Header: Header{ + "X-Foo": []string{"X-Bar"}, + "X-Idempotency-Key": nil, + }, + }, + + WantWrite: "GET /foo HTTP/1.1\r\n" + + "Host: \r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "X-Foo: X-Bar\r\n\r\n", + }, + 24: { + Req: Request{ + Method: "GET", + URL: mustParseURL("/foo"), + Header: Header{ + "X-Foo": []string{"X-Bar"}, + "X-Idempotency-Key": []string{}, + }, + }, + + WantWrite: "GET /foo HTTP/1.1\r\n" + + "Host: \r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "X-Foo: X-Bar\r\n\r\n", + }, } func TestRequestWrite(t *testing.T) { |
