Skip to content

Commit

Permalink
add comment and test
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Sep 4, 2024
1 parent 09a37c5 commit b6dae4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func (d *Decoder) parseLiteralHeaderField() error {
if buf[0]&0x10 == 0 {
return errNoDynamicTable
}
// We don't need to check the value of the N-bit here.
// It's only relevant when re-encoding header fields,
// and determines whether the header field can be added to the dynamic table.
// Since we don't support the dynamic table, we can ignore it.
index, buf, err := readVarInt(4, buf)
if err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,21 @@ func TestDecoderInvalidIndexedHeaderFields(t *testing.T) {
}

func TestDecoderLiteralHeaderFieldWithNameReference(t *testing.T) {
t.Run("without the N-bit", func(t *testing.T) {
testDecoderLiteralHeaderFieldWithNameReference(t, false)
})
t.Run("with the N-bit", func(t *testing.T) {
testDecoderLiteralHeaderFieldWithNameReference(t, true)
})
}

func testDecoderLiteralHeaderFieldWithNameReference(t *testing.T, n bool) {
decoder := newRecordingDecoder()
data := appendVarInt(nil, 4, 49)
data[0] ^= 0x40 | 0x10
if n {
data[0] |= 0x20
}
data = appendVarInt(data, 7, 6)
data = append(data, []byte("foobar")...)
doPartialWrites(t, decoder, insertPrefix(data))
Expand Down

0 comments on commit b6dae4c

Please sign in to comment.