c := ts.Client()
_, err := c.Get(ts.URL)
- if e, g := "Get /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g {
+ if e, g := `Get "/?n=10": stopped after 10 redirects`, fmt.Sprintf("%v", err); e != g {
t.Errorf("with default client Get, expected error %q, got %q", e, g)
}
// HEAD request should also have the ability to follow redirects.
_, err = c.Head(ts.URL)
- if e, g := "Head /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g {
+ if e, g := `Head "/?n=10": stopped after 10 redirects`, fmt.Sprintf("%v", err); e != g {
t.Errorf("with default client Head, expected error %q, got %q", e, g)
}
// Do should also follow redirects.
greq, _ := NewRequest("GET", ts.URL, nil)
_, err = c.Do(greq)
- if e, g := "Get /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g {
+ if e, g := `Get "/?n=10": stopped after 10 redirects`, fmt.Sprintf("%v", err); e != g {
t.Errorf("with default client Do, expected error %q, got %q", e, g)
}
// Requests with an empty Method should also redirect (Issue 12705)
greq.Method = ""
_, err = c.Do(greq)
- if e, g := "Get /?n=10: stopped after 10 redirects", fmt.Sprintf("%v", err); e != g {
+ if e, g := `Get "/?n=10": stopped after 10 redirects`, fmt.Sprintf("%v", err); e != g {
t.Errorf("with default client Do and empty Method, expected error %q, got %q", e, g)
}
{
desc: "Strip password from error message",
in: "http://user:password@dummy.faketld/",
- out: "Get http://user:***@dummy.faketld/: dummy impl",
+ out: `Get "http://user:***@dummy.faketld/": dummy impl`,
},
{
desc: "Don't Strip password from domain name",
in: "http://user:password@password.faketld/",
- out: "Get http://user:***@password.faketld/: dummy impl",
+ out: `Get "http://user:***@password.faketld/": dummy impl`,
},
{
desc: "Don't Strip password from path",
in: "http://user:password@dummy.faketld/password",
- out: "Get http://user:***@dummy.faketld/password: dummy impl",
+ out: `Get "http://user:***@dummy.faketld/password": dummy impl`,
},
{
desc: "Strip escaped password",
in: "http://user:pa%2Fssword@dummy.faketld/",
- out: "Get http://user:***@dummy.faketld/: dummy impl",
+ out: `Get "http://user:***@dummy.faketld/": dummy impl`,
},
}
for _, tC := range testCases {
{"foo.html", false},
{"../dir/", false},
+ {" http://foo.com", false},
{"http://192.168.0.%31/", false},
{"http://192.168.0.%31:8080/", false},
{"http://[fe80::%31]/", false},
{"mysql://x@y(z:123)/foo", true}, // not well-formed per RFC 3986, golang.org/issue/33646
{"mysql://x@y(1.2.3.4:123)/foo", true},
+ {" http://foo.com", true}, // invalid character in schema
+ {"ht tp://foo.com", true}, // invalid character in schema
+ {"ahttp://foo.com", false}, // valid schema characters
+ {"1http://foo.com", true}, // invalid character in schema
+
{"http://[]%20%48%54%54%50%2f%31%2e%31%0a%4d%79%48%65%61%64%65%72%3a%20%31%32%33%0a%0a/", true}, // golang.org/issue/11208
{"http://a b.com/", true}, // no space in host name please
{"cache_object://foo", true}, // scheme cannot have _, relative path cannot have : in first segment