From d18b48aaf48952d099a38907288d593c811adc6d Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Mon, 20 Apr 2020 19:45:25 +0200 Subject: [PATCH] Stream in http downloader --- PFERD/downloaders.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PFERD/downloaders.py b/PFERD/downloaders.py index 45b29c6..7c30447 100644 --- a/PFERD/downloaders.py +++ b/PFERD/downloaders.py @@ -39,9 +39,10 @@ class HttpDownloader(): ) return session - def download(self, url: str, target_path: Path, parameters: Dict[str, Any] = {}) -> None: + def download(self, url: str, target_path: Path, parameters: Optional[Dict[str, Any]] = None) -> None: """Download a given url to a given path, optionally with some get parameters.""" - with self._session.get(url, params=parameters) as response: + parameters = parameters if parameters else {} + with self._session.get(url, params=parameters, stream=True) as response: if response.status_code == 200: tmp_file = self._tmp_dir.new_file() stream_to_path(response, tmp_file)