Skip to content

Commit

Permalink
Merge pull request #41 from sjaensch/dont-follow-redirects
Browse files Browse the repository at this point in the history
Support new request param follow_redirects, do not follow them by default
  • Loading branch information
sjaensch committed Mar 31, 2020
2 parents c9d9022 + caf2680 commit d3ed28c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bravado_asyncio/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def request(
else None
)

follow_redirects = request_params.get("follow_redirects", False)

# aiohttp always adds a Content-Type header, and this breaks some servers that don't
# expect it for non-POST/PUT requests: https://github.com/aio-libs/aiohttp/issues/457
skip_auto_headers = (
Expand All @@ -203,6 +205,7 @@ def request(
k: from_bytes(v) if isinstance(v, bytes) else str(v)
for k, v in request_params.get("headers", {}).items()
},
allow_redirects=follow_redirects,
skip_auto_headers=skip_auto_headers,
timeout=timeout,
**self._get_ssl_params()
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aiohttp<3.6
bottle
bravado-core>=4.11.0
bravado[integration-tests]>=10.4.1
bravado[integration-tests,fido]>=10.4.1
coverage
ephemeral_port_reserve
mock<4
Expand Down
3 changes: 3 additions & 0 deletions tests/http_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_request(asyncio_client, mock_client_session, request_params):
params=None,
data=mock.ANY,
headers={},
allow_redirects=False,
skip_auto_headers=["Content-Type"],
ssl=None,
timeout=None,
Expand Down Expand Up @@ -107,6 +108,7 @@ def test_simple_get(asyncio_client, mock_client_session, request_params):
params=request_params["params"],
data=mock.ANY,
headers={},
allow_redirects=False,
skip_auto_headers=["Content-Type"],
ssl=None,
timeout=None,
Expand Down Expand Up @@ -151,6 +153,7 @@ def test_formdata(
params=None,
data=mock.ANY,
headers={},
allow_redirects=False,
skip_auto_headers=["Content-Type"],
ssl=None,
timeout=None,
Expand Down

0 comments on commit d3ed28c

Please sign in to comment.