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

Commit 22a13bd

Browse files
committed
Header encoder for more complex tests.
1 parent 5f5d763 commit 22a13bd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/server.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
import ssl
1818
import sys
1919

20+
from hyper.http20.hpack import Encoder
21+
from hyper.http20.huffman import HuffmanEncoder
22+
from hyper.http20.huffman_constants import (
23+
RESPONSE_CODES, RESPONSE_CODES_LENGTH
24+
)
25+
2026
class SocketServerThread(threading.Thread):
2127
"""
2228
This method stolen wholesale from shazow/urllib3.
@@ -82,6 +88,14 @@ def _start_server(self, socket_handler):
8288
self.host = self.server_thread.host
8389
self.port = self.server_thread.port
8490

91+
def get_encoder(self):
92+
"""
93+
Returns a HPACK encoder set up for responses.
94+
"""
95+
e = Encoder()
96+
e.huffman_coder = HuffmanEncoder(RESPONSE_CODES, RESPONSE_CODES_LENGTH)
97+
return e
98+
8599
def tear_down(self):
86100
"""
87101
Tears down the testing thread.

0 commit comments

Comments
 (0)