Skip to content

Commit

Permalink
Test that retry preserve chunked=True
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Oct 29, 2019
1 parent 6fa8289 commit f7edf72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions dummyserver/testcase.py
Expand Up @@ -15,8 +15,13 @@


def consume_socket(sock, chunks=65536):
while not sock.recv(chunks).endswith(b"\r\n\r\n"):
pass
consumed = bytearray()
while True:
b = sock.recv(chunks)
consumed += b
if b.endswith(b"\r\n\r\n"):
break
return consumed


class SocketDummyServerTestCase(object):
Expand Down
6 changes: 3 additions & 3 deletions test/with_dummyserver/test_socketlevel.py
Expand Up @@ -1760,8 +1760,8 @@ def test_pool_size_retry_drain_fail(self):
def socket_handler(listener):
for _ in range(2):
sock = listener.accept()[0]
while not sock.recv(65536).endswith(b"\r\n\r\n"):
pass
request = consume_socket(sock)
assert b"Transfer-Encoding: chunked" in request

# send a response with an invalid content length -- this causes
# a ProtocolError to raise when trying to drain the connection
Expand All @@ -1778,5 +1778,5 @@ def socket_handler(listener):
with HTTPConnectionPool(
self.host, self.port, maxsize=10, retries=retries, block=True
) as pool:
pool.urlopen("GET", "/not_found", preload_content=False)
pool.urlopen("GET", "/not_found", chunked=True, preload_content=False)
assert pool.num_connections == 1

0 comments on commit f7edf72

Please sign in to comment.