|
|
@@ -2892,3 +2892,24 @@ func TestTransportRetryAfterGOAWAY(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestAuthorityAddr(t *testing.T) {
|
|
|
+ tests := []struct {
|
|
|
+ scheme, authority string
|
|
|
+ want string
|
|
|
+ }{
|
|
|
+ {"http", "foo.com", "foo.com:80"},
|
|
|
+ {"https", "foo.com", "foo.com:443"},
|
|
|
+ {"https", "foo.com:1234", "foo.com:1234"},
|
|
|
+ {"https", "1.2.3.4:1234", "1.2.3.4:1234"},
|
|
|
+ {"https", "1.2.3.4", "1.2.3.4:443"},
|
|
|
+ {"https", "[::1]:1234", "[::1]:1234"},
|
|
|
+ {"https", "[::1]", "[::1]:443"},
|
|
|
+ }
|
|
|
+ for _, tt := range tests {
|
|
|
+ got := authorityAddr(tt.scheme, tt.authority)
|
|
|
+ if got != tt.want {
|
|
|
+ t.Errorf("authorityAddr(%q, %q) = %q; want %q", tt.scheme, tt.authority, got, tt.want)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|