Skip to main content

nautilus_network/http/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Asynchronous HTTP requests with rate limiting, connection reuse, and bounded responses.
17//!
18//! # Architecture
19//!
20//! [`HttpClient`] applies quota policy before delegating requests to [`InnerHttpClient`]. The inner
21//! client owns one reusable [`reqwest::Client`], preserving its connection pool across requests and
22//! clones.
23//!
24//! # Rate limiting and requests
25//!
26//! Requests can await default and per-key quotas from one or more shared
27//! [`RateLimiter`](crate::ratelimiter::RateLimiter) instances. Sharing a limiter across clients
28//! enforces one process-wide budget for scopes such as an IP address or account. The client accepts
29//! default and per-request headers, repeated query values, raw bodies, client-level and per-request
30//! timeouts, and an optional proxy.
31//!
32//! HTTP status errors remain [`HttpResponse`] values for adapter-specific handling. The client does
33//! not retry requests automatically; adapters can apply [`crate::retry::RetryManager`] when the
34//! operation and venue error are safe to retry.
35//!
36//! # Connection and response policy
37//!
38//! The underlying client enables `TCP_NODELAY`, pooled idle connections, HTTP/2 keepalive while
39//! idle, and adaptive HTTP/2 flow control. Responses retain only configured header fields and reject
40//! bodies larger than 100 MiB, including chunked bodies without a declared length. The redacted
41//! request path removes credential-bearing URLs from transport errors and logs.
42//!
43//! `reqwest` owns the lifecycle of individual pooled connections, so this client exposes no socket
44//! state sink or explicit reconnect operation. Callers observe connection failure through each
45//! request result and retain the client to preserve its pool.
46
47pub mod client;
48pub mod error;
49pub mod types;
50
51// Re-exports
52pub use client::{HttpClient, HttpRedirectPolicy, InnerHttpClient};
53pub use error::HttpClientError;
54pub use reqwest::{Error as ReqwestError, Method, Response, StatusCode, Url, header::USER_AGENT};
55pub use types::{HttpMethod, HttpResponse, HttpStatus};