refactor(downloader): put one transport adapter per HTTP session kind under download()

This commit is contained in:
imSp4rky
2026-12-04 14:21:18 -07:00
parent 9e8647dd38
commit 6d04d19239
6 changed files with 303 additions and 109 deletions
@@ -145,6 +145,18 @@ def test_stalled_body_times_out_and_retries(tmp_path, server, make_session, monk
assert len(server.hits) == 2
@pytest.mark.parametrize("make_session", SESSIONS)
def test_transport_body_reads_headers_in_any_case(server, make_session):
body = dl.transport_for(make_session()).get(f"{server.url}/plain", headers={"Range": "bytes=0-9"})
try:
assert body.status_code == 206
assert body.header("content-range") == body.header("CONTENT-RANGE") == f"bytes 0-9/{len(BODY)}"
assert body.content_length == 10
assert b"".join(body.chunks(4, None)) == BODY[:10]
finally:
body.close()
def test_complete_file_is_reported_without_a_request(tmp_path, server):
save_path = tmp_path / "0.mp4"
save_path.write_bytes(b"x" * 10)