mirror of
https://github.com/httpie/cli.git
synced 2025-01-05 21:29:12 +01:00
Fixed --max-redirects
This commit is contained in:
parent
356e043651
commit
e18b609ef7
@ -631,13 +631,18 @@ By default, HTTP redirects are not followed and only the first
|
||||
response is shown. To instruct HTTPie to follow the ``Location`` header of
|
||||
``30x`` responses and show the final response instead, use the ``--follow, -F`` option.
|
||||
|
||||
If you additionally wish to see the intermediary requests/responses as well,
|
||||
use the ``--show-redirects, -R`` option as well.
|
||||
If you additionally wish to see the intermediary requests/responses,
|
||||
then use the ``--show-redirects, -R`` option as well.
|
||||
|
||||
To change the default limit of maximum 30 redirects, use the
|
||||
``--max-redirects=<limit>`` option.
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ http --follow --show-redirects --max-redirects=5 httpbin.org/redirect/3
|
||||
|
||||
|
||||
=======
|
||||
Proxies
|
||||
=======
|
||||
|
@ -40,6 +40,7 @@ def get_response(args, config_dir):
|
||||
"""Send the request and return a `request.Response`."""
|
||||
|
||||
requests_session = get_requests_session()
|
||||
requests_session.max_redirects = args.max_redirects
|
||||
|
||||
if not args.session and not args.session_read_only:
|
||||
kwargs = get_requests_kwargs(args)
|
||||
|
@ -192,7 +192,6 @@ def main(args=sys.argv[1:], env=Environment(), error=None):
|
||||
error('Too many redirects (--max-redirects=%s).', args.max_redirects)
|
||||
except Exception as e:
|
||||
# TODO: Better distinction between expected and unexpected errors.
|
||||
# Network errors vs. bugs, etc.
|
||||
if traceback:
|
||||
raise
|
||||
msg = str(e)
|
||||
|
@ -17,6 +17,6 @@ class TestRedirects:
|
||||
assert HTTP_OK in r
|
||||
|
||||
def test_max_redirects(self, httpbin):
|
||||
r = http('--max-redirects=2', '--follow', httpbin.url + '/redirect/3',
|
||||
r = http('--max-redirects=1', '--follow', httpbin.url + '/redirect/3',
|
||||
error_exit_ok=True)
|
||||
assert r.exit_status == ExitStatus.ERROR_TOO_MANY_REDIRECTS
|
||||
|
Loading…
Reference in New Issue
Block a user