mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Guard http response in context manager
This commit is contained in:
parent
6407190ae0
commit
8181ae5b17
@ -33,8 +33,7 @@ class HttpDownloader():
|
||||
|
||||
def download(self, url: str, target_path: Path, parameters: Dict[str, Any] = {}) -> None:
|
||||
"""Download a given url to a given path, optionally with some get parameters."""
|
||||
response = self._session.get(url, params=parameters)
|
||||
|
||||
with self._session.get(url, params=parameters) as response:
|
||||
if response.status_code == 200:
|
||||
tmp_file = self._tmp_dir.new_file()
|
||||
stream_to_path(response, tmp_file)
|
||||
|
Loading…
Reference in New Issue
Block a user