httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.37k stars 3.67k forks source link

Add a --max-redirects option #188

Closed tylercrompton closed 8 years ago

tylercrompton commented 10 years ago

Right now, we rely on the default max redirects set forth by Requests, which is currently 30. I think we should have an option to tinker around with this. It should be extremely easy to implement. It'd be a matter of adding about ten lines to httpie/cli.py, adding one to three and changing one or two in httpie/client.py.

Current Behavior:

$ http --follow http://httpbin.org/redirect/31

http: error: TooManyRedirects: Exceeded 30 redirects.

Proposed Behavior:

$ http --follow --max-redirects=31 http://httpbin.org/redirect/31
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 261
Content-Type: application/json
Date: Fri, 20 Dec 2013 03:54:45 GMT
Server: gunicorn/0.17.4

{
    "args": {}, 
    "headers": {
        "Accept": "*/*", 
        "Accept-Encoding": "gzip, deflate, compress", 
        "Connection": "close", 
        "Host": "httpbin.org", 
        "User-Agent": "HTTPie/0.8.0-dev"
    }, 
    "origin": "24.197.59.36", 
    "url": "http://httpbin.org/get"
}
Oxicode commented 10 years ago

+1

JamesDavidCarr commented 9 years ago

I made a pull request a while ago for this.

Hoping that I can get some feedback from you both about how this compares to what you expected.

https://github.com/jakubroztocil/httpie/pull/246