diff --git a/http3/request.go b/http3/request.go index 962ae1e56..7036cc371 100644 --- a/http3/request.go +++ b/http3/request.go @@ -41,7 +41,7 @@ func requestFromHeaders(headers []qpack.HeaderField) (*http.Request, error) { return nil, errors.New(":path, :authority and :method must not be empty") } - u, err := url.Parse(path) + u, err := url.ParseRequestURI(path) if err != nil { return nil, err } diff --git a/http3/request_test.go b/http3/request_test.go index 1ca2cf570..251e324e4 100644 --- a/http3/request_test.go +++ b/http3/request_test.go @@ -21,6 +21,7 @@ var _ = Describe("Request", func() { Expect(err).NotTo(HaveOccurred()) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Path).To(Equal("/foo")) + Expect(req.URL.Host).To(BeEmpty()) Expect(req.Proto).To(Equal("HTTP/3")) Expect(req.ProtoMajor).To(Equal(3)) Expect(req.ProtoMinor).To(BeZero()) @@ -32,6 +33,22 @@ var _ = Describe("Request", func() { Expect(req.TLS).ToNot(BeNil()) }) + It("parses path with leading double slashes", func() { + headers := []qpack.HeaderField{ + {Name: ":path", Value: "//foo"}, + {Name: ":authority", Value: "quic.clemente.io"}, + {Name: ":method", Value: "GET"}, + } + req, err := requestFromHeaders(headers) + Expect(err).NotTo(HaveOccurred()) + Expect(req.Header).To(BeEmpty()) + Expect(req.Body).To(BeNil()) + Expect(req.URL.Path).To(Equal("//foo")) + Expect(req.URL.Host).To(BeEmpty()) + Expect(req.Host).To(Equal("quic.clemente.io")) + Expect(req.RequestURI).To(Equal("//foo")) + }) + It("concatenates the cookie headers", func() { headers := []qpack.HeaderField{ {Name: ":path", Value: "/foo"},