summaryrefslogtreecommitdiffstats
path: root/taskcluster/scripts/misc/fetch-content
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /taskcluster/scripts/misc/fetch-content
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'taskcluster/scripts/misc/fetch-content')
-rwxr-xr-xtaskcluster/scripts/misc/fetch-content19
1 files changed, 19 insertions, 0 deletions
diff --git a/taskcluster/scripts/misc/fetch-content b/taskcluster/scripts/misc/fetch-content
index 9e6a1f4ef0..6e7b625dce 100755
--- a/taskcluster/scripts/misc/fetch-content
+++ b/taskcluster/scripts/misc/fetch-content
@@ -188,6 +188,25 @@ def stream_download(url, sha256=None, size=None):
) if certifi else urllib.request.urlopen(url, timeout=60) as fh:
if not url.endswith(".gz") and fh.info().get("Content-Encoding") == "gzip":
fh = gzip.GzipFile(fileobj=fh)
+ else:
+ # when using gzip we can't compare size or length (inflated) against content-length (compressed)
+ content_length = fh.getheader("content-length")
+ if content_length:
+ try:
+ content_length = int(content_length)
+ except ValueError:
+ raise IntegrityError(
+ "content-length header for %s is not an integer; got %s"
+ % (url, content_length)
+ )
+ if size:
+ if size != content_length:
+ raise IntegrityError(
+ "size mismatch on %s: wanted %d; content-length is %d"
+ % (url, size, content_length)
+ )
+ else:
+ size = content_length
while True:
chunk = fh.read(65536)