Struct HttpPeer

Source
pub struct HttpPeer { /* private fields */ }

Implementations§

Source§

impl HttpPeer

Source

pub fn new(address: SocketAddr, request_host: &str) -> Self

Create a new HttpPeer with the given address and request host.

Source

pub fn forward_for(self, forward_for: ForwardedFor) -> Self

Set the Forwarded-For or X-Forwarded-* headers to the given value.

Source

pub fn sni_host(self, sni_host: String) -> Self

Set the SNI host to the given value. This is the host that will be used for the TLS handshake.

Source

pub fn request_host(self, request_host: String) -> Self

Set the Host header to the given value. This is the host that will be used for the HTTP request.

Source

pub fn via(self, via: &str, in_request: bool, in_response: bool) -> Self

Set the Via header to the given value. This header can be added to the request fowarded to the peer and/or to the response returned to the client.

Source

pub fn allow_invalid_certificates( self, allow_invalid_certificates: bool, ) -> Self

Set whether invalid certificates should be allowed.

Source

pub fn supported_encodings(self, supported_encodings: HashSet<String>) -> Self

A set of supported encodings that this server can handle, this may be useful if you need to update the response body and you cannot handle some encodings.

Source

pub fn force_close(self, force_close: bool) -> Self

Set whether the connection should be closed after the request has been forwarded to the peer.

Source

pub fn tls(self, tls: bool) -> Self

Set whether the connection should be encrypted using TLS when connecting to the peer.

Source

pub fn timeout(self, timeout: Duration) -> Self

Set the timeout for the request to the peer. If the timeout is reached, the request will be aborted and an error will be returned to the client.

Source

pub fn request_body_size_limit(self, request_body_size_limit: usize) -> Self

Set the maximum size of the request body that can be stored in memory.

This limit should not be used in most cases as the request body is streamed and not stored in memory. However, there is some cases where the request body needs to be stored in memory, think of an old client sending HTTP/1.0 requests with a body. In this case the body will be stored in memory before being forwarded to the peer.

This limit prevents the server from storing too much data in memory. The default value is 16MB.

Trait Implementations§

Source§

impl Clone for HttpPeer

Source§

fn clone(&self) -> HttpPeer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl PartialEq for HttpPeer

Source§

fn eq(&self, other: &HttpPeer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HttpPeer

Source§

impl StructuralPartialEq for HttpPeer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,