[2.x] Don't save error as a file (#813)

* fix: don't save error as file

Raise an aiohttp.ClientResponseError if the response status is 400 or higher

#799

* fix tests

Co-authored-by: darksidecat <58224121+darksidecat@users.noreply.github.com>
This commit is contained in:
Oleg A 2022-02-08 03:29:53 +03:00 committed by GitHub
parent 3731a62885
commit b39672f9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 31 deletions

View file

@ -277,7 +277,13 @@ class BaseBot:
dest = destination if isinstance(destination, io.IOBase) else open(destination, 'wb')
session = await self.get_session()
async with session.get(url, timeout=timeout, proxy=self.proxy, proxy_auth=self.proxy_auth) as response:
async with session.get(
url,
timeout=timeout,
proxy=self.proxy,
proxy_auth=self.proxy_auth,
raise_for_status=True,
) as response:
while True:
chunk = await response.content.read(chunk_size)
if not chunk: