[Python-modules-commits] [python-aiohttp] 01/05: Import python-aiohttp_0.22.4.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Thu Jul 28 22:05:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository python-aiohttp.
commit ac7dc8763eab3a6fb487bf163136605530a73bb9
Author: Piotr Ożarowski <piotr at debian.org>
Date: Thu Jul 28 23:29:50 2016 +0200
Import python-aiohttp_0.22.4.orig.tar.gz
---
CHANGES.txt | 24 +++++++++++--
CONTRIBUTORS.txt | 1 +
PKG-INFO | 26 ++++++++++++--
aiohttp.egg-info/PKG-INFO | 26 ++++++++++++--
aiohttp.egg-info/requires.txt | 2 +-
aiohttp/__init__.py | 9 ++---
aiohttp/client.py | 3 +-
aiohttp/helpers.py | 11 +++---
aiohttp/test_utils.py | 5 ++-
docs/client.rst | 22 ++++++++++--
setup.py | 2 +-
tests/test_helpers.py | 84 ++++++++++++++++++++++++++++++++-----------
tests/test_timeout.py | 10 ++++++
13 files changed, 180 insertions(+), 45 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 6eccd88..9b5862e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,14 +1,34 @@
CHANGES
=======
-0.22.1 (08-16-2016)
+0.22.3 (07-26-2016)
+-------------------
+
+- Do not filter cookies if unsafe flag provided #1005
+
+
+0.22.2 (07-23-2016)
+-------------------
+
+- Suppress CancelledError when Timeout raises TimeoutError #970
+
+- Don't expose `aiohttp.__version__`
+
+- Add unsafe parameter to CookieJar #968
+
+- Use unsafe cookie jar in test client tools
+
+- Expose aiohttp.CookieJar name
+
+
+0.22.1 (07-16-2016)
-------------------
- Large cookie expiration/max-age doesn't break an event loop from now
(fixes #967)
-0.22.0 (08-15-2016)
+0.22.0 (07-15-2016)
-------------------
- Fix bug in serving static directory #803
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 2021683..e1a9a00 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -70,6 +70,7 @@ Mathias Fröjdman
Matthieu Hauglustaine
Michael Ihnatenko
Mikhail Lukyanchenko
+Misha Behersky
Morgan Delahaye-Prat
Moss Collum
Nicolas Braem
diff --git a/PKG-INFO b/PKG-INFO
index 1a450f7..0d205d3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: aiohttp
-Version: 0.22.1
+Version: 0.22.4
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
Author: Andrew Svetlov
@@ -150,14 +150,34 @@ Description: http client/server for asyncio
CHANGES
=======
- 0.22.1 (08-16-2016)
+ 0.22.3 (07-26-2016)
+ -------------------
+
+ - Do not filter cookies if unsafe flag provided #1005
+
+
+ 0.22.2 (07-23-2016)
+ -------------------
+
+ - Suppress CancelledError when Timeout raises TimeoutError #970
+
+ - Don't expose `aiohttp.__version__`
+
+ - Add unsafe parameter to CookieJar #968
+
+ - Use unsafe cookie jar in test client tools
+
+ - Expose aiohttp.CookieJar name
+
+
+ 0.22.1 (07-16-2016)
-------------------
- Large cookie expiration/max-age doesn't break an event loop from now
(fixes #967)
- 0.22.0 (08-15-2016)
+ 0.22.0 (07-15-2016)
-------------------
- Fix bug in serving static directory #803
diff --git a/aiohttp.egg-info/PKG-INFO b/aiohttp.egg-info/PKG-INFO
index 1a450f7..0d205d3 100644
--- a/aiohttp.egg-info/PKG-INFO
+++ b/aiohttp.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: aiohttp
-Version: 0.22.1
+Version: 0.22.4
Summary: http client/server for asyncio
Home-page: https://github.com/KeepSafe/aiohttp/
Author: Andrew Svetlov
@@ -150,14 +150,34 @@ Description: http client/server for asyncio
CHANGES
=======
- 0.22.1 (08-16-2016)
+ 0.22.3 (07-26-2016)
+ -------------------
+
+ - Do not filter cookies if unsafe flag provided #1005
+
+
+ 0.22.2 (07-23-2016)
+ -------------------
+
+ - Suppress CancelledError when Timeout raises TimeoutError #970
+
+ - Don't expose `aiohttp.__version__`
+
+ - Add unsafe parameter to CookieJar #968
+
+ - Use unsafe cookie jar in test client tools
+
+ - Expose aiohttp.CookieJar name
+
+
+ 0.22.1 (07-16-2016)
-------------------
- Large cookie expiration/max-age doesn't break an event loop from now
(fixes #967)
- 0.22.0 (08-15-2016)
+ 0.22.0 (07-15-2016)
-------------------
- Fix bug in serving static directory #803
diff --git a/aiohttp.egg-info/requires.txt b/aiohttp.egg-info/requires.txt
index 588325f..62c059e 100644
--- a/aiohttp.egg-info/requires.txt
+++ b/aiohttp.egg-info/requires.txt
@@ -1,2 +1,2 @@
chardet
-multidict>=1.1.0
+multidict>=1.1.0,<2
diff --git a/aiohttp/__init__.py b/aiohttp/__init__.py
index faaad55..87662e2 100644
--- a/aiohttp/__init__.py
+++ b/aiohttp/__init__.py
@@ -1,9 +1,10 @@
-# This relies on each of the submodules having an __all__ variable.
-
-__version__ = '0.22.1'
+__version__ = '0.22.4'
+# Deprecated, keep it here for a while for backward compatibility.
import multidict # noqa
+# This relies on each of the submodules having an __all__ variable.
+
from multidict import * # noqa
from . import hdrs # noqa
from .protocol import * # noqa
@@ -30,4 +31,4 @@ __all__ = (client.__all__ + # noqa
multidict.__all__ + # noqa
multipart.__all__ + # noqa
websocket_client.__all__ + # noqa
- ('hdrs', '__version__', 'FileSender'))
+ ('hdrs', 'FileSender'))
diff --git a/aiohttp/client.py b/aiohttp/client.py
index bd4c6f8..3af9cda 100644
--- a/aiohttp/client.py
+++ b/aiohttp/client.py
@@ -152,8 +152,7 @@ class ClientSession:
redirects = 0
history = []
- if not isinstance(method, upstr):
- method = upstr(method)
+ method = upstr(method)
# Merge with default headers and transform to CIMultiDict
headers = self._prepare_headers(headers)
diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py
index 256a558..e518e70 100644
--- a/aiohttp/helpers.py
+++ b/aiohttp/helpers.py
@@ -27,7 +27,7 @@ except ImportError:
__all__ = ('BasicAuth', 'create_future', 'FormData', 'parse_mimetype',
- 'Timeout')
+ 'Timeout', 'CookieJar')
class BasicAuth(namedtuple('BasicAuth', ['login', 'password', 'encoding'])):
@@ -561,7 +561,7 @@ class Timeout:
if exc_type is asyncio.CancelledError and self._cancelled:
self._cancel_handler = None
self._task = None
- raise asyncio.TimeoutError
+ raise asyncio.TimeoutError from None
if self._timeout is not None:
self._cancel_handler.cancel()
self._cancel_handler = None
@@ -587,9 +587,10 @@ class CookieJar(AbstractCookieJar):
DATE_YEAR_RE = re.compile("(\d{2,4})")
- def __init__(self, *, loop=None):
+ def __init__(self, *, unsafe=False, loop=None):
super().__init__(loop=loop)
self._host_only_cookies = set()
+ self._unsafe = unsafe
def _expire_cookie(self, when, name, DAY=24*3600):
now = self._loop.time()
@@ -608,7 +609,7 @@ class CookieJar(AbstractCookieJar):
url_parsed = urlsplit(response_url or "")
hostname = url_parsed.hostname
- if is_ip_address(hostname):
+ if not self._unsafe and is_ip_address(hostname):
# Don't accept cookies from IPs
return
@@ -700,7 +701,7 @@ class CookieJar(AbstractCookieJar):
hostname = url_parsed.hostname or ""
- if is_ip_address(hostname):
+ if not self._unsafe and is_ip_address(hostname):
continue
if name in self._host_only_cookies:
diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py
index bb9e784..2c6aa17 100644
--- a/aiohttp/test_utils.py
+++ b/aiohttp/test_utils.py
@@ -349,7 +349,10 @@ class TestClient:
self._server = None
if not loop.is_running():
loop.run_until_complete(self.start_server())
- self._session = ClientSession(loop=self._loop)
+ self._session = ClientSession(
+ loop=self._loop,
+ cookie_jar=aiohttp.CookieJar(unsafe=True,
+ loop=self._loop))
self._root = '{}://{}:{}'.format(protocol, self._address, self.port)
self._closed = False
diff --git a/docs/client.rst b/docs/client.rst
index 7361d2f..f30503b 100644
--- a/docs/client.rst
+++ b/docs/client.rst
@@ -386,6 +386,24 @@ You also can set default headers for all session requests::
:class:`~aiohttp.ClientSession` supports keep-alive requests
and connection pooling out-of-the-box.
+.. _aiohttp-client-cookie-safety:
+
+Cookie safety
+-------------
+
+By default :class:`~aiohttp.ClientSession` uses strict version of
+:class:`~aiohttp.CookieJar`. :rfc:`2109` explicitly forbids cookie
+accepting from URLs with IP address instead of DNS name
+(e.g. `http://127.0.0.1:80/cookie`).
+
+It's good but sometimes for testing we need to enable support for such
+cookies. It should be done by passing `usafe=True` to
+:class:`~aiohttp.CookieJar` constructor::
+
+
+ jar = aiohttp.CookieJar(unsafe=True)
+ session = aiohttp.ClientSession(cookie_jar=jar)
+
Connectors
----------
@@ -421,8 +439,8 @@ In order to specify the nameservers to when resolving the hostnames,
aiodns is required.
from aiohttp.resolver import AsyncResolver
-
-
+
+
resolver = AsyncResolver(nameservers=["8.8.8.8", "8.8.4.4"])
conn = aiohttp.TCPConnector(resolver=resolver)
diff --git a/setup.py b/setup.py
index 8570c62..2c0680e 100644
--- a/setup.py
+++ b/setup.py
@@ -54,7 +54,7 @@ with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
raise RuntimeError('Unable to determine version.')
-install_requires = ['chardet', 'multidict>=1.1.0']
+install_requires = ['chardet', 'multidict>=1.1.0,<2']
if sys.version_info < (3, 4, 1):
raise RuntimeError("aiohttp requires Python 3.4.1+")
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index e623ad7..4368b42 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -273,10 +273,41 @@ def test_is_ip_address():
assert not helpers.is_ip_address("1200::AB00:1234::2552:7777:1313")
-class TestCookieJar(unittest.TestCase):
+class TestCookieJarBase(unittest.TestCase):
def setUp(self):
+ self.loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(None)
+
+ # N.B. those need to be overriden in child test cases
+ self.jar = helpers.CookieJar(loop=self.loop)
# Cookies to send from client to server as "Cookie" header
+ self.cookies_to_send = http.cookies.SimpleCookie()
+ # Cookies received from the server as "Set-Cookie" header
+ self.cookies_to_receive = http.cookies.SimpleCookie()
+
+ def tearDown(self):
+ self.loop.close()
+
+ def request_reply_with_same_url(self, url):
+ self.jar.update_cookies(self.cookies_to_send)
+ cookies_sent = self.jar.filter_cookies(url)
+
+ self.jar.cookies.clear()
+
+ self.jar.update_cookies(self.cookies_to_receive, url)
+ cookies_received = self.jar.cookies.copy()
+
+ self.jar.cookies.clear()
+
+ return cookies_sent, cookies_received
+
+
+class TestCookieJarSafe(TestCookieJarBase):
+
+ def setUp(self):
+ super().setUp()
+
self.cookies_to_send = http.cookies.SimpleCookie(
"shared-cookie=first; "
"domain-cookie=second; Domain=example.com; "
@@ -300,7 +331,6 @@ class TestCookieJar(unittest.TestCase):
" Expires=string;"
)
- # Cookies received from the server as "Set-Cookie" header
self.cookies_to_receive = http.cookies.SimpleCookie(
"unconstrained-cookie=first; Path=/; "
"domain-cookie=second; Domain=example.com; Path=/; "
@@ -313,27 +343,8 @@ class TestCookieJar(unittest.TestCase):
"wrong-path-cookie=nineth; Domain=pathtest.com; Path=somepath;"
)
- self.loop = asyncio.new_event_loop()
- asyncio.set_event_loop(None)
-
self.jar = helpers.CookieJar(loop=self.loop)
- def tearDown(self):
- self.loop.close()
-
- def request_reply_with_same_url(self, url):
- self.jar.update_cookies(self.cookies_to_send)
- cookies_sent = self.jar.filter_cookies(url)
-
- self.jar.cookies.clear()
-
- self.jar.update_cookies(self.cookies_to_receive, url)
- cookies_received = self.jar.cookies.copy()
-
- self.jar.cookies.clear()
-
- return cookies_sent, cookies_received
-
def timed_request(
self, url, update_time, send_time):
time_func = "time.monotonic"
@@ -676,3 +687,34 @@ class TestCookieJar(unittest.TestCase):
# Invalid time
self.assertEqual(parse_func("Tue, 1 Jan 1970 77:88:99 GMT"), None)
+
+
+class TestCookieJarUnsafe(TestCookieJarBase):
+
+ def setUp(self):
+ super().setUp()
+ self.cookies_to_send = http.cookies.SimpleCookie(
+ "shared-cookie=first; "
+ "ip-cookie=second; Domain=127.0.0.1;"
+ )
+
+ self.cookies_to_receive = http.cookies.SimpleCookie(
+ "shared-cookie=first; "
+ "ip-cookie=second; Domain=127.0.0.1;"
+ )
+
+ self.jar = helpers.CookieJar(loop=self.loop, unsafe=True)
+
+ def test_preserving_ip_domain_cookies(self):
+ cookies_sent, cookies_received = (
+ self.request_reply_with_same_url("http://127.0.0.1/"))
+
+ self.assertEqual(set(cookies_sent.keys()), {
+ "shared-cookie",
+ "ip-cookie",
+ })
+
+ self.assertEqual(set(cookies_received.keys()), {
+ "shared-cookie",
+ "ip-cookie",
+ })
diff --git a/tests/test_timeout.py b/tests/test_timeout.py
index 7d34a24..07e13a5 100644
--- a/tests/test_timeout.py
+++ b/tests/test_timeout.py
@@ -165,3 +165,13 @@ def test_cancel_outer_coro(loop):
yield from task
assert task.cancelled()
assert task.done()
+
+
+ at pytest.mark.run_loop
+def test_timeout_suppress_exception_chain(loop):
+
+ with pytest.raises(asyncio.TimeoutError) as ctx:
+ with Timeout(0.01, loop=loop) as t:
+ yield from asyncio.sleep(10, loop=loop)
+ assert t._loop is loop
+ assert ctx.value.__suppress_context__
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-aiohttp.git
More information about the Python-modules-commits
mailing list