Skip to content
Myr

Add a test which verifies that ChunkedEncodingError is emitted if an invalid Transfer-Encoding: chunked response is returned. (#5906)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ben Li-Sauerwine · committed by GitHub · parent b0e025a · Browse files · 1 file+22 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−0 removed

  • tests:+22 added−0 removed

1 file+22 added−0 removed

modified:tests/test_lowlevel.py+22 added
22 unmodified lines
23 assert r.status_code == 20024 assert r.request.headers['Transfer-Encoding'] == 'chunked'252627def test_chunked_encoding_error():28 """get a ChunkedEncodingError if the server returns a bad response"""2930 def incomplete_chunked_response_handler(sock):31 request_content = consume_socket_content(sock, timeout=0.5)3233 # The server never ends the request and doesn't provide any valid chunks34 sock.send(b"HTTP/1.1 200 OK\r\n" +35 b"Transfer-Encoding: chunked\r\n")3637 return request_content3839 close_server = threading.Event()40 server = Server(incomplete_chunked_response_handler)4142 with server as (host, port):43 url = 'http://{}:{}/'.format(host, port)44 with pytest.raises(requests.exceptions.ChunkedEncodingError):45 r = requests.get(url)46 close_server.set() # release server block474849def test_digestauth_401_count_reset_on_redirect():50 """Ensure we correctly reset num_401_calls after a successful digest auth,51 followed by a 302 redirect to another digest auth prompt.52
279 unmodified lines