Skip to content
Myr

Merge pull request #3754 from nateprewitt/3066_auth_and_data

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

test auth doesn't generate incorrect http headers

authored by Cory Benfield · committed by GitHub · parents c398ab0, 1371672 · Browse files · 2 files+37 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

2 files+37 added−0 removed

  • tests:+36 added−0 removed
  • other:+1 added−0 removed

2 files+37 added−0 removed

modified:tests/test_requests.py+36 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 header.1699 """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 """1712 auth = ('user', 'pass')1713 url = httpbin('post')1714 file_obj = io.BytesIO(b'test data')1715 r = requests.Request('POST', url, auth=auth, data=file_obj)1716 prepared_request = r.prepare()1717 assert 'Transfer-Encoding' not in prepared_request.headers1718 assert 'Content-Length' in prepared_request.headers17191720 def test_chunked_upload_does_not_set_content_length_header(self, httpbin):1721 """Ensure that requests with a generator body stream using1722 Transfer-Encoding: chunked, not a Content-Length header.1723 """1724 data = (i for i in [b'a', b'b', b'c'])1725 url = httpbin('post')1726 r = requests.Request('POST', url, data=data)1727 prepared_request = r.prepare()1728 assert 'Transfer-Encoding' in prepared_request.headers1729 assert 'Content-Length' not in prepared_request.headers173017311732class TestCaseInsensitiveDict:17331734 @pytest.mark.parametrize(1735 'cid', (
549 unmodified lines
modified:AUTHORS.rst+1 added
171 unmodified lines
172- Brian Bamsch <bbamsch32@gmail.com> (`@bbamsch <https://github.com/bbamsch>`_)173- Om Prakash Kumar <omprakash070@gmail.com> (`@iamprakashom <https://github.com/iamprakashom>`_)174- Philipp Konrad <gardiac2002@gmail.com> (`@gardiac2002 <https://github.com/gardiac2002>`_)175- Hussain Tamboli <hussaintamboli18@gmail.com> (`@hussaintamboli <https://github.com/hussaintamboli>`_)176- Casey Davidson (`@davidsoncasey <https://github.com/davidsoncasey>`_)