diff --git a/http3/headers.go b/http3/headers.go index ec3fc0dd..79c070b5 100644 --- a/http3/headers.go +++ b/http3/headers.go @@ -60,6 +60,8 @@ func parseHeaders(headers []qpack.HeaderField, isRequest bool) (header, error) { case ":status": hdr.Status = h.Value isResponsePseudoHeader = true + default: + return header{}, fmt.Errorf("unknown pseudo header: %s", h.Name) } if isRequest && isResponsePseudoHeader { return header{}, fmt.Errorf("invalid request pseudo header: %s", h.Name) diff --git a/http3/headers_test.go b/http3/headers_test.go index 72233680..70fac997 100644 --- a/http3/headers_test.go +++ b/http3/headers_test.go @@ -44,6 +44,17 @@ var _ = Describe("Request", func() { Expect(err).To(MatchError("header field is not lower-case: Content-Length")) }) + It("rejects unknown pseudo headers", func() { + headers := []qpack.HeaderField{ + {Name: ":path", Value: "/foo"}, + {Name: ":authority", Value: "quic.clemente.io"}, + {Name: ":method", Value: "GET"}, + {Name: ":foo", Value: "bar"}, + } + _, err := requestFromHeaders(headers) + Expect(err).To(MatchError("unknown pseudo header: :foo")) + }) + It("rejects invalid field names", func() { headers := []qpack.HeaderField{ {Name: ":path", Value: "/foo"},