Procházet zdrojové kódy

fixed weird client issue with requests.

tags/v1.8.0
Roxie Gibson před 6 roky
rodič
revize
629518a9d7
1 změnil soubory, kde provedl 6 přidání a 5 odebrání
  1. +6
    -5
      roxbot/http.py

+ 6
- 5
roxbot/http.py Zobrazit soubor

@@ -52,11 +52,12 @@ async def api_request(url, *, headers=None, **kwargs):
headers = {'User-agent': 'RoxBot Discord Bot'}
else:
headers = {'User-agent': 'RoxBot Discord Bot', **headers}
resp = await request(url, headers=headers, **kwargs)
try:
return json.loads(await resp.read())
except json.JSONDecodeError:
return None
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers, **kwargs) as resp:
try:
return await resp.json()
except json.JSONDecodeError:
return None


async def download_file(url, filename=None):

Načítá se…
Zrušit
Uložit