From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- taskcluster/scripts/misc/fetch-content | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'taskcluster/scripts/misc/fetch-content') 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) -- cgit v1.2.3