[][src]Struct chttp::options::Options

pub struct Options {
    pub redirect_policy: RedirectPolicy,
    pub preferred_http_version: Option<Version>,
    pub timeout: Option<Duration>,
    pub connect_timeout: Duration,
    pub tcp_keepalive: Option<Duration>,
    pub tcp_nodelay: bool,
    pub buffer_size: usize,
    pub auto_referer: bool,
    pub proxy: Option<Uri>,
    pub dns_servers: Option<Vec<SocketAddr>>,
    pub max_upload_speed: Option<u64>,
    pub max_download_speed: Option<u64>,
    pub ssl_ciphers: Option<Vec<String>>,
    pub ssl_client_certificate: Option<ClientCertificate>,
}

Defines various protocol and connection options.

Fields

redirect_policy: RedirectPolicy

The policy for automatically following server redirects.

The default is to not follow redirects.

preferred_http_version: Option<Version>

A preferred HTTP version the client should attempt to use to communicate to the server with.

This is treated as a suggestion. A different version may be used if the server does not support it or negotiates a different version.

The default value is None (any version).

timeout: Option<Duration>

A timeout for the maximum time allowed for a request-response cycle.

The default value is None (unlimited).

connect_timeout: Duration

A timeout for the initial connection phase.

The default value is 300 seconds.

tcp_keepalive: Option<Duration>

Enable or disable TCP keepalive with a given probe interval.

The default value is None (disabled).

tcp_nodelay: bool

Enable or disable the TCP_NODELAY option.

The default value is false.

buffer_size: usize

Set the max buffer size in bytes to use for reading the response body.

The default value is 8 KiB.

auto_referer: bool

Indicates whether the Referer header should be automatically updated.

proxy: Option<Uri>

A proxy to use for requests.

The proxy protocol is specified by the URI scheme.

  • http: Proxy. Default when no scheme is specified.
  • https: HTTPS Proxy. (Added in 7.52.0 for OpenSSL, GnuTLS and NSS)
  • socks4: SOCKS4 Proxy.
  • socks4a: SOCKS4a Proxy. Proxy resolves URL hostname.
  • socks5: SOCKS5 Proxy.
  • socks5h: SOCKS5 Proxy. Proxy resolves URL hostname.
dns_servers: Option<Vec<SocketAddr>>

A list of specific DNS servers to be used for DNS resolution.

By default this option is not set and the system's built-in DNS resolver is used. This option can only be used if libcurl is compiled with c-ares, otherwise this option has no effect.

max_upload_speed: Option<u64>

A maximum upload speed for the request body, in bytes per second.

The default is unlimited.

max_download_speed: Option<u64>

A maximum download speed for the response body, in bytes per second.

The default is unlimited.

ssl_ciphers: Option<Vec<String>>

A list of ciphers to use for SSL/TLS connections.

The list of valid cipher names is dependent on the underlying SSL/TLS engine in use.

You can find an up-to-date list of potential cipher names at https://curl.haxx.se/docs/ssl-ciphers.html.

The default is unset and will result in the system defaults being used.

ssl_client_certificate: Option<ClientCertificate>

A custom SSL/TLS client certificate to use for all client connections.

If a format is not supported by the underlying SSL/TLS engine, an error will be returned when attempting to send a request using the offending certificate.

The default value is none.

Examples

let cert = ClientCertificate::PEM {
    path: "client.pem".into(),
    private_key: Some(PrivateKey::PEM {
        path: "key.pem".into(),
        password: Some("secret".into()),
    }),
};
let options = Options::default()
    .with_ssl_client_certificate(Some(cert));

Methods

impl Options[src]

pub fn with_redirect_policy(self, value: RedirectPolicy) -> Self[src]

Sets the #name property.

pub fn with_preferred_http_version(self, value: Option<Version>) -> Self[src]

Sets the #name property.

pub fn with_timeout(self, value: Option<Duration>) -> Self[src]

Sets the #name property.

pub fn with_connect_timeout(self, value: Duration) -> Self[src]

Sets the #name property.

pub fn with_tcp_keepalive(self, value: Option<Duration>) -> Self[src]

Sets the #name property.

pub fn with_tcp_nodelay(self, value: bool) -> Self[src]

Sets the #name property.

pub fn with_buffer_size(self, value: usize) -> Self[src]

Sets the #name property.

pub fn with_auto_referer(self, value: bool) -> Self[src]

Sets the #name property.

pub fn with_proxy(self, value: Option<Uri>) -> Self[src]

Sets the #name property.

pub fn with_dns_servers(self, value: Option<Vec<SocketAddr>>) -> Self[src]

Sets the #name property.

pub fn with_max_upload_speed(self, value: Option<u64>) -> Self[src]

Sets the #name property.

pub fn with_max_download_speed(self, value: Option<u64>) -> Self[src]

Sets the #name property.

pub fn with_ssl_ciphers(self, value: Option<Vec<String>>) -> Self[src]

Sets the #name property.

pub fn with_ssl_client_certificate(
    self,
    value: Option<ClientCertificate>
) -> Self
[src]

Sets the #name property.

Trait Implementations

impl Clone for Options[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Options[src]

fn default() -> Self[src]

Create a new options with the default values.

impl Debug for Options[src]

Auto Trait Implementations

impl Send for Options

impl Sync for Options

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]