summaryrefslogtreecommitdiffstats
path: root/taskcluster/scripts/misc/fetch-content
diff options
context:
space:
mode:
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)