diff --git a/.changes/asset-protocol-head-empty-body.md b/.changes/asset-protocol-head-empty-body.md new file mode 100644 index 000000000000..2631c02098a9 --- /dev/null +++ b/.changes/asset-protocol-head-empty-body.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:bug +--- + +Respond with empty body for `HEAD` requests to `asset` protocol diff --git a/crates/tauri/src/protocol/asset.rs b/crates/tauri/src/protocol/asset.rs index 961a7221c5e4..b46bd69d9dc6 100644 --- a/crates/tauri/src/protocol/asset.rs +++ b/crates/tauri/src/protocol/asset.rs @@ -199,6 +199,10 @@ fn get_response( })?; resp.body(buf.into()) } + } else if request.method() == http::Method::HEAD { + // if the HEAD method is used, we should not return a body + resp = resp.header(CONTENT_LENGTH, len); + resp.body(Vec::new().into()) } else { // avoid reading the file if we already read it // as part of mime type detection