forked from quic-go/quic-go
add support for the Extended CONNECT method (#3357)
Extended CONNECT is used by WebTransport.
This commit is contained in:
@@ -81,17 +81,6 @@ var _ = Describe("Request", func() {
|
||||
}))
|
||||
})
|
||||
|
||||
It("handles CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
req, err := requestFromHeaders(headers)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(req.Method).To(Equal(http.MethodConnect))
|
||||
Expect(req.RequestURI).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("errors with missing path", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
@@ -119,22 +108,63 @@ var _ = Describe("Request", func() {
|
||||
Expect(err).To(MatchError(":path, :authority and :method must not be empty"))
|
||||
})
|
||||
|
||||
It("errors with missing authority in CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
_, err := requestFromHeaders(headers)
|
||||
Expect(err).To(MatchError(":path must be empty and :authority must not be empty"))
|
||||
Context("regular HTTP CONNECT", func() {
|
||||
It("handles CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
req, err := requestFromHeaders(headers)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(req.Method).To(Equal(http.MethodConnect))
|
||||
Expect(req.RequestURI).To(Equal("quic.clemente.io"))
|
||||
})
|
||||
|
||||
It("errors with missing authority in CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
_, err := requestFromHeaders(headers)
|
||||
Expect(err).To(MatchError(":path must be empty and :authority must not be empty"))
|
||||
})
|
||||
|
||||
It("errors with extra path in CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":path", Value: "/foo"},
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
_, err := requestFromHeaders(headers)
|
||||
Expect(err).To(MatchError(":path must be empty and :authority must not be empty"))
|
||||
})
|
||||
})
|
||||
|
||||
It("errors with extra path in CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":path", Value: "/foo"},
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
}
|
||||
_, err := requestFromHeaders(headers)
|
||||
Expect(err).To(MatchError(":path must be empty and :authority must not be empty"))
|
||||
Context("Extended CONNECT", func() {
|
||||
It("handles Extended CONNECT method", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":protocol", Value: "webtransport"},
|
||||
{Name: ":scheme", Value: "ftp"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":path", Value: "/foo"},
|
||||
}
|
||||
req, err := requestFromHeaders(headers)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(req.Method).To(Equal(http.MethodConnect))
|
||||
Expect(req.Proto).To(Equal("webtransport"))
|
||||
Expect(req.URL.String()).To(Equal("ftp://quic.clemente.io/foo"))
|
||||
})
|
||||
|
||||
It("errors with missing scheme", func() {
|
||||
headers := []qpack.HeaderField{
|
||||
{Name: ":protocol", Value: "webtransport"},
|
||||
{Name: ":method", Value: http.MethodConnect},
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":path", Value: "/foo"},
|
||||
}
|
||||
_, err := requestFromHeaders(headers)
|
||||
Expect(err).To(MatchError("extended CONNECT: :scheme, :path and :authority must not be empty"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("extracting the hostname from a request", func() {
|
||||
|
||||
Reference in New Issue
Block a user