Skip to content

Commit

Permalink
Merge pull request #2956 from lucas-clemente/remove-duplicate-scheme-…
Browse files Browse the repository at this point in the history
…check

remove duplicate check of the URL scheme in the HTTP/3 client
  • Loading branch information
marten-seemann committed Dec 29, 2020
2 parents 41970df + 7e4ac36 commit 052d0b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions http3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ func (c *client) maxHeaderBytes() uint64 {

// RoundTrip executes a request and returns a response
func (c *client) RoundTrip(req *http.Request) (*http.Response, error) {
if req.URL.Scheme != "https" {
return nil, errors.New("http3: unsupported scheme")
}
if authorityAddr("https", hostnameFromRequest(req)) != c.hostname {
return nil, fmt.Errorf("http3 client BUG: RoundTrip called for the wrong client (expected %s, got %s)", c.hostname, req.Host)
}
Expand Down
10 changes: 7 additions & 3 deletions http3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,15 @@ var _ = Describe("Client", func() {
Expect(err).To(MatchError("http3 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() {
req, err := http.NewRequest("https", "http://quic.clemente.io:1337/foobar.html", nil)
It("allows requests using a different scheme", func() {
testErr := errors.New("handshake error")
req, err := http.NewRequest("masque", "masque://quic.clemente.io:1337/foobar.html", nil)
Expect(err).ToNot(HaveOccurred())
dialAddr = func(hostname string, _ *tls.Config, _ *quic.Config) (quic.EarlySession, error) {
return nil, testErr
}
_, err = client.RoundTrip(req)
Expect(err).To(MatchError("http3: unsupported scheme"))
Expect(err).To(MatchError(testErr))
})
})

Expand Down

0 comments on commit 052d0b2

Please sign in to comment.