Skip to content

Commit

Permalink
fix(core): return empty body for HEAD requests to asset protocol, c…
Browse files Browse the repository at this point in the history
…loses #11263 (#11264)
  • Loading branch information
chrox authored Oct 8, 2024
1 parent eda5713 commit 04fd3a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/asset-protocol-head-empty-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:bug
---

Respond with empty body for `HEAD` requests to `asset` protocol
4 changes: 4 additions & 0 deletions crates/tauri/src/protocol/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04fd3a7

Please sign in to comment.