http-request 23.3.0

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::*;

/// Default construction for [`Tmp`].
impl Default for Tmp {
    /// Builds a default temporary store without eagerly cloning bundled TLS roots.
    ///
    /// # Returns
    ///
    /// - `Tmp`: a store with an empty visited-URL set and lazy default TLS roots.
    #[inline(always)]
    fn default() -> Self {
        Self {
            visit_url: HashSet::new(),
            root_cert: None,
        }
    }
}

/// Inherent implementation of [`Tmp`].
impl Tmp {
    /// Borrows the custom TLS root certificate store if custom roots were configured.
    ///
    /// # Returns
    ///
    /// - `Option<&RootCertStore>` - Custom trust store, or `None` for default WebPKI roots.
    #[inline(always)]
    pub(crate) fn root_cert_ref(&self) -> Option<&RootCertStore> {
        let Self { root_cert, .. } = self;
        root_cert.as_ref()
    }

    /// Lazily initializes the TLS root store from bundled Mozilla roots and returns a mutable handle.
    ///
    /// # Returns
    ///
    /// - `&mut RootCertStore` - Mutable custom root certificate store.
    pub(crate) fn root_cert_or_init(&mut self) -> &mut RootCertStore {
        let Self { root_cert, .. } = self;
        root_cert.get_or_insert_with(|| RootCertStore {
            roots: TLS_SERVER_ROOTS.to_vec(),
        })
    }
}