cli.resmgr: allow missing content-length
@@ -128,8 +128,9 @@ def download(any_url, no_dynamic, resource_type, path_in_archive, allow_uninstal
continue
if resdict['url'].startswith('https://') or resdict['url'].startswith('http://'):
log.info("Downloading %s resource '%s' (%s)", registered, resdict['name'], resdict['url'])
- with requests.get(resdict['url'], stream=True) as r:
- resdict['size'] = int(r.headers.get('content-length'))
+ if 'size' not in resdict:
+ with requests.head(resdict['url']) as r:
+ resdict['size'] = int(r.headers.get('content-length', 0))
else:
log.info("Copying %s resource '%s' (%s)", registered, resdict['name'], resdict['url'])
urlpath = Path(resdict['url'])
