aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/requestwrite_test.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2015-01-21 19:27:34 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2015-04-09 09:26:52 +0000
commit957255f5ab1ca4aff3195a20b80fe2aa4eb9e336 (patch)
tree46c339093e1054f689410b298f7e4272bc6e7f51 /src/net/http/requestwrite_test.go
parent92c57363e0b4d193c4324e2af6902fe56b7524a0 (diff)
downloadgo-957255f5ab1ca4aff3195a20b80fe2aa4eb9e336.tar.xz
net/http: don't send IPv6 zone identifier in outbound request, per RFC 6874
When making a request to an IPv6 address with a zone identifier, for exmaple [fe80::1%en0], RFC 6874 says HTTP clients must remove the zone identifier "%en0" before writing the request for security reason. This change removes any IPv6 zone identifer attached to URI in the Host header field in requests. Fixes #9544. Change-Id: I7406bd0aa961d260d96f1f887c2e45854e921452 Reviewed-on: https://go-review.googlesource.com/3111 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/requestwrite_test.go')
-rw-r--r--src/net/http/requestwrite_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/net/http/requestwrite_test.go b/src/net/http/requestwrite_test.go
index 7a6bd58786..e9a5f5f080 100644
--- a/src/net/http/requestwrite_test.go
+++ b/src/net/http/requestwrite_test.go
@@ -455,6 +455,37 @@ var reqWriteTests = []reqWriteTest{
"ALL-CAPS: x\r\n" +
"\r\n",
},
+
+ // Request with host header field; IPv6 address with zone identifier
+ {
+ Req: Request{
+ Method: "GET",
+ URL: &url.URL{
+ Host: "[fe80::1%en0]",
+ },
+ },
+
+ WantWrite: "GET / HTTP/1.1\r\n" +
+ "Host: [fe80::1]\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
+ "\r\n",
+ },
+
+ // Request with optional host header field; IPv6 address with zone identifier
+ {
+ Req: Request{
+ Method: "GET",
+ URL: &url.URL{
+ Host: "www.example.com",
+ },
+ Host: "[fe80::1%en0]:8080",
+ },
+
+ WantWrite: "GET / HTTP/1.1\r\n" +
+ "Host: [fe80::1]:8080\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
+ "\r\n",
+ },
}
func TestRequestWrite(t *testing.T) {