write http headers in lower case

fixes #317
This commit is contained in:
Lucas Clemente
2016-09-04 11:38:10 +02:00
parent aa16873794
commit e856c08645
2 changed files with 3 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"net/http"
"strconv"
"strings"
"sync"
"github.com/lucas-clemente/quic-go/protocol"
@@ -48,7 +49,7 @@ func (w *responseWriter) WriteHeader(status int) {
enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)})
for k, v := range w.header {
enc.WriteField(hpack.HeaderField{Name: k, Value: v[0]})
enc.WriteField(hpack.HeaderField{Name: strings.ToLower(k), Value: v[0]})
}
utils.Infof("Responding with %d", status)

View File

@@ -44,9 +44,7 @@ var _ = Describe("Response Writer", func() {
w.Header().Add("content-length", "42")
w.WriteHeader(http.StatusTeapot)
Expect(headerStream.Bytes()).To(Equal([]byte{
0x0, 0x0, 0x14, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 0x48, 0x3, 0x34, 0x31, 0x38,
0x40, 0x8a, 0xbc, 0x7a, 0x92, 0x5a, 0x92, 0xb6, 0x72, 0xd5, 0x32, 0x67,
0x2, 0x34, 0x32,
0x0, 0x0, 0x9, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 0x48, 0x3, 0x34, 0x31, 0x38, 0x5c, 0x2, 0x34, 0x32,
}))
})