diff options
| author | PapyrusThePlant <[email protected]> | 2017-08-11 16:44:15 +0200 |
|---|---|---|
| committer | PapyrusThePlant <[email protected]> | 2017-08-11 16:44:15 +0200 |
| commit | 0d21e83b7f008e10ba6507af659d1207eb94263f (patch) | |
| tree | ba36c09975e982abbebaa1e2aaad47f32b02798d /discord/http.py | |
| parent | [commands] Ensure no mentions escape clean_content (diff) | |
| download | discord.py-0d21e83b7f008e10ba6507af659d1207eb94263f.tar.xz discord.py-0d21e83b7f008e10ba6507af659d1207eb94263f.zip | |
Fix the proxy support for aiohttp>=1.4.
Diffstat (limited to 'discord/http.py')
| -rw-r--r-- | discord/http.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/discord/http.py b/discord/http.py index bddf56e3..b935cf99 100644 --- a/discord/http.py +++ b/discord/http.py @@ -88,7 +88,7 @@ class HTTPClient: SUCCESS_LOG = '{method} {url} has received {text}' REQUEST_LOG = '{method} {url} with {json} has returned {status}' - def __init__(self, connector=None, *, loop=None): + def __init__(self, connector=None, *, proxy=None, proxy_auth=None, loop=None): self.loop = asyncio.get_event_loop() if loop is None else loop self.connector = connector self._session = aiohttp.ClientSession(connector=connector, loop=self.loop) @@ -97,6 +97,8 @@ class HTTPClient: self._global_over.set() self.token = None self.bot_token = False + self.proxy = proxy + self.proxy_auth = proxy_auth user_agent = 'DiscordBot (https://github.com/Rapptz/discord.py {0}) Python/{1[0]}.{1[1]} aiohttp/{2}' self.user_agent = user_agent.format(__version__, sys.version_info, aiohttp.__version__) @@ -135,6 +137,12 @@ class HTTPClient: kwargs['headers'] = headers + # Proxy support + if self.proxy is not None: + kwargs['proxy'] = self.proxy + if self.proxy_auth is not None: + kwargs['proxy_auth'] = self.proxy_auth + if not self._global_over.is_set(): # wait until the global lock is complete yield from self._global_over.wait() |