From 01ca8f3a64d0fd35b1da446fbb59e5c49ffb66ef Mon Sep 17 00:00:00 2001 From: Tom Dryer Date: Sun, 20 Dec 2020 15:13:33 -0800 Subject: [PATCH] Upgrade aiohttp and cookie-quoting workaround See #498. --- hangups/http_utils.py | 14 +++++--------- setup.py | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/hangups/http_utils.py b/hangups/http_utils.py index a08435b2..8585e74c 100644 --- a/hangups/http_utils.py +++ b/hangups/http_utils.py @@ -31,9 +31,12 @@ class Session: def __init__(self, cookies, proxy=None): self._proxy = proxy + # The server does not support quoting cookie values (see #498). + cookie_jar = aiohttp.CookieJar(quote_cookie=False) timeout = aiohttp.ClientTimeout(connect=CONNECT_TIMEOUT) - self._session = aiohttp.ClientSession(timeout=timeout) - self._cookies = cookies + self._session = aiohttp.ClientSession( + cookies=cookies, cookie_jar=cookie_jar, timeout=timeout + ) sapisid = cookies['SAPISID'] self._authorization_headers = _get_authorization_headers(sapisid) @@ -116,13 +119,6 @@ def fetch_raw(self, method, url, params=None, headers=None, data=None): headers = headers or {} headers.update(self._authorization_headers) - # Workaround for #498: Serialize the cookie header manually to prevent - # aiohttp from quoting cookie values, which the server does not - # support. - headers['Cookie'] = '; '.join( - '{}={}'.format(name, value) - for name, value in sorted(self._cookies.items()) - ) return self._session.request( method, url, params=params, headers=headers, data=data, proxy=self._proxy diff --git a/setup.py b/setup.py index c6155a9b..734c31e7 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ # especially for end-users (non-developers) who use pip to install hangups. install_requires = [ 'ConfigArgParse>=0.11.0,<2', - 'aiohttp>=3.3,<4', + 'aiohttp>=3.7,<4', 'async-timeout>=2,<4', 'appdirs>=1.4,<1.5', 'readlike>=0.1.2,<0.2',