Skip to content

Commit

Permalink
modifying original request only if connected to proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
popravich committed Jun 18, 2014
1 parent ebb2467 commit 7d7cee5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,20 @@ def __init__(self, proxy, *args, **kwargs):

@asyncio.coroutine
def _create_connection(self, req, **kwargs):
proxy_req = ClientRequest('GET', self.proxy,
headers={'Host': req.host})
try:
transport, proto = yield from super()._create_connection(proxy_req)
except OSError:
raise ProxyConnectionError()
req.path = '{scheme}:https://{host}{path}'.format(scheme=req.scheme,
host=req.host,
path=req.path)
proxy_req = ClientRequest('GET', self.proxy,
headers={'Host': req.host})

if proxy_req.auth:
auth = proxy_req.headers['AUTHORIZATION']
del proxy_req.headers['AUTHORIZATION']
req.headers['PROXY-AUTHORIZATION'] = auth
proxy_req.headers['PROXY-AUTHORIZATION'] = auth
try:
transport, proto = yield from super()._create_connection(proxy_req)
except OSError:
raise ProxyConnectionError()

if req.ssl:
# For HTTPS requests over HTTP proxy
Expand Down

0 comments on commit 7d7cee5

Please sign in to comment.