Crate follow_redirects [−] [src]
hyper to follow HTTP redirects.
This crate supports all 5 redirect styles that are defined by the HTTP/1.1 spec.
These include both "permanent" redirects (status codes
308) as well as
"temporary" redirects (status codes
303 See Other response from the server will cause the client to change
the request method to
GET, and discard the request body before following the redirect.
The client uses the
Location HTTP header to determine the next url to follow the redirect to.
Both relative (without a hostname) as well as absolute URLs (including schema and hostname) urls
Location header is missing in a response from the server, but the status code indicates
a redirect, the client will return the response to the caller. You can detect this situation by
checking the status code and headers of the returned response.
In order to be able to replay the request body when following redirects other than
303 See Other,
the client will buffer the request body in-memory before making the first request to the
To avoid following an endless chain of redirects, the client has a limit for the maximum number of redirects it will follow until giving up.
When the maximum number of redirects is reached, the client will simply return the last response to the caller. You can detect this situation by checking the status code of the returned response.
In order to protect the confidentiality of authentication or session information passed along in a request, the client will strip authentication and cookie headers when following a redirect to a different host and port.
Redirects to the same host and port, but different paths will retain session information.
extern crate hyper; extern crate follow_redirects; // 1. import the extension trait use follow_redirects::ClientExt; // ... // 2. create a standard hyper client let client = hyper::Client::new(&handle); // ... // 3. make a request that will follow redirects let url = "http://docs.rs/hyper".parse().unwrap(); let future = client.follow_redirects().get(url);
A client to make outgoing HTTP requests, and which follows redirects.
Extension trait for adding follow-redirect features to