test_redirect_rfc1808_to_non_ascii_location() — requests Function Reference
Architecture documentation for the test_redirect_rfc1808_to_non_ascii_location() function in test_lowlevel.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 884c31ab_a7d6_3dbd_2982_beb0b7fd1003["test_redirect_rfc1808_to_non_ascii_location()"] 48561d17_8bd1_bf20_5710_ec3053a534d2["test_lowlevel.py"] 884c31ab_a7d6_3dbd_2982_beb0b7fd1003 -->|defined in| 48561d17_8bd1_bf20_5710_ec3053a534d2 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de["consume_socket_content()"] 884c31ab_a7d6_3dbd_2982_beb0b7fd1003 -->|calls| 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de style 884c31ab_a7d6_3dbd_2982_beb0b7fd1003 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_lowlevel.py lines 308–339
def test_redirect_rfc1808_to_non_ascii_location():
path = 'š'
expected_path = b'%C5%A1'
redirect_request = [] # stores the second request to the server
def redirect_resp_handler(sock):
consume_socket_content(sock, timeout=0.5)
location = f'//{host}:{port}/{path}'
sock.send(
(
b'HTTP/1.1 301 Moved Permanently\r\n'
b'Content-Length: 0\r\n'
b'Location: %s\r\n'
b'\r\n'
) % location.encode('utf8')
)
redirect_request.append(consume_socket_content(sock, timeout=0.5))
sock.send(b'HTTP/1.1 200 OK\r\n\r\n')
close_server = threading.Event()
server = Server(redirect_resp_handler, wait_to_close_event=close_server)
with server as (host, port):
url = f'http://{host}:{port}'
r = requests.get(url=url, allow_redirects=True)
assert r.status_code == 200
assert len(r.history) == 1
assert r.history[0].status_code == 301
assert redirect_request[0].startswith(b'GET /' + expected_path + b' HTTP/1.1')
assert r.url == '{}/{}'.format(url, expected_path.decode('ascii'))
close_server.set()
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_redirect_rfc1808_to_non_ascii_location() do?
test_redirect_rfc1808_to_non_ascii_location() is a function in the requests codebase, defined in tests/test_lowlevel.py.
Where is test_redirect_rfc1808_to_non_ascii_location() defined?
test_redirect_rfc1808_to_non_ascii_location() is defined in tests/test_lowlevel.py at line 308.
What does test_redirect_rfc1808_to_non_ascii_location() call?
test_redirect_rfc1808_to_non_ascii_location() 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