Skip to content

Commit

Permalink
Merge branch 'master' into content-disposition
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Nov 6, 2017
2 parents 29636f0 + 0b34a8f commit ff12184
Show file tree
Hide file tree
Showing 40 changed files with 669 additions and 284 deletions.
8 changes: 4 additions & 4 deletions .appveyor.yml
@@ -1,14 +1,14 @@
environment:
PYPI_PASSWD:
secure: syNUF3e8AEPY327rWBkKag==
secure: u+K6dKi7+CXXVFEUG4V7zUyV3w7Ntg0Ork/RGVV0eSQ=
matrix:
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python36-x64"

install:
- "tools/build.cmd %PYTHON%\\python.exe -m pip install wheel"
- "tools/build.cmd %PYTHON%\\python.exe -m pip install -U wheel setuptools"
- "tools/build.cmd %PYTHON%\\python.exe -m pip install -r requirements/ci.txt"

build: false
Expand All @@ -17,15 +17,15 @@ test_script:
- "tools/build.cmd %PYTHON%\\python.exe setup.py test"

after_test:
- "tools/build.cmd %PYTHON%\\python.exe setup.py bdist_wheel"
- "tools/build.cmd %PYTHON%\\python.exe setup.py sdist bdist_wheel"

artifacts:
- path: dist\*

deploy_script:
- ps: >-
if($env:appveyor_repo_tag -eq 'True') {
Invoke-Expression "$env:PYTHON\\python.exe -m twine upload dist/* --username fafhrd --password $env:PYPI_PASSWD"
Invoke-Expression "$env:PYTHON\\python.exe -m twine upload dist/* --username andrew.svetlov --password $env:PYPI_PASSWD"
}
#notifications:
Expand Down
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Expand Up @@ -19,5 +19,10 @@
## Your environment

<!-- Describe the environment you have that lead to your issue.
This includes project version, OS, proxy server and other bits that
are related to your case. -->
This includes aiohttp version, OS, proxy server and other bits that
are related to your case.
IMPORTANT: aiohttp is both server framework and client library.
For getting rid of confusing please put 'server', 'client' or 'both'
word here.
-->
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -5,8 +5,9 @@
- If you propose a new feature or improvement, select "master"
as a target branch;
- If this is a bug fix or documentation amendment, select
the latest release branch (which looks like "0.xx") -->
- If this is a bug fix or documentation amendment, select the latest
[release branch](https://github.com/aio-libs/aiohttp/branches) (which
looks like "X.Y" e.g. "2.3") -->

## What do these changes do?

Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -196,6 +196,7 @@ jobs:
- docker
script:
- ./tools/run_docker.sh "aiohttp"
- pip install -r requirements/ci.txt # to compile *.c files by Cython
deploy:
provider: pypi
# `skip_cleanup: true` is required to preserve binary wheels, built
Expand Down
21 changes: 18 additions & 3 deletions CHANGES.rst
@@ -1,6 +1,6 @@
=======
Changes
=======
=========
Changelog
=========

..
You should *NOT* be adding new change log entries to this file, this
Expand All @@ -14,6 +14,21 @@ Changes

.. towncrier release notes start
2.3.2 (2017-11-01)
==================

- Fix passing client max size on cloning request obj. (#2385)
- Fix ClientConnectorSSLError and ClientProxyConnectionError for proxy
connector. (#2408)
- Drop generated `_http_parser` shared object from tarball distribution. (#2414)
- Fix connector convert OSError to ClientConnectorError. (#2423)
- Fix connection attempts for multiple dns hosts. (#2424)
- Fix ValueError for AF_INET6 sockets if a preexisting INET6 socket to the
`aiohttp.web.run_app` function. (#2431)
- `_SessionRequestContextManager` closes the session properly now. (#2441)
- Rename `from_env` to `trust_env` in client reference. (#2451)


2.3.1 (2017-10-18)
==================

Expand Down
1 change: 0 additions & 1 deletion CHANGES/2385.bugfix

This file was deleted.

1 change: 1 addition & 0 deletions CHANGES/2408.bugfix
@@ -0,0 +1 @@
Fix ClientConnectorSSLError and ClientProxyConnectionError for proxy connector
1 change: 0 additions & 1 deletion CHANGES/2414.bugfix

This file was deleted.

1 change: 1 addition & 0 deletions CHANGES/2423.bugfix
@@ -0,0 +1 @@
Fix connector convert OSError to ClientConnectorError
1 change: 1 addition & 0 deletions CHANGES/2424.bugfix
@@ -0,0 +1 @@
Fix connection attempts for multiple dns hosts
1 change: 0 additions & 1 deletion CHANGES/2431.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion CHANGES/2441.bugfix

This file was deleted.

1 change: 1 addition & 0 deletions CHANGES/2451.doc
@@ -0,0 +1 @@
Rename `from_env` to `trust_env` in client reference.
2 changes: 1 addition & 1 deletion aiohttp/__init__.py
@@ -1,4 +1,4 @@
__version__ = '2.3.1'
__version__ = '3.0.0a0'

# This relies on each of the submodules having an __all__ variable.

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/abc.py
Expand Up @@ -84,7 +84,7 @@ def request(self):
return self._request

@abstractmethod
async def __await__(self):
def __await__(self):
"""Execute the view handler."""


Expand Down
113 changes: 70 additions & 43 deletions aiohttp/connector.py
Expand Up @@ -773,49 +773,73 @@ def _get_fingerprint_and_hashfunc(self, req):
else:
return (None, None)

async def _create_direct_connection(self, req):
async def _wrap_create_connection(self, *args,
req, client_error=ClientConnectorError,
**kwargs):
try:
return await self._loop.create_connection(*args, **kwargs)
except certificate_errors as exc:
raise ClientConnectorCertificateError(
req.connection_key, exc) from exc
except ssl_errors as exc:
raise ClientConnectorSSLError(req.connection_key, exc) from exc
except OSError as exc:
raise client_error(req.connection_key, exc) from exc

async def _create_direct_connection(self, req,
*, client_error=ClientConnectorError):
sslcontext = self._get_ssl_context(req)
fingerprint, hashfunc = self._get_fingerprint_and_hashfunc(req)

hosts = await self._resolve_host(req.url.raw_host, req.port)
try:
hosts = await self._resolve_host(req.url.raw_host, req.port)
except OSError as exc:
# in case of proxy it is not ClientProxyConnectionError
# it is problem of resolving proxy ip itself
raise ClientConnectorError(req.connection_key, exc) from exc

last_exc = None

for hinfo in hosts:
host = hinfo['host']
port = hinfo['port']

try:
host = hinfo['host']
port = hinfo['port']
transp, proto = await self._loop.create_connection(
transp, proto = await self._wrap_create_connection(
self._factory, host, port,
ssl=sslcontext, family=hinfo['family'],
proto=hinfo['proto'], flags=hinfo['flags'],
server_hostname=hinfo['hostname'] if sslcontext else None,
local_addr=self._local_addr)
has_cert = transp.get_extra_info('sslcontext')
if has_cert and fingerprint:
sock = transp.get_extra_info('socket')
if not hasattr(sock, 'getpeercert'):
# Workaround for asyncio 3.5.0
# Starting from 3.5.1 version
# there is 'ssl_object' extra info in transport
sock = transp._ssl_protocol._sslpipe.ssl_object
# gives DER-encoded cert as a sequence of bytes (or None)
cert = sock.getpeercert(binary_form=True)
assert cert
got = hashfunc(cert).digest()
expected = fingerprint
if got != expected:
transp.close()
if not self._cleanup_closed_disabled:
self._cleanup_closed_transports.append(transp)
raise ServerFingerprintMismatch(
expected, got, host, port)
return transp, proto
except certificate_errors as exc:
raise ClientConnectorCertificateError(
req.connection_key, exc) from exc
except ssl_errors as exc:
raise ClientConnectorSSLError(req.connection_key, exc) from exc
except OSError as exc:
raise ClientConnectorError(req.connection_key, exc) from exc
local_addr=self._local_addr,
req=req, client_error=client_error)
except ClientConnectorError as exc:
last_exc = exc
continue

has_cert = transp.get_extra_info('sslcontext')
if has_cert and fingerprint:
sock = transp.get_extra_info('socket')
if not hasattr(sock, 'getpeercert'):
# Workaround for asyncio 3.5.0
# Starting from 3.5.1 version
# there is 'ssl_object' extra info in transport
sock = transp._ssl_protocol._sslpipe.ssl_object
# gives DER-encoded cert as a sequence of bytes (or None)
cert = sock.getpeercert(binary_form=True)
assert cert
got = hashfunc(cert).digest()
expected = fingerprint
if got != expected:
transp.close()
if not self._cleanup_closed_disabled:
self._cleanup_closed_transports.append(transp)
last_exc = ServerFingerprintMismatch(
expected, got, host, port)
continue

return transp, proto
else:
raise last_exc

async def _create_proxy_connection(self, req):
headers = {}
Expand All @@ -831,12 +855,10 @@ async def _create_proxy_connection(self, req):
verify_ssl=req.verify_ssl,
fingerprint=req.fingerprint,
ssl_context=req.ssl_context)
try:
# create connection to proxy server
transport, proto = await self._create_direct_connection(
proxy_req)
except OSError as exc:
raise ClientProxyConnectionError(proxy_req, exc) from exc

# create connection to proxy server
transport, proto = await self._create_direct_connection(
proxy_req, client_error=ClientProxyConnectionError)

auth = proxy_req.headers.pop(hdrs.AUTHORIZATION, None)
if auth is not None:
Expand Down Expand Up @@ -887,9 +909,10 @@ async def _create_proxy_connection(self, req):
finally:
transport.close()

transport, proto = await self._loop.create_connection(
transport, proto = await self._wrap_create_connection(
self._factory, ssl=sslcontext, sock=rawsock,
server_hostname=req.host)
server_hostname=req.host,
req=req)
finally:
proxy_resp.close()

Expand Down Expand Up @@ -921,6 +944,10 @@ def path(self):
return self._path

async def _create_connection(self, req):
_, proto = await self._loop.create_unix_connection(
self._factory, self._path)
try:
_, proto = await self._loop.create_unix_connection(
self._factory, self._path)
except OSError as exc:
raise ClientConnectorError(req.connection_key, exc) from exc

return proto
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Expand Up @@ -43,7 +43,7 @@

class _BaseCoroMixin(Coroutine):

__slots__ = ('_coro')
__slots__ = ('_coro',)

def __init__(self, coro):
self._coro = coro
Expand Down

0 comments on commit ff12184

Please sign in to comment.