fail early on invalid http
parent
f2fb108026
commit
755b70475a
|
|
@ -29,6 +29,8 @@ def today(today=dt.today()):
|
|||
|
||||
def download(url, target, **kwargs):
|
||||
response = requests.get(url, stream=True, **kwargs)
|
||||
if not response.ok:
|
||||
raise ValueError("HTTP not OK", response.status_code, response.text)
|
||||
response.raw.decode_content = True
|
||||
with open(target, "wb") as out:
|
||||
shutil.copyfileobj(response.raw, out)
|
||||
|
|
|
|||
Loading…
Reference in New Issue