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
/// Hexadecimal uppercase digit table used by percent-encoding and multipart boundaries.
pub(crate) const HEX_UPPER: &[u8; 16] = b"0123456789ABCDEF";

/// Default `application/x-www-form-urlencoded` media type for form request bodies.
pub(crate) const FORM_URLENCODED_CONTENT_TYPE: &str = "application/x-www-form-urlencoded";

/// Canonical `application/json` media type applied by [`RequestBuilder::try_body_json`].
pub(crate) const JSON_CONTENT_TYPE: &str = "application/json";

/// Internal delimiter joining repeated `Set-Cookie` response headers without colliding with RFC 9110 field values.
pub(crate) const SET_COOKIE_DELIMITER: char = '\n';

/// Default `multipart/form-data` boundary prefix.
pub(crate) const MULTIPART_BOUNDARY_PREFIX: &str = "hyperlane-boundary-";

/// `Authorization` header prefix for Bearer tokens.
pub(crate) const BEARER_PREFIX: &str = "Bearer ";

/// `Authorization` header prefix for HTTP Basic credentials.
pub(crate) const BASIC_PREFIX: &str = "Basic ";

/// Error message returned when an HTTP/2 TLS handshake fails to negotiate `h2` ALPN.
pub(crate) const H2_ALPN_MISMATCH: &str = "Server did not negotiate HTTP/2 via ALPN";

/// Maximum stack buffer length for zero-allocation lowercase header lookups.
pub(crate) const RESPONSE_HEADER_STACK_LIMIT: usize = 64;

/// Maximum exponential backoff delay between automatic retries (milliseconds).
pub(crate) const MAX_RETRY_BACKOFF_MS: u64 = 1000;

/// Base exponential backoff delay for the first retry attempt (milliseconds).
pub(crate) const BASE_RETRY_BACKOFF_MS: u64 = 50;

/// Upper cap honored for server-supplied `Retry-After` integer delays (milliseconds).
pub(crate) const MAX_RETRY_AFTER_MS: u64 = 10_000;

/// Lowercase `retry-after` response header name.
pub(crate) const HEADER_RETRY_AFTER: &str = "retry-after";

/// HTTP/2 client initial per-stream receive window size (1 MiB).
pub(crate) const H2_INITIAL_STREAM_WINDOW: u32 = 1024 * 1024;

/// HTTP/2 client initial connection-level receive window size (4 MiB).
pub(crate) const H2_INITIAL_CONN_WINDOW: u32 = 4 * 1024 * 1024;

/// HTTP/2 client maximum DATA frame size (64 KiB).
pub(crate) const H2_MAX_FRAME_SIZE: u32 = 64 * 1024;

/// Stack buffer capacity for zero-allocation HTTP/2 URI serialization.
pub(crate) const H2_URI_STACK_CAP: usize = 256;

/// Default HTTP/1.1 tail headers emitted when a request has no custom headers and keep-alive is enabled.
pub(crate) const DEFAULT_WIRE_TAIL_KEEP_ALIVE: &[u8] =
    b"\r\naccept: */*\r\nuser-agent: hyperlane\r\nconnection: keep-alive\r\n\r\n";

/// Default HTTP/1.1 tail headers emitted when a request has no custom headers and keep-alive is disabled.
pub(crate) const DEFAULT_WIRE_TAIL_CLOSE: &[u8] =
    b"\r\naccept: */*\r\nuser-agent: hyperlane\r\nconnection: close\r\n\r\n";

/// Default size of the thread-local pre-zeroed synchronous read scratch buffer.
pub(crate) const SYNC_READ_SCRATCH_CAP: usize = 8192;

/// Error message when an HTTP/2 send stream closes before granting flow-control capacity.
pub(crate) const H2_SEND_CAPACITY_CLOSED: &str =
    "HTTP/2 send stream closed before granting capacity";

/// Multipart boundary double-dash prefix bytes.
pub(crate) const MULTIPART_DASH_BYTES: &[u8] = b"--";

/// Multipart `Content-Disposition` form-data name header prefix bytes.
pub(crate) const MULTIPART_DISPOSITION_PREFIX: &[u8] = b"Content-Disposition: form-data; name=\"";

/// Multipart filename parameter prefix bytes.
pub(crate) const MULTIPART_FILENAME_PREFIX: &[u8] = b"; filename=\"";

/// Multipart `Content-Type` header prefix bytes.
pub(crate) const MULTIPART_CONTENT_TYPE_PREFIX: &[u8] = b"Content-Type: ";

/// Double-quote byte used in multipart parameters and URL validation.
pub(crate) const QUOTE_U8: u8 = b'"';

/// Underscore replacement byte for unsafe multipart parameter characters.
pub(crate) const UNDERSCORE_U8: u8 = b'_';

/// Hyphen byte allowed inside DNS host labels.
pub(crate) const HYPHEN_U8: u8 = b'-';

/// Forbidden ASCII bytes inside the fast-path URL path component.
pub(crate) const FAST_URL_PATH_FORBIDDEN: &[u8] = b"\\\"<>`{}^";

/// Forbidden ASCII bytes inside the fast-path URL query component.
pub(crate) const FAST_URL_QUERY_FORBIDDEN: &[u8] = b"\"<>`";

/// IDNA punycode label prefix requiring full WHATWG URL host validation.
pub(crate) const PUNYCODE_PREFIX: &str = "xn--";

/// Percent byte introducing percent-encoded sequences in URL paths.
pub(crate) const PERCENT_U8: u8 = b'%';