http3: expose an OpenStream method on the RoundTripper (#4409)

The stream exposes two methods required for doing an HTTP request:
SendRequestHeader and ReadResponse. This can be used by applications
that wish to use the stream for non-HTTP content afterwards. This will
lead to a simplification in the API we need to expose for WebTransport,
and will make it easier to send HTTP Datagrams associated with this
stream.
This commit is contained in:
Marten Seemann
2024-04-09 16:14:14 -04:00
committed by GitHub
parent e310b80cf3
commit eb310a6db8
12 changed files with 434 additions and 239 deletions

View File

@@ -293,21 +293,12 @@ var _ = Describe("Request", func() {
Expect(err).ToNot(HaveOccurred())
})
It("uses req.URL.Host", func() {
req := &http.Request{URL: url}
Expect(hostnameFromRequest(req)).To(Equal("quic.clemente.io:1337"))
})
It("uses req.URL.Host even if req.Host is available", func() {
req := &http.Request{
Host: "www.example.org",
URL: url,
}
Expect(hostnameFromRequest(req)).To(Equal("quic.clemente.io:1337"))
It("uses URL.Host", func() {
Expect(hostnameFromURL(url)).To(Equal("quic.clemente.io:1337"))
})
It("returns an empty hostname if nothing is set", func() {
Expect(hostnameFromRequest(&http.Request{})).To(BeEmpty())
Expect(hostnameFromURL(nil)).To(BeEmpty())
})
})
})