Trait isahc::ResponseExt

source ·
pub trait ResponseExt<T> {
    fn trailer(&self) -> &Trailer;
    fn effective_uri(&self) -> Option<&Uri>;
    fn local_addr(&self) -> Option<SocketAddr>;
    fn remote_addr(&self) -> Option<SocketAddr>;
    fn cookie_jar(&self) -> Option<&CookieJar>;
    fn metrics(&self) -> Option<&Metrics>;
}
Expand description

Provides extension methods for working with HTTP responses.

Required Methods

Get the trailer of the response containing headers that were received after the response body.

See the documentation for Trailer for more details on how to handle trailing headers.

Examples
use isahc::prelude::*;

let mut response = isahc::get("https://my-site-with-trailers.com")?;

println!("Status: {}", response.status());
println!("Headers: {:#?}", response.headers());

// Read and discard the response body until the end.
response.consume()?;

// Now the trailer will be available as well.
println!("Trailing headers: {:#?}", response.trailer().try_get().unwrap());

Get the effective URI of this response. This value differs from the original URI provided when making the request if at least one redirect was followed.

This information is only available if populated by the HTTP client that produced the response.

Get the local socket address of the last-used connection involved in this request, if known.

Multiple connections may be involved in a request, such as with redirects.

This method only makes sense with a normal Internet request. If some other kind of transport is used to perform the request, such as a Unix socket, then this method will return None.

Get the remote socket address of the last-used connection involved in this request, if known.

Multiple connections may be involved in a request, such as with redirects.

This method only makes sense with a normal Internet request. If some other kind of transport is used to perform the request, such as a Unix socket, then this method will return None.

Addresses and proxies

The address returned by this method is the IP address and port that the client connected to and not necessarily the real address of the origin server. Forward and reverse proxies between the caller and the server can cause the address to be returned to reflect the address of the nearest proxy rather than the server.

Available on crate feature cookies only.

Get the configured cookie jar used for persisting cookies from this response, if any.

Availability

This method is only available when the cookies feature is enabled.

If request metrics are enabled for this particular transfer, return a metrics object containing a live view of currently available data.

By default metrics are disabled and None will be returned. To enable metrics you can use Configurable::metrics.

Implementors