RequestInformation

Trait RequestInformation 

Source
pub trait RequestInformation {
    // Required methods
    fn is_host_header_allowed(&self) -> bool;
    fn host_header(&self) -> Option<&str>;
    fn authority(&self) -> Option<&str>;
    fn forwarded(&self) -> impl DoubleEndedIterator<Item = &str>;
    fn x_forwarded_for(&self) -> impl DoubleEndedIterator<Item = &str>;
    fn x_forwarded_host(&self) -> impl DoubleEndedIterator<Item = &str>;
    fn x_forwarded_proto(&self) -> impl DoubleEndedIterator<Item = &str>;
    fn x_forwarded_by(&self) -> impl DoubleEndedIterator<Item = &str>;
    fn default_scheme(&self) -> Option<&str>;

    // Provided method
    fn default_host(&self) -> Option<&str> { ... }
}
Expand description

A trait to extract required information from a request in order to fetch trusted information

Required Methods§

Source

fn is_host_header_allowed(&self) -> bool

Check if the host header is allowed

Most implementations should return true if the HTTP version is less than HTTP/2

Source

fn host_header(&self) -> Option<&str>

Get the host header of the request

Source

fn authority(&self) -> Option<&str>

Get the authority of the request

Source

fn forwarded(&self) -> impl DoubleEndedIterator<Item = &str>

Get the Forwarded header values

A double-ended iterator is returned to allow the implementation to optimize the iteration in case of multiple values

Source

fn x_forwarded_for(&self) -> impl DoubleEndedIterator<Item = &str>

Get the X-Forwarded-For header values

Source

fn x_forwarded_host(&self) -> impl DoubleEndedIterator<Item = &str>

Get the X-Forwarded-Host header values

Source

fn x_forwarded_proto(&self) -> impl DoubleEndedIterator<Item = &str>

Get the X-Forwarded-Proto header values

Source

fn x_forwarded_by(&self) -> impl DoubleEndedIterator<Item = &str>

Get the X-Forwarded-By header values

Source

fn default_scheme(&self) -> Option<&str>

Return the default scheme of the request when no trusted headers are found

Provided Methods§

Source

fn default_host(&self) -> Option<&str>

Return the default host of the request when no trusted headers are found

Default to host header if allowed or authority

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RequestInformation for Parts

Source§

impl<T> RequestInformation for Request<T>

Implementors§