improve error message in the h2quic client

This commit is contained in:
Marten Seemann
2017-06-03 17:39:54 +02:00
parent 9054e5205f
commit c2a89e6b78
2 changed files with 2 additions and 3 deletions

View File

@@ -144,8 +144,7 @@ func (c *client) Do(req *http.Request) (*http.Response, error) {
return nil, errors.New("quic http2: unsupported scheme")
}
if authorityAddr("https", hostnameFromRequest(req)) != c.hostname {
utils.Debugf("%s vs %s", req.Host, c.hostname)
return nil, errors.New("h2quic Client BUG: Do called for the wrong client")
return nil, fmt.Errorf("h2quic Client BUG: RoundTrip called for the wrong client (expected %s, got %s)", c.hostname, req.Host)
}
hasBody := (req.Body != nil)

View File

@@ -212,7 +212,7 @@ var _ = Describe("Client", func() {
req, err := http.NewRequest("https", "https://quic.clemente.io:1336/foobar.html", nil)
Expect(err).ToNot(HaveOccurred())
_, err = client.Do(req)
Expect(err).To(MatchError("h2quic Client BUG: Do called for the wrong client"))
Expect(err).To(MatchError("h2quic Client BUG: RoundTrip called for the wrong client (expected quic.clemente.io:1337, got quic.clemente.io:1336)"))
})
It("refuses to do plain HTTP requests", func() {