isahc

Trait ResponseExt

Source
pub trait ResponseExt<T> {
    // Required methods
    fn trailer(&self) -> &Trailer;
    fn effective_uri(&self) -> Option<&Uri>;
    fn local_addr(&self) -> Option<SocketAddr>;
    fn remote_addr(&self) -> Option<SocketAddr>;
    fn metrics(&self) -> Option<&Metrics>;
}
Expand description

Provides extension methods for working with HTTP responses.

Required Methods§

Source

fn trailer(&self) -> &Trailer

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());
Source

fn effective_uri(&self) -> Option<&Uri>

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.

Source

fn local_addr(&self) -> Option<SocketAddr>

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.

Source

fn remote_addr(&self) -> Option<SocketAddr>

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.

Source

fn metrics(&self) -> Option<&Metrics>

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§

Source§

impl<T> ResponseExt<T> for Response<T>