From 55342309b94c78ec59d338c699c07c5642eebf1d Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:05:51 +0100 Subject: [PATCH] move keep-alive fix to only close connections where an error occurs --- crates/auth/src/error.rs | 2 ++ src/main.rs | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/auth/src/error.rs b/crates/auth/src/error.rs index 763b4b1..87f7915 100644 --- a/crates/auth/src/error.rs +++ b/crates/auth/src/error.rs @@ -26,6 +26,8 @@ impl actix_web::error::ResponseError for Error { match self { Error::Unauthorized => HttpResponse::build(self.status_code()) .append_header(("WWW-Authenticate", "Basic")) + // This is an unfortunate workaround for https://github.com/actix/actix-web/issues/1805 + .force_close() .body(self.to_string()), _ => HttpResponse::build(self.status_code()).body(self.to_string()), } diff --git a/src/main.rs b/src/main.rs index 0834244..6740007 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use crate::config::Config; -use actix_web::http::KeepAlive; use actix_web::HttpServer; use anyhow::Result; use app::make_app; @@ -57,8 +56,6 @@ async fn main() -> Result<()> { HttpServer::new(move || make_app(cal_store.clone(), auth.clone())) .bind((config.http.host, config.http.port))? - // This is an unfortunate workaround for https://github.com/actix/actix-web/issues/1805 - .keep_alive(KeepAlive::Disabled) .run() .await?;