diff --git a/src-tauri/src/http_request.rs b/src-tauri/src/http_request.rs index 1348d741..0b38c0c8 100644 --- a/src-tauri/src/http_request.rs +++ b/src-tauri/src/http_request.rs @@ -399,6 +399,15 @@ pub async fn send_http_request( } else { warn!("Unsupported body type: {}", body_type); } + } else { + // No body set + let method = request.method.to_ascii_lowercase(); + let is_body_method = method == "post" || method == "put" || method == "patch"; + // Add Content-Length for methods that commonly accept a body because some servers + // will error if they don't receive it. + if is_body_method && !headers.contains_key("content-length") { + headers.insert("Content-Length", HeaderValue::from_static("0")); + } } // Add headers last, because previous steps may modify them