Browse Source

fixed weird client issue with requests.

tags/v1.8.0
Roxie Gibson 6 years ago
parent
commit
629518a9d7
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      roxbot/http.py

+ 6
- 5
roxbot/http.py View File

headers = {'User-agent': 'RoxBot Discord Bot'} headers = {'User-agent': 'RoxBot Discord Bot'}
else: else:
headers = {'User-agent': 'RoxBot Discord Bot', **headers} 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): async def download_file(url, filename=None):

Loading…
Cancel
Save