Add: verbose flag to show logs in detail

This commit is contained in:
DaZuo0122
2026-01-17 00:15:46 +08:00
parent 7746511fc4
commit 7e87edb411
11 changed files with 146 additions and 2 deletions

View File

@@ -9,3 +9,4 @@ serde = { version = "1", features = ["derive"] }
thiserror = "2"
tokio = { version = "1", features = ["net", "time"] }
url = "2"
tracing = "0.1"

View File

@@ -4,6 +4,7 @@ use std::net::{IpAddr, SocketAddr};
use std::time::{Duration, Instant};
use tokio::net::lookup_host;
use thiserror::Error;
use tracing::debug;
use url::Url;
#[derive(Debug, Error)]
@@ -67,6 +68,16 @@ pub struct HttpRequestOptions {
}
pub async fn request(url: &str, opts: HttpRequestOptions) -> Result<HttpReport, HttpError> {
debug!(
url,
method = ?opts.method,
timeout_ms = opts.timeout_ms,
follow_redirects = ?opts.follow_redirects,
http1_only = opts.http1_only,
http2_only = opts.http2_only,
proxy = ?opts.proxy,
"http request start"
);
let parsed = Url::parse(url).map_err(|err| HttpError::Url(err.to_string()))?;
let host = parsed
.host_str()