From 5c2eabf758f5671d2faeb334c19f0f3fc8df9643 Mon Sep 17 00:00:00 2001 From: ulinja <56582668+ulinja@users.noreply.github.com> Date: Thu, 21 Apr 2022 01:14:18 +0200 Subject: [PATCH] fix: resolve undefined reference error The error occurred when downloading a file and the 'content-length' field is missing from the HTTP response header. --- udib/webdownload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/udib/webdownload.py b/udib/webdownload.py index 930a25e..5fdb59f 100644 --- a/udib/webdownload.py +++ b/udib/webdownload.py @@ -48,8 +48,8 @@ def download_file(path_to_output_file, url_to_file, show_progress = False): file_response = requests.get(url_to_file, stream=True) total_length = file_response.headers.get('content-length') - if total_length is None: # no content length header - output_file.write(response.content) + if total_length is None: # no content length header + output_file.write(file_response.content) else: if (show_progress): total_length = int(total_length)