Follows redirects.
The original request method may be changed to GET depending on the status code:
| Code | Method handling |
|---|---|
| 301, 302, 303 | Changed to GET |
| 307, 308 | Method not changed |
Request Options
:redirect- if set tofalse, disables automatic response redirects. Defaults totrue.:redirect_trusted- by default, authorization credentials are only sent on redirects with the same host, scheme and port. If:redirect_trustedis set totrue, credentials will be sent to any host. Defaults tofalse.:redirect_log_level- the log level to emit redirect logs at. Can also be set tofalseto disable logging these messages. Defaults to:debug.:max_redirects- the maximum number of redirects, defaults to10. If the limit is reached, aReq.TooManyRedirectsErrorexception is returned.
Examples
iex> Req.get!("http://api.github.com").status
# 23:24:11.670 [debug] redirecting to https://api.github.com/
200
iex> Req.get!("https://httpbingo.org/redirect/4", max_redirects: 3)
# 23:07:59.570 [debug] redirecting to /relative-redirect/3
# 23:08:00.068 [debug] redirecting to /relative-redirect/2
# 23:08:00.206 [debug] redirecting to /relative-redirect/1
** (Req.TooManyRedirectsError) too many redirects (3)
iex> Req.get!("http://api.github.com", redirect_log_level: false)
200
iex> Req.get!("http://api.github.com", redirect_log_level: :error)
# 23:24:11.670 [error] redirecting to https://api.github.com/
200