Skip to content

Commit 2f21da4

Browse files
committed
spdy: fix header block byte accounting
writeHeaderValueBlock accounts for serialized 32-bit length/count fields as 2 bytes, but they occupy 4 bytes on the wire. Adjust the returned byte count to match the encoded header block layout. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 5976b66 commit 2f21da4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

spdy/write.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err error) {
170170
if err = binary.Write(w, binary.BigEndian, uint32(numHeaders)); err != nil {
171171
return
172172
}
173-
n += 2
173+
n += 4
174174
for name, values := range h {
175175
nameLen := len(name)
176176
if nameLen > math.MaxUint32 {
@@ -179,7 +179,7 @@ func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err error) {
179179
if err = binary.Write(w, binary.BigEndian, uint32(nameLen)); err != nil {
180180
return
181181
}
182-
n += 2
182+
n += 4
183183
name = strings.ToLower(name)
184184
if _, err = io.WriteString(w, name); err != nil {
185185
return
@@ -193,7 +193,7 @@ func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err error) {
193193
if err = binary.Write(w, binary.BigEndian, uint32(vLen)); err != nil {
194194
return
195195
}
196-
n += 2
196+
n += 4
197197
if _, err = io.WriteString(w, v); err != nil {
198198
return
199199
}

0 commit comments

Comments
 (0)