forked from quic-go/quic-go
committed by
Lucas Clemente
parent
bb24be8281
commit
76cf0a2345
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/http2/hpack"
|
||||
)
|
||||
@@ -30,6 +31,11 @@ func requestFromHeaders(headers []hpack.HeaderField) (*http.Request, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// concatenate cookie headers, see https://tools.ietf.org/html/rfc6265#section-5.4
|
||||
if len(httpHeaders["Cookie"]) > 0 {
|
||||
httpHeaders.Set("Cookie", strings.Join(httpHeaders["Cookie"], "; "))
|
||||
}
|
||||
|
||||
if len(path) == 0 || len(authority) == 0 || len(method) == 0 {
|
||||
return nil, errors.New(":path, :authority and :method must not be empty")
|
||||
}
|
||||
|
||||
@@ -31,6 +31,21 @@ var _ = Describe("Request", func() {
|
||||
Expect(req.RequestURI).To(Equal("/foo"))
|
||||
})
|
||||
|
||||
It("concatenates the cookie headers", func() {
|
||||
headers := []hpack.HeaderField{
|
||||
{Name: ":path", Value: "/foo"},
|
||||
{Name: ":authority", Value: "quic.clemente.io"},
|
||||
{Name: ":method", Value: "GET"},
|
||||
{Name: "cookie", Value: "cookie1=foobar1"},
|
||||
{Name: "cookie", Value: "cookie2=foobar2"},
|
||||
}
|
||||
req, err := requestFromHeaders(headers)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(req.Header).To(Equal(http.Header{
|
||||
"Cookie": []string{"cookie1=foobar1; cookie2=foobar2"},
|
||||
}))
|
||||
})
|
||||
|
||||
It("handles other headers", func() {
|
||||
headers := []hpack.HeaderField{
|
||||
{Name: ":path", Value: "/foo"},
|
||||
|
||||
Reference in New Issue
Block a user