refactor: reconsider http read header timeouts

This commit is contained in:
Jun Kurihara 2024-01-23 02:29:05 +09:00
commit 8081eb9f92
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
4 changed files with 22 additions and 7 deletions

View file

@ -29,8 +29,14 @@ pub(crate) fn connection_builder(globals: &Arc<Globals>) -> Arc<ConnectionBuilde
.pipeline_flush(true);
http_server
.http2()
.keep_alive_interval(Some(globals.proxy_config.proxy_idle_timeout))
.timer(TokioTimer)
.max_concurrent_streams(globals.proxy_config.max_concurrent_streams);
if globals.proxy_config.keepalive {
http_server
.http2()
.keep_alive_interval(Some(globals.proxy_config.proxy_idle_timeout))
.keep_alive_timeout(globals.proxy_config.proxy_idle_timeout + std::time::Duration::from_secs(1))
.timer(TokioTimer);
}
Arc::new(http_server)
}

View file

@ -88,10 +88,9 @@ where
let message_handler_clone = self.message_handler.clone();
let tls_enabled = self.tls_enabled;
let listening_on = self.listening_on;
let timeout_sec = Duration::from_secs(CONNECTION_TIMEOUT_SEC + 1); // just in case...
self.globals.runtime_handle.clone().spawn(async move {
timeout(
timeout_sec + Duration::from_secs(1), // just in case...
Duration::from_secs(CONNECTION_TIMEOUT_SEC) + Duration::from_secs(1), // just in case...
server_clone.serve_connection_with_upgrades(
stream,
service_fn(move |req: Request<Incoming>| {