Struct HttpConnector

Source
pub struct HttpConnector<R = GaiResolver> { /* private fields */ }
Expand description

A connector for the http scheme.

Performs DNS resolution in a thread pool, and then connects over TCP.

§Note

Sets the HttpInfo value on responses, which includes transport information such as the remote socket address used.

Implementations§

Source§

impl HttpConnector

Source

pub fn new(threads: usize) -> HttpConnector

Construct a new HttpConnector.

Takes number of DNS worker threads.

Source

pub fn new_with_executor<E>( executor: E, handle: Option<Handle>, ) -> HttpConnector
where E: 'static + Executor<GaiTask> + Send + Sync,

Construct a new HttpConnector.

Takes an executor to run blocking getaddrinfo tasks on.

Source§

impl HttpConnector<TokioThreadpoolGaiResolver>

Source

pub fn new_with_tokio_threadpool_resolver() -> HttpConnector<TokioThreadpoolGaiResolver>

Construct a new HttpConnector using the TokioThreadpoolGaiResolver.

This resolver requires the threadpool runtime to be used.

Source§

impl<R> HttpConnector<R>

Source

pub fn new_with_resolver(resolver: R) -> HttpConnector<R>

Construct a new HttpConnector.

Takes a Resolve to handle DNS lookups.

Source

pub fn enforce_http(&mut self, is_enforced: bool)

Option to enforce all Uris have the http scheme.

Enabled by default.

Source

pub fn set_reactor(&mut self, handle: Option<Handle>)

Set a handle to a Reactor to register connections to.

If None, the implicit default reactor will be used.

Source

pub fn set_keepalive(&mut self, dur: Option<Duration>)

Set that all sockets have SO_KEEPALIVE set with the supplied duration.

If None, the option will not be set.

Default is None.

Source

pub fn set_nodelay(&mut self, nodelay: bool)

Set that all sockets have SO_NODELAY set to the supplied value nodelay.

Default is false.

Source

pub fn set_send_buffer_size(&mut self, size: Option<usize>)

Sets the value of the SO_SNDBUF option on the socket.

Source

pub fn set_recv_buffer_size(&mut self, size: Option<usize>)

Sets the value of the SO_RCVBUF option on the socket.

Source

pub fn set_local_address(&mut self, addr: Option<IpAddr>)

Set that all sockets are bound to the configured address before connection.

If None, the sockets will not be bound.

Default is None.

Source

pub fn set_resolve_timeout(&mut self, dur: Option<Duration>)

Set timeout for hostname resolution.

If None, then no timeout is applied by the connector, making it subject to the timeout imposed by the operating system.

Default is None.

Source

pub fn set_connect_timeout(&mut self, dur: Option<Duration>)

Set the connect timeout.

If a domain resolves to multiple IP addresses, the timeout will be evenly divided across them.

Default is None.

Source

pub fn set_happy_eyeballs_timeout(&mut self, dur: Option<Duration>)

Set timeout for RFC 6555 (Happy Eyeballs) algorithm.

If hostname resolves to both IPv4 and IPv6 addresses and connection cannot be established using preferred address family before timeout elapses, then connector will in parallel attempt connection using other address family.

If None, parallel connection attempts are disabled.

Default is 300 milliseconds.

Source

pub fn set_reuse_address( &mut self, reuse_address: bool, ) -> &mut HttpConnector<R>

Set that all socket have SO_REUSEADDR set to the supplied value reuse_address.

Default is false.

Trait Implementations§

Source§

impl<R> Clone for HttpConnector<R>
where R: Clone,

Source§

fn clone(&self) -> HttpConnector<R>

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<R> Connect for HttpConnector<R>
where R: Resolve + Clone + Send + Sync, <R as Resolve>::Future: Send,

Source§

type Transport = TcpStream

The connected IO Stream.
Source§

type Error = Error

An error occured when trying to connect.
Source§

type Future = HttpConnecting<R>

A Future that will resolve to the connected Transport.
Source§

fn connect(&self, dst: Destination) -> <HttpConnector<R> as Connect>::Future

Connect to a destination.
Source§

impl<R> Debug for HttpConnector<R>
where R: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for HttpConnector<R>
where R: Freeze,

§

impl<R = GaiResolver> !RefUnwindSafe for HttpConnector<R>

§

impl<R> Send for HttpConnector<R>
where R: Send,

§

impl<R> Sync for HttpConnector<R>
where R: Sync,

§

impl<R> Unpin for HttpConnector<R>
where R: Unpin,

§

impl<R = GaiResolver> !UnwindSafe for HttpConnector<R>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.