Skip to content

Commit

Permalink
Allow to disable redirect url re-quoting #1474
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 28, 2017
1 parent 90d89e8 commit ed9bf2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Changes

- Added `history` to `ClientResponseError`. #1741

- Allow to disable redirect url re-quoting #1474

- Dropped "%O" in access logger #1673


Expand Down
5 changes: 4 additions & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class ClientSession:
_source_traceback = None
_connector = None

requote_redirect_url = True

def __init__(self, *, connector=None, loop=None, cookies=None,
headers=None, skip_auto_headers=None,
auth=None, json_serialize=json.dumps,
Expand Down Expand Up @@ -272,7 +274,8 @@ def _request(self, method, url, *,
"a redirect [{0.status}] status "
"but response lacks a Location "
"or URI HTTP header".format(resp))
r_url = URL(r_url)
r_url = URL(
r_url, encoded=not self.requote_redirect_url)

scheme = r_url.scheme
if scheme not in ('http', 'https', ''):
Expand Down
8 changes: 8 additions & 0 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ The client session supports the context manager protocol for self closing.

.. versionadded:: 1.0

.. attribute:: requote_redirect_url

aiohttp re quote's redirect urls by default, but some servers
require exact url from location header. to disable `re-quote` system
set `requote_redirect_url` to `False`.

.. note:: this parameter affects all subsequent requests.

.. attribute:: loop

A loop instance used for session creation.
Expand Down

0 comments on commit ed9bf2b

Please sign in to comment.