Skip to main content

qubit_http/request/
http_request.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! Immutable HTTP request object.
10
11use std::time::Duration;
12
13use http::{HeaderMap, Method};
14use tokio_util::sync::CancellationToken;
15
16use super::http_request_body::HttpRequestBody;
17use super::http_request_retry_override::HttpRequestRetryOverride;
18
19/// Immutable snapshot of a single HTTP call produced by [`crate::HttpRequestBuilder`].
20#[derive(Debug, Clone)]
21pub struct HttpRequest {
22    /// HTTP method (GET, POST, …).
23    pub method: Method,
24    /// Absolute URL string, or path joined with client `base_url` when not parseable as URL.
25    pub path: String,
26    /// Query string parameters as `(name, value)` pairs.
27    pub query: Vec<(String, String)>,
28    /// Headers added on top of client defaults and injector output.
29    pub headers: HeaderMap,
30    /// Serialized body variant.
31    pub body: HttpRequestBody,
32    /// Overrides client-wide request timeout when set; otherwise client default applies.
33    pub request_timeout: Option<Duration>,
34    /// Optional cancellation token checked before send and during I/O phases.
35    pub cancellation_token: Option<CancellationToken>,
36    /// Per-request retry override (enable/disable/method-policy/Retry-After behavior).
37    pub retry_override: HttpRequestRetryOverride,
38}