Follow Redirects

The follow redirects plugin allows the client to send subsequent requests whenever the response is of the Redirect (3XX) variant.

:max_redirects

It also allows one to set the maximum number of redirects (default is 3):

http = HTTPX.plugin(:follow_redirects)

http.max_redirects(42).get("https://example.com/redirect41times")
# or
http.get("https://example.com/redirect41times", max_redirects: 42)

:follow_insecure_redirects

By default, insecure redirects (https to http) aren’t followed. If you want to allow them however, you can enable this option:

http = HTTPX.plugin(:follow_redirects)
http.get("https://redirecttohttp", follow_insecure_redirects: true)

Retry-After

Since v0.10.0, response redirection will be delayed if the redirect response carries a retry-after header. This is a standard way the server communicates to the client how long to wait before doing the next request.

Next: Retries