http-request 21.7.9

http-request is a lightweight, efficient library for building, sending, and handling HTTP/HTTPS requests in Rust applications. It provides a simple and intuitive API, allowing developers to easily interact with web services, whether they use the "HTTP" or "HTTPS" protocol. The library supports various HTTP methods, custom headers, request bodies, timeout, automatic handling of redirects (including detecting redirect loops), and enhanced response body decoding (both automatic and manual), enabling fast and secure communication. Whether working with secure "HTTPS" connections or standard "HTTP" requests, the library is optimized for performance, minimal resource usage, and easy integration into Rust projects.
Documentation
use super::*;

/// Configuration for an outgoing HTTP request.
///
/// Field-by-field setters are generated by `lombok-macros` (`#[set]` /
/// `#[set(type(...))]`), aligning with `hyperlane-core`'s `ServerConfig` /
/// `RequestConfig` style — see `hyperlane-standards §8`.
///
/// For most use cases, prefer the fluent setters on
/// [`crate::RequestBuilder`]. This type is the underlying data passed to
/// `HttpRequest` and is also returned by [`HttpRequest::config`].
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct RequestConfig {
    /// Per-read buffer size in bytes.
    pub buffer_size: usize,
    /// Request timeout in milliseconds.
    pub timeout: u64,
    /// Maximum number of redirects to follow (0 = no redirect).
    pub max_redirect_times: usize,
    /// HTTP version (`HttpVersion::Http1_1` / `HttpVersion::Http2`).
    pub http_version: HttpVersion,
    /// Whether to follow redirects automatically.
    pub redirect: bool,
    /// Whether to automatically decode response bodies (gzip / deflate / br).
    pub decode: bool,
    /// Optional proxy configuration. `None` means direct connection.
    pub proxy: Option<Proxy>,
}

impl RequestConfig {
    /// Set `buffer_size` field.
    pub fn set_buffer_size(&mut self, v: usize) -> &mut Self {
        self.buffer_size = v;
        self
    }
    /// Get `buffer_size` field.
    pub fn get_buffer_size(&self) -> usize {
        self.buffer_size
    }
    /// Set `timeout` field.
    pub fn set_timeout(&mut self, v: u64) -> &mut Self {
        self.timeout = v;
        self
    }
    /// Get `timeout` field.
    pub fn get_timeout(&self) -> u64 {
        self.timeout
    }
    /// Set `max_redirect_times` field.
    pub fn set_max_redirect_times(&mut self, v: usize) -> &mut Self {
        self.max_redirect_times = v;
        self
    }
    /// Get `max_redirect_times` field.
    pub fn get_max_redirect_times(&self) -> usize {
        self.max_redirect_times
    }
    /// Set `http_version` field.
    pub fn set_http_version(&mut self, v: HttpVersion) -> &mut Self {
        self.http_version = v;
        self
    }
    /// Get `http_version` field.
    pub fn get_http_version(&self) -> &HttpVersion {
        &self.http_version
    }
    /// Set `redirect` field.
    pub fn set_redirect(&mut self, v: bool) -> &mut Self {
        self.redirect = v;
        self
    }
    /// Get `redirect` field.
    pub fn get_redirect(&self) -> bool {
        self.redirect
    }
    /// Set `decode` field.
    pub fn set_decode(&mut self, v: bool) -> &mut Self {
        self.decode = v;
        self
    }
    /// Get `decode` field.
    pub fn get_decode(&self) -> bool {
        self.decode
    }
    /// Set `proxy` field.
    pub fn set_proxy(&mut self, v: Option<Proxy>) -> &mut Self {
        self.proxy = v;
        self
    }
    /// Get `proxy` field.
    pub fn get_proxy(&self) -> &Option<Proxy> {
        &self.proxy
    }
}