diff --git a/unshackle/core/downloaders/curl_impersonate.py b/unshackle/core/downloaders/curl_impersonate.py index f9f0d95..52dab7a 100644 --- a/unshackle/core/downloaders/curl_impersonate.py +++ b/unshackle/core/downloaders/curl_impersonate.py @@ -76,6 +76,11 @@ def download(url: str, save_path: Path, session: Session, **kwargs: Any) -> Gene try: content_length = int(stream.headers.get("Content-Length", "0")) + + # Skip Content-Length validation for compressed responses since + # curl_impersonate automatically decompresses but Content-Length shows compressed size + if stream.headers.get("Content-Encoding", "").lower() in ["gzip", "deflate", "br"]: + content_length = 0 except ValueError: content_length = 0 diff --git a/unshackle/core/downloaders/requests.py b/unshackle/core/downloaders/requests.py index ef57d77..49c1759 100644 --- a/unshackle/core/downloaders/requests.py +++ b/unshackle/core/downloaders/requests.py @@ -90,6 +90,11 @@ def download( if not segmented: try: content_length = int(stream.headers.get("Content-Length", "0")) + + # Skip Content-Length validation for compressed responses since + # requests automatically decompresses but Content-Length shows compressed size + if stream.headers.get("Content-Encoding", "").lower() in ["gzip", "deflate", "br"]: + content_length = 0 except ValueError: content_length = 0