Resume Large Downloads Through Rotating Proxies
November 28, 2026
The problem: a 2 GB download that dies at 1.4 GB
Long transfers through a proxy rarely fail cleanly. The upstream connection drops, the proxy rotates the IP mid-transfer, or the origin throttles you, and your downloader is left holding a truncated file. Restarting from zero throws away the bandwidth and minutes you already spent, and on rate-limited or metered endpoints those repeated full restarts can push you straight into a block.
The fix is HTTP Range requests. They let a client ask for "only the bytes I'm missing," so an interrupted transfer resumes instead of restarting. Paired with a proxy that holds one IP for the duration, resumable downloads turn from fragile to dependable.
How Range requests work
A plain GET asks for the whole body and gets 200 OK. Add a Range header and a compliant server replies 206 Partial Content with just the requested slice, plus a Content-Range header describing exactly what it sent:
Range: bytes=1400000000-
HTTP/1.1 206 Partial Content
Content-Range: bytes 1400000000-2147483647/2147483648
Content-Length: 747483648
The client appends that slice to the bytes already on disk. If the server ignores Range, it answers 200 OK with the full body, and you detect that from the status code and simply start over.
Resume with cURL
curl supports this natively. -C - reads the size of the local file and sends the matching Range for you:
curl -C - -L \
-x http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT \
-o bigfile.zip \
https://example.com/bigfile.zip
Run the same command again after any failure and it picks up where it left off.
Resume in Python
requests gives the same control. Use stream=True so you never hold the whole file in memory, and send If-Range with a stored ETag so the server only honors the partial request when the file is unchanged:
import os
import requests
PROXY = "http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT"
URL = "https://example.com/bigfile.zip"
DEST = "bigfile.zip"
def download_resume(url, dest, proxy, etag=None):
proxies = {"http": proxy, "https": proxy}
have = os.path.getsize(dest) if os.path.exists(dest) else 0
headers = {}
if have:
headers["Range"] = f"bytes={have}-"
if etag:
headers["If-Range"] = etag
with requests.get(url, headers=headers, proxies=proxies,
stream=True, timeout=30) as r:
new_etag = r.headers.get("ETag")
if r.status_code == 206:
mode = "ab" # append the missing bytes
elif r.status_code == 200:
mode, have = "wb", 0 # server ignored Range; start fresh
else:
r.raise_for_status()
with open(dest, mode) as f:
for chunk in r.iter_content(65536):
f.write(chunk)
return os.path.getsize(dest), new_etag
Why proxy rotation breaks naive resume
Here is the part most people miss. When a proxy rotates the IP in the middle of a transfer, the resume request can arrive from a different address than the one that served the earlier bytes. Two things go wrong:
- Some origins bind a download to the client IP or a short-lived server-side session. A resume from a new IP returns
200 OK(a full restart) or403, so you never make forward progress. - A freshly rotated IP is unproven to the origin and may get throttled or challenged, turning one clean download into an endless loop of failures.
The answer is to decouple rotation from the transfer itself. Rotate between files, never within one.
Hold one IP for the whole transfer
Use a sticky rotation mode so the proxy keeps its IP until you rotate it or the IP fails. With RoProxy each proxy connects through a gateway host on an HTTP port and carries its own rotation mode; set it to sticky for the length of a large download:
http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT
Now every chunk, including each resume, comes from the same address, so 206 responses stay consistent. When the file finishes, rotate the IP and move on to the next one.
Wrap it with retries that resume
Because every attempt re-reads the file size, a simple retry loop resumes automatically rather than restarting:
import time
def download_with_resume(url, dest, proxy, attempts=5):
etag = None
for i in range(attempts):
try:
size, etag = download_resume(url, dest, proxy, etag)
return size
except requests.RequestException as e:
have = os.path.getsize(dest) if os.path.exists(dest) else 0
print(f"Attempt {i+1} failed: {e}. Resuming from {have} bytes.")
time.sleep(2 ** i) # exponential backoff
raise RuntimeError("Download failed after retries")
Confirm which IP served the bytes
When a resume keeps failing, verify the exit IP so you know whether rotation is the culprit. Ask an IP echo service through the very same proxy:
def exit_ip(proxy):
proxies = {"http": proxy, "https": proxy}
r = requests.get("https://api.ipify.org?format=json",
proxies=proxies, timeout=15)
return r.json()["ip"]
print(exit_ip(PROXY)) # should stay constant while rotation is sticky
If the address changes between attempts, your rotation mode is not sticky, or the IP failed and was replaced. Either way, you have your diagnosis.
Edge cases worth handling
- Server ignores
Range: you get200, and the code above resets and restarts cleanly. Log it so you know resume is unavailable for that host. - File changed upstream:
If-Rangewith the storedETagmakes the server return200instead of a mismatched206, which prevents a corrupt merge of old and new bytes. - Missing
Content-Length: you cannot compute a grand total, but append-based resume still works; track progress by bytes on disk instead. - Very large offsets: some proxies handle huge ranges poorly. If a single resume stalls, fetch smaller windows (say 64 MB at a time) and loop until the file is complete.
Putting it together
Resumable downloads are cheap to add and save real bandwidth. Two rules make them work through a proxy: use Range (with If-Range whenever the origin provides a validator) so you only fetch missing bytes, and keep one IP for the whole transfer so the origin keeps honoring partial content. If your downloads keep snapping back to zero, a sticky proxy from RoProxy holds a single IP across the transfer while you still rotate freely between files.