Home / Function/ test_conflicting_content_lengths() — requests Function Reference

test_conflicting_content_lengths() — requests Function Reference

Architecture documentation for the test_conflicting_content_lengths() function in test_lowlevel.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  2093ddb9_6b84_c4ae_5b98_b40875536ba6["test_conflicting_content_lengths()"]
  48561d17_8bd1_bf20_5710_ec3053a534d2["test_lowlevel.py"]
  2093ddb9_6b84_c4ae_5b98_b40875536ba6 -->|defined in| 48561d17_8bd1_bf20_5710_ec3053a534d2
  7ab3c4d7_8531_6cbe_e871_9880cb1ee6de["consume_socket_content()"]
  2093ddb9_6b84_c4ae_5b98_b40875536ba6 -->|calls| 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de
  style 2093ddb9_6b84_c4ae_5b98_b40875536ba6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_lowlevel.py lines 99–124

def test_conflicting_content_lengths():
    """Ensure we correctly throw an InvalidHeader error if multiple
    conflicting Content-Length headers are returned.
    """

    def multiple_content_length_response_handler(sock):
        request_content = consume_socket_content(sock, timeout=0.5)
        response = (
            b"HTTP/1.1 200 OK\r\n"
            b"Content-Type: text/plain\r\n"
            b"Content-Length: 16\r\n"
            b"Content-Length: 32\r\n\r\n"
            b"-- Bad Actor -- Original Content\r\n"
        )
        sock.send(response)

        return request_content

    close_server = threading.Event()
    server = Server(multiple_content_length_response_handler)

    with server as (host, port):
        url = f"http://{host}:{port}/"
        with pytest.raises(requests.exceptions.InvalidHeader):
            requests.get(url)
        close_server.set()

Domain

Subdomains

Frequently Asked Questions

What does test_conflicting_content_lengths() do?
test_conflicting_content_lengths() is a function in the requests codebase, defined in tests/test_lowlevel.py.
Where is test_conflicting_content_lengths() defined?
test_conflicting_content_lengths() is defined in tests/test_lowlevel.py at line 99.
What does test_conflicting_content_lengths() call?
test_conflicting_content_lengths() calls 1 function(s): consume_socket_content.

Analyze Your Own Codebase

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

Try Supermodel Free