Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 7e281c9

Browse files
committed
Upgrade to hpack v1.0.1
1 parent 64936d1 commit 7e281c9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

hyper/packages/hpack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
66
HTTP/2 header encoding for Python.
77
"""
8-
__version__ = '1.0.0'
8+
__version__ = '1.0.1'

hyper/packages/hpack/hpack.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,13 @@ def add(self, to_add, huffman=False):
278278
# Indexed representation.
279279
encoded = self._encode_indexed(index)
280280
else:
281-
# Indexed literal. Since we have a partial match, don't add to
282-
# the header table, it won't help us.
281+
# Indexed literal. We are going to add header to the
282+
# header table unconditionally. It is a future todo to
283+
# filter out headers which are known to be ineffective for
284+
# indexing since they just take space in the table and
285+
# pushed out other valuable headers.
283286
encoded = self._encode_indexed_literal(index, value, huffman)
287+
self._add_to_header_table(to_add)
284288

285289
return encoded
286290

@@ -362,9 +366,11 @@ def _encode_literal(self, name, value, indexing, huffman=False):
362366

363367
def _encode_indexed_literal(self, index, value, huffman=False):
364368
"""
365-
Encodes a header with an indexed name and a literal value.
369+
Encodes a header with an indexed name and a literal value and performs
370+
incremental indexing.
366371
"""
367-
name = encode_integer(index, 4)
372+
prefix = encode_integer(index, 6)
373+
prefix[0] |= 0x40
368374

369375
if huffman:
370376
value = self.huffman_coder.encode(value)
@@ -374,7 +380,7 @@ def _encode_indexed_literal(self, index, value, huffman=False):
374380
if huffman:
375381
value_len[0] |= 0x80
376382

377-
return b''.join([bytes(name), bytes(value_len), value])
383+
return b''.join([bytes(prefix), bytes(value_len), value])
378384

379385
def _encode_table_size_change(self):
380386
"""

0 commit comments

Comments
 (0)