test_fragment_update_on_redirect() — requests Function Reference
Architecture documentation for the test_fragment_update_on_redirect() function in test_lowlevel.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 255f00ae_0b7e_4891_d674_c5b83377ce70["test_fragment_update_on_redirect()"] 48561d17_8bd1_bf20_5710_ec3053a534d2["test_lowlevel.py"] 255f00ae_0b7e_4891_d674_c5b83377ce70 -->|defined in| 48561d17_8bd1_bf20_5710_ec3053a534d2 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de["consume_socket_content()"] 255f00ae_0b7e_4891_d674_c5b83377ce70 -->|calls| 7ab3c4d7_8531_6cbe_e871_9880cb1ee6de style 255f00ae_0b7e_4891_d674_c5b83377ce70 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_lowlevel.py lines 364–404
def test_fragment_update_on_redirect():
"""Verify we only append previous fragment if one doesn't exist on new
location. If a new fragment is encountered in a Location header, it should
be added to all subsequent requests.
"""
def response_handler(sock):
consume_socket_content(sock, timeout=0.5)
sock.send(
b'HTTP/1.1 302 FOUND\r\n'
b'Content-Length: 0\r\n'
b'Location: /get#relevant-section\r\n\r\n'
)
consume_socket_content(sock, timeout=0.5)
sock.send(
b'HTTP/1.1 302 FOUND\r\n'
b'Content-Length: 0\r\n'
b'Location: /final-url/\r\n\r\n'
)
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(response_handler, wait_to_close_event=close_server)
with server as (host, port):
url = f'http://{host}:{port}/path/to/thing/#view=edit&token=hunter2'
r = requests.get(url)
assert r.status_code == 200
assert len(r.history) == 2
assert r.history[0].request.url == url
# Verify we haven't overwritten the location with our previous fragment.
assert r.history[1].request.url == f'http://{host}:{port}/get#relevant-section'
# Verify previous fragment is used and not the original.
assert r.url == f'http://{host}:{port}/final-url/#relevant-section'
close_server.set()
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_fragment_update_on_redirect() do?
test_fragment_update_on_redirect() is a function in the requests codebase, defined in tests/test_lowlevel.py.
Where is test_fragment_update_on_redirect() defined?
test_fragment_update_on_redirect() is defined in tests/test_lowlevel.py at line 364.
What does test_fragment_update_on_redirect() call?
test_fragment_update_on_redirect() 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