http3: only use :protocol pseudo-header for Extended CONNECT (#4261)

* Fix protocol

The default value should be "HTTP/3.0".

* Reject normal request with :protocol header

The :protocol pseudo header is only defined for
Extended Connect requests (RFC 9220).

* save one branch check

* Fix review issue
This commit is contained in:
taoso
2024-01-26 11:07:35 +08:00
committed by GitHub
parent d3974e1674
commit 808f849ca2
2 changed files with 19 additions and 3 deletions

View File

@@ -212,6 +212,17 @@ var _ = Describe("Request", func() {
Expect(err).To(MatchError(":path, :authority and :method must not be empty"))
})
It("errors with invalid protocol", func() {
headers := []qpack.HeaderField{
{Name: ":path", Value: "/foo"},
{Name: ":authority", Value: "quic.clemente.io"},
{Name: ":method", Value: "GET"},
{Name: ":protocol", Value: "connect-udp"},
}
_, err := requestFromHeaders(headers)
Expect(err).To(MatchError(":protocol must be empty"))
})
Context("regular HTTP CONNECT", func() {
It("handles CONNECT method", func() {
headers := []qpack.HeaderField{
@@ -221,6 +232,7 @@ var _ = Describe("Request", func() {
req, err := requestFromHeaders(headers)
Expect(err).NotTo(HaveOccurred())
Expect(req.Method).To(Equal(http.MethodConnect))
Expect(req.Proto).To(Equal("HTTP/3.0"))
Expect(req.RequestURI).To(Equal("quic.clemente.io"))
})