mirror of
https://github.com/tauri-apps/tauri-plugin-http.git
synced 2026-01-31 00:45:17 +01:00
feat(http): add request and response tracing behind feature flag (#2079)
Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/11956038248 Co-authored-by: amrbashir <amrbashir@users.noreply.github.com>
This commit is contained in:
@@ -41,6 +41,7 @@ http = "1"
|
||||
reqwest = { version = "0.12", default-features = false }
|
||||
url = { workspace = true }
|
||||
data-url = "0.3"
|
||||
tracing = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
default = [
|
||||
@@ -71,3 +72,4 @@ http2 = ["reqwest/http2"]
|
||||
charset = ["reqwest/charset"]
|
||||
macos-system-configuration = ["reqwest/macos-system-configuration"]
|
||||
unsafe-headers = []
|
||||
tracing = ["dep:tracing"]
|
||||
|
||||
@@ -283,6 +283,9 @@ pub async fn fetch<R: Runtime>(
|
||||
|
||||
request = request.headers(headers);
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::trace!("{:?}", request);
|
||||
|
||||
let fut = async move { request.send().await.map_err(Into::into) };
|
||||
let mut resources_table = webview.resources_table();
|
||||
let rid = resources_table.add_request(Box::pin(fut));
|
||||
@@ -304,6 +307,9 @@ pub async fn fetch<R: Runtime>(
|
||||
.header(header::CONTENT_TYPE, data_url.mime_type().to_string())
|
||||
.body(reqwest::Body::from(body))?;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::trace!("{:?}", response);
|
||||
|
||||
let fut = async move { Ok(reqwest::Response::from(response)) };
|
||||
let mut resources_table = webview.resources_table();
|
||||
let rid = resources_table.add_request(Box::pin(fut));
|
||||
@@ -351,6 +357,9 @@ pub async fn fetch_send<R: Runtime>(
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::trace!("{:?}", res);
|
||||
|
||||
let status = res.status();
|
||||
let url = res.url().to_string();
|
||||
let mut headers = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user