Home / Function/ test_transfer_enc_removal_on_redirect() — requests Function Reference

test_transfer_enc_removal_on_redirect() — requests Function Reference

Architecture documentation for the test_transfer_enc_removal_on_redirect() function in test_requests.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  8533efc6_f1a0_d19c_6107_621bc34239a7["test_transfer_enc_removal_on_redirect()"]
  22b80b19_26d4_cd0e_c476_3edf87b3df14["TestRequests"]
  8533efc6_f1a0_d19c_6107_621bc34239a7 -->|defined in| 22b80b19_26d4_cd0e_c476_3edf87b3df14
  style 8533efc6_f1a0_d19c_6107_621bc34239a7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_requests.py lines 329–350

    def test_transfer_enc_removal_on_redirect(self, httpbin):
        purged_headers = ("Transfer-Encoding", "Content-Type")
        ses = requests.Session()
        req = requests.Request("POST", httpbin("post"), data=(b"x" for x in range(1)))
        prep = ses.prepare_request(req)
        assert "Transfer-Encoding" in prep.headers

        # Create Response to avoid https://github.com/kevin1024/pytest-httpbin/issues/33
        resp = requests.Response()
        resp.raw = io.BytesIO(b"the content")
        resp.request = prep
        setattr(resp.raw, "release_conn", lambda *args: args)

        # Mimic a redirect response
        resp.status_code = 302
        resp.headers["location"] = httpbin("get")

        # Run request through resolve_redirect
        next_resp = next(ses.resolve_redirects(resp, prep))
        assert next_resp.request.body is None
        for header in purged_headers:
            assert header not in next_resp.request.headers

Domain

Subdomains

Frequently Asked Questions

What does test_transfer_enc_removal_on_redirect() do?
test_transfer_enc_removal_on_redirect() is a function in the requests codebase, defined in tests/test_requests.py.
Where is test_transfer_enc_removal_on_redirect() defined?
test_transfer_enc_removal_on_redirect() is defined in tests/test_requests.py at line 329.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free