From e5d157e1afefa4b070ae6598e8a8a2902833e7ba Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Sat, 5 Feb 2022 16:59:54 +0000 Subject: [PATCH] :bug: bug: don't send Content-Length to relay if status code is 304 Not Modified Thanks to Nginx for noticing this --- crates/ptth_server/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ptth_server/src/lib.rs b/crates/ptth_server/src/lib.rs index 67ed009..542adb7 100644 --- a/crates/ptth_server/src/lib.rs +++ b/crates/ptth_server/src/lib.rs @@ -97,9 +97,12 @@ async fn handle_one_req ( .header (ptth_core::PTTH_MAGIC_HEADER, base64::encode (rmp_serde::to_vec (&response.parts).map_err (ServerError::MessagePackEncodeResponse)?)) .header ("X-PTTH-SERVER-NAME", &state.config.name); - if let Some (length) = response.content_length { - resp_req = resp_req.header ("Content-Length", length.to_string ()); + if response.parts.status_code != ptth_core::http_serde::StatusCode::NotModified { + if let Some (length) = response.content_length { + resp_req = resp_req.header ("Content-Length", length.to_string ()); + } } + if let Some (mut body) = response.body { if state.config.throttle_upload { // Spawn another task to throttle the chunks