Skip to content
Myr

Add tests to verify that correct 'Content-Length' or 'Transfer-Encoding' headers are being set in PreparedRequest.

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

authored by Casey Davidson · committed by Nate Prewitt · parent c398ab0 · Browse files · 1 file+24 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+24 added−0 removed

  • tests:+24 added−0 removed

1 file+24 added−0 removed

modified:tests/test_requests.py+24 added
1691 unmodified lines
1692 assert not resp.raw.closed1693 resp.close()1694 assert resp.raw.closed16951696 def test_empty_stream_with_auth_does_not_set_content_length_header(self, httpbin):1697 """Ensure that a byte stream with size 0 will not set both a Content-Length1698 and Transfer-Encoding header1699 """1700 auth = ('user', 'pass')1701 url = httpbin('post')1702 file_obj = io.BytesIO(b'')1703 r = requests.Request('POST', url, auth=auth, data=file_obj)1704 prepared_request = r.prepare()1705 assert 'Transfer-Encoding' in prepared_request.headers1706 assert 'Content-Length' not in prepared_request.headers17071708 def test_stream_with_auth_does_not_set_transfer_encoding_header(self, httpbin):1709 """Ensure that a byte stream with size > 0 will not set both a Content-Length1710 and Transfer-Encoding header"""1711 auth = ('user', 'pass')1712 url = httpbin('post')1713 file_obj = io.BytesIO(b'test data')1714 r = requests.Request('POST', url, auth=auth, data=file_obj)1715 prepared_request = r.prepare()1716 assert 'Transfer-Encoding' not in prepared_request.headers1717 assert 'Content-Length' in prepared_request.headers171817191720class TestCaseInsensitiveDict:17211722 @pytest.mark.parametrize(1723 'cid', (
549 unmodified lines