Skip to content

Commit 944524e

Browse files
committed
merged upstream/master
2 parents d7f41bd + 4bf83a8 commit 944524e

23 files changed

+173
-58
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.swp
12
*.bak
23
*.egg
34
*.egg-info

CHANGES.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
CHANGES
22
=======
33

4-
0.22.2 (XX-XX-XXXX)
4+
0.23.0 (XX-XX-XXXX)
5+
-------------------
6+
7+
- Change default size for client session's connection pool from
8+
unlimited to 20 #977
9+
10+
- Add IE support for cookie deletion. #994
11+
12+
- Remove deprecated `WebSocketResponse.wait_closed` method (BACKWARD
13+
INCOMPATIBLE)
14+
15+
- Remove deprecated `force` parameter for `ClientResponse.close`
16+
method (BACKWARD INCOMPATIBLE)
17+
18+
- Avoid using of mutable CIMultiDict kw param in make_mocked_request
19+
#997
20+
21+
0.22.2 (07-23-2016)
522
-------------------
623

724
- Suppress CancelledError when Timeout raises TimeoutError #970
825

926
- Don't expose `aiohttp.__version__`
1027

28+
- Add unsafe parameter to CookieJar #968
29+
30+
- Use unsafe cookie jar in test client tools
31+
32+
- Expose aiohttp.CookieJar name
33+
34+
1135
0.22.1 (07-16-2016)
1236
-------------------
1337

CONTRIBUTING.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ After that please install libraries required for development::
6060
We also recommend to install *ipdb* but it's on your own::
6161

6262
$ pip install ipdb
63+
64+
.. note::
65+
If you plan to use ``ipdb`` within the test suite, use::
66+
67+
$ make vtest
68+
69+
to run the tests.
6370

6471
Congratulations, you are ready to run the test suite
6572

CONTRIBUTORS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Contributors
33

44
A. Jesse Jiryu Davis
55
Alejandro Gómez
6+
Aleksey Kutepov
67
Alex Khomchenko
78
Alex Lisovoy
89
Alex Key
@@ -65,6 +66,7 @@ Lubomir Gelo
6566
Ludovic Gasc
6667
Lukasz Marcin Dobrzanski
6768
Marco Paolini
69+
Mariano Anaya
6870
Martin Richard
6971
Mathias Fröjdman
7072
Matthieu Hauglustaine
@@ -111,3 +113,4 @@ Yury Selivanov
111113
Yusuke Tsutsumi
112114
Марк Коренберг
113115
Семён Марьясин
116+
Pau Freixes

aiohttp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This relies on each of the submodules having an __all__ variable.
22

3-
__version__ = '0.22.2b0'
3+
__version__ = '0.22.2'
44

55
import multidict # noqa
66

aiohttp/client_reqrep.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,7 @@ def start(self, connection, read_until_eof=False):
661661
'Can not load response cookies: %s', exc)
662662
return self
663663

664-
def close(self, force=True):
665-
if not force:
666-
warnings.warn("force parameter should be True", DeprecationWarning,
667-
stacklevel=2)
664+
def close(self):
668665
if self._closed:
669666
return
670667

aiohttp/connector.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ class BaseConnector(object):
109109
:param keepalive_timeout: (optional) Keep-alive timeout.
110110
:param bool force_close: Set to True to force close and do reconnect
111111
after each request (and between redirects).
112+
:param limit: The limit of simultaneous connections to the same endpoint.
112113
:param loop: Optional event loop.
113114
"""
114115

115116
_closed = True # prevent AttributeError in __del__ if ctor was failed
116117
_source_traceback = None
117118

118119
def __init__(self, *, conn_timeout=None, keepalive_timeout=_default,
119-
force_close=False, limit=None,
120+
force_close=False, limit=20,
120121
loop=None):
121122

122123
if force_close:
@@ -170,6 +171,12 @@ def __del__(self, _warnings=warnings):
170171
context['source_traceback'] = self._source_traceback
171172
self._loop.call_exception_handler(context)
172173

174+
def __enter__(self):
175+
return self
176+
177+
def __exit__(self, *exc):
178+
self.close()
179+
173180
@property
174181
def force_close(self):
175182
"""Ultimately close connection on releasing if True."""
@@ -182,7 +189,8 @@ def limit(self):
182189
Endpoints are the same if they are have equal
183190
(host, port, is_ssl) triple.
184191
185-
If limit is None the connector has no limit (default).
192+
If limit is None the connector has no limit.
193+
The default limit size is 20.
186194
"""
187195
return self._limit
188196

aiohttp/helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
__all__ = ('BasicAuth', 'create_future', 'FormData', 'parse_mimetype',
30-
'Timeout')
30+
'Timeout', 'CookieJar')
3131

3232

3333
class BasicAuth(namedtuple('BasicAuth', ['login', 'password', 'encoding'])):
@@ -587,9 +587,10 @@ class CookieJar(AbstractCookieJar):
587587

588588
DATE_YEAR_RE = re.compile("(\d{2,4})")
589589

590-
def __init__(self, *, loop=None):
590+
def __init__(self, *, unsafe=False, loop=None):
591591
super().__init__(loop=loop)
592592
self._host_only_cookies = set()
593+
self._unsafe = unsafe
593594

594595
def _expire_cookie(self, when, name, DAY=24*3600):
595596
now = self._loop.time()
@@ -608,7 +609,7 @@ def update_cookies(self, cookies, response_url=None):
608609
url_parsed = urlsplit(response_url or "")
609610
hostname = url_parsed.hostname
610611

611-
if is_ip_address(hostname):
612+
if not self._unsafe and is_ip_address(hostname):
612613
# Don't accept cookies from IPs
613614
return
614615

aiohttp/test_utils.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ def __init__(self, app, protocol="http"):
349349
self._server = None
350350
if not loop.is_running():
351351
loop.run_until_complete(self.start_server())
352-
self._session = ClientSession(loop=self._loop)
352+
self._session = ClientSession(
353+
loop=self._loop,
354+
cookie_jar=aiohttp.CookieJar(unsafe=True,
355+
loop=self._loop))
353356
self._root = '{}://{}:{}'.format(protocol, self._address, self.port)
354357
self._closed = False
355358

@@ -558,7 +561,7 @@ def get_extra_info(key):
558561
_not_set = object()
559562

560563

561-
def make_mocked_request(method, path, headers=CIMultiDict(), *,
564+
def make_mocked_request(method, path, headers=None, *,
562565
version=HttpVersion(1, 1), closing=False,
563566
app=None,
564567
reader=_not_set,
@@ -613,10 +616,17 @@ def make_mocked_request(method, path, headers=CIMultiDict(), *,
613616

614617
if version < HttpVersion(1, 1):
615618
closing = True
616-
message = RawRequestMessage(method, path, version, headers,
617-
[(k.encode('utf-8'), v.encode('utf-8'))
618-
for k, v in headers.items()],
619-
closing, False)
619+
620+
if headers:
621+
hdrs = headers
622+
raw_hdrs = [
623+
(k.encode('utf-8'), v.encode('utf-8')) for k, v in headers.items()]
624+
else:
625+
hdrs = CIMultiDict()
626+
raw_hdrs = []
627+
628+
message = RawRequestMessage(method, path, version, hdrs,
629+
raw_hdrs, closing, False)
620630
if app is None:
621631
app = _create_app_mock()
622632

aiohttp/web_reqrep.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,12 @@ def set_cookie(self, name, value, *, expires=None,
511511

512512
self._cookies[name] = value
513513
c = self._cookies[name]
514+
514515
if expires is not None:
515516
c['expires'] = expires
517+
elif c.get('expires') == 'Thu, 01 Jan 1970 00:00:00 GMT':
518+
del c['expires']
519+
516520
if domain is not None:
517521
c['domain'] = domain
518522

@@ -537,7 +541,9 @@ def del_cookie(self, name, *, domain=None, path='/'):
537541
"""
538542
# TODO: do we need domain/path here?
539543
self._cookies.pop(name, None)
540-
self.set_cookie(name, '', max_age=0, domain=domain, path=path)
544+
self.set_cookie(name, '', max_age=0,
545+
expires="Thu, 01 Jan 1970 00:00:00 GMT",
546+
domain=domain, path=path)
541547

542548
@property
543549
def content_length(self):

0 commit comments

Comments
 (0)