http-request 8.58.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 crate::*;

/// Represents the body of an HTTP request as a JSON object, stored as a `DashMap`
/// with static string keys and values. This type is typically used for structured data
/// in the body of the request.
pub type BodyJson = DashMap<&'static str, &'static str>;

/// Represents the body of an HTTP request as plain text. This type is used for requests
/// where the body contains raw string content, such as simple text data or form submissions.
pub type BodyText = &'static str;

pub type BodyBinary = &'static [u8];

/// Represents the body of an HTTP request, which can be either plain text, JSON, or binary data.
/// This enum allows different types of content to be used in the body of the request, supporting
/// both structured and unstructured data formats.
#[derive(Debug, Clone)]
pub enum Body {
    /// The text variant of the body, containing plain string content.
    ///
    /// This variant holds a reference to a static string (`BodyText`), typically used
    /// when the request body contains text data such as a plain message or form input.
    Text(BodyText),

    /// The JSON variant of the body, containing structured JSON data.
    ///
    /// This variant holds a `BodyJson`, which is a `DashMap` with static string keys
    /// and values. It is useful for sending data in JSON format, typically for APIs
    /// that require structured data in the request body.
    Json(BodyJson),

    /// The binary variant of the body, containing raw binary data.
    ///
    /// This variant holds a reference to a static slice of bytes (`BodyBinary`), and
    /// is useful when sending raw binary data such as images, files, or non-text content.
    Binary(BodyBinary),
}