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
+1 -2
View File
@@ -147,12 +147,11 @@ class _FakeRnetSession:
def test_rnet_encoded_body_discards_a_partial_instead_of_range_resuming(tmp_path, monkeypatch):
dl = importlib.import_module("unshackle.core.downloaders.requests")
monkeypatch.setattr(dl, "is_rnet_session", lambda s: isinstance(s, _FakeRnetSession))
monkeypatch.setattr(dl, "RETRY_WAIT", 0)
session = _FakeRnetSession(PLAIN)
save_path = tmp_path / "sub.vtt"
save_path.with_name("sub.vtt.!dev").write_bytes(PLAIN[:5000])
list(download(url="http://127.0.0.1:1/sub.vtt", save_path=save_path, session=session))
list(download(url="http://127.0.0.1:1/sub.vtt", save_path=save_path, session=dl.RnetTransport(session)))
# the encoded 206 must be dropped, not appended; the clean restart fetches the whole body
assert session.range_requests == 1
assert save_path.read_bytes() == PLAIN