Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(server): strip stale Content-Length when proxying rewritten bodies

Akarshan Biswasfebad8ade9c8
diff --git a/src-tauri/src/core/server/proxy.rs b/src-tauri/src/core/server/proxy.rs
index 075168b9c..6494e1819 100644
--- a/src-tauri/src/core/server/proxy.rs
+++ b/src-tauri/src/core/server/proxy.rs
@@ -2454,8 +2454,14 @@ async fn proxy_request(
for (key_idx, key_opt) in key_attempts.iter().enumerate() {
let mut outbound_req = client.request(method.clone(), upstream_url.clone());
+ // Body is re-buffered/rewritten, so a stale inbound Content-Length would
+ // mismatch the bytes we send and stall the upstream; reqwest re-derives it.
for (name, value) in headers.iter() {
- if name != hyper::header::HOST && name != hyper::header::AUTHORIZATION {
+ if name != hyper::header::HOST
+ && name != hyper::header::AUTHORIZATION
+ && name != hyper::header::CONTENT_LENGTH
+ && name != hyper::header::TRANSFER_ENCODING
+ {
outbound_req = outbound_req.header(name, value);
}
}