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

Commit f0e9483

Browse files
committed
Static and header tables have been flipped.
1 parent aeb13f7 commit f0e9483

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

hyper/http20/hpack.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,21 @@ def matching_header(self, name, value):
299299
Upsettingly, the header table is one-indexed, not zero-indexed.
300300
"""
301301
partial_match = None
302-
header_table_size = len(self.header_table)
302+
static_table_len = len(Encoder.static_table)
303303

304-
for (i, (n, v)) in enumerate(self.header_table):
304+
for (i, (n, v)) in enumerate(Encoder.static_table):
305305
if n == name:
306306
if v == value:
307-
return (i + 1, self.header_table[i])
307+
return (i + 1, Encoder.static_table[i])
308308
elif partial_match is None:
309309
partial_match = (i + 1, None)
310310

311-
for (i, (n, v)) in enumerate(Encoder.static_table):
311+
for (i, (n, v)) in enumerate(self.header_table):
312312
if n == name:
313313
if v == value:
314-
return (i + header_table_size + 1, Encoder.static_table[i])
314+
return (i + static_table_len + 1, self.header_table[i])
315315
elif partial_match is None:
316-
partial_match = (i + header_table_size + 1, None)
316+
partial_match = (i + static_table_len + 1, None)
317317

318318
return partial_match
319319

@@ -578,15 +578,11 @@ def _decode_indexed(self, data):
578578
index, consumed = decode_integer(data, 7)
579579
index -= 1 # Because this idiot table is 1-indexed. Ugh.
580580

581-
if index > len(self.header_table):
582-
index -= len(self.header_table)
583-
header = Decoder.static_table[index]
584-
585-
# If this came out of the static table, we need to add it to the
586-
# header table.
587-
self._add_to_header_table(header)
588-
else:
581+
if index >= len(Decoder.static_table):
582+
index -= len(Decoder.static_table)
589583
header = self.header_table[index]
584+
else:
585+
header = Decoder.static_table[index]
590586

591587
log.debug("Decoded %s, consumed %d", header, consumed)
592588
return header, consumed
@@ -619,11 +615,11 @@ def _decode_literal(self, data, should_index):
619615
index, consumed = decode_integer(data, name_len)
620616
index -= 1
621617

622-
if index >= len(self.header_table):
623-
index -= len(self.header_table)
624-
name = Decoder.static_table[index][0]
625-
else:
618+
if index >= len(Decoder.static_table):
619+
index -= len(Decoder.static_table)
626620
name = self.header_table[index][0]
621+
else:
622+
name = Decoder.static_table[index][0]
627623

628624
total_consumed = consumed
629625
length = 0

0 commit comments

Comments
 (0)