From 7065c540e1822fb15d4d040703c314c15ce81e95 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 8 Nov 2018 16:29:43 -0800 Subject: [PATCH] set nodelay on socket #560 --- CHANGES.md | 14 ++++++++------ src/server/builder.rs | 33 ++++++++++++++++++++++++++------- src/server/service.rs | 2 +- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1e66cff87..617237417 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,18 +2,20 @@ ## [0.7.14] - 2018-11-x +### Added + +* Add method to configure custom error handler to `Query` and `Path` extractors. + +* Add method to configure `SameSite` option in `CookieIdentityPolicy`. + + ### Fixed * Fix keep-alive timer reset * HttpServer now treats streaming bodies the same for HTTP/1.x protocols. #549 - -### Added - -* Add method to configure custom error handler to `Query` and `Path` extractors. - -* Add method to configure `SameSite` option in `CookieIdentityPolicy`. +* Set nodelay for socket #560 ## [0.7.13] - 2018-10-14 diff --git a/src/server/builder.rs b/src/server/builder.rs index 4f159af13..ea3638f10 100644 --- a/src/server/builder.rs +++ b/src/server/builder.rs @@ -9,14 +9,20 @@ use super::acceptor::{ }; use super::error::AcceptorError; use super::handler::IntoHttpHandler; -use super::service::HttpService; +use super::service::{HttpService, StreamConfiguration}; use super::settings::{ServerSettings, ServiceConfig}; use super::KeepAlive; pub(crate) trait ServiceProvider { fn register( - &self, server: Server, lst: net::TcpListener, host: String, - addr: net::SocketAddr, keep_alive: KeepAlive, secure: bool, client_timeout: u64, + &self, + server: Server, + lst: net::TcpListener, + host: String, + addr: net::SocketAddr, + keep_alive: KeepAlive, + secure: bool, + client_timeout: u64, client_shutdown: u64, ) -> Server; } @@ -43,8 +49,13 @@ where } fn finish( - &self, host: String, addr: net::SocketAddr, keep_alive: KeepAlive, secure: bool, - client_timeout: u64, client_shutdown: u64, + &self, + host: String, + addr: net::SocketAddr, + keep_alive: KeepAlive, + secure: bool, + client_timeout: u64, + client_shutdown: u64, ) -> impl ServiceFactory { let factory = self.factory.clone(); let acceptor = self.acceptor.clone(); @@ -65,6 +76,7 @@ where acceptor.create(), )).map_err(|_| ()) .map_init_err(|_| ()) + .and_then(StreamConfiguration::new().nodelay(true)) .and_then( HttpService::new(settings) .map_init_err(|_| ()) @@ -76,6 +88,7 @@ where TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service)) .map_err(|_| ()) .map_init_err(|_| ()) + .and_then(StreamConfiguration::new().nodelay(true)) .and_then( HttpService::new(settings) .map_init_err(|_| ()) @@ -95,8 +108,14 @@ where H: IntoHttpHandler, { fn register( - &self, server: Server, lst: net::TcpListener, host: String, - addr: net::SocketAddr, keep_alive: KeepAlive, secure: bool, client_timeout: u64, + &self, + server: Server, + lst: net::TcpListener, + host: String, + addr: net::SocketAddr, + keep_alive: KeepAlive, + secure: bool, + client_timeout: u64, client_shutdown: u64, ) -> Server { server.listen2( diff --git a/src/server/service.rs b/src/server/service.rs index e3402e305..cd4b3d3fa 100644 --- a/src/server/service.rs +++ b/src/server/service.rs @@ -88,7 +88,7 @@ where Ok(Async::Ready(())) } - fn call(&mut self, req: Self::Request) -> Self::Future { + fn call(&mut self, mut req: Self::Request) -> Self::Future { HttpChannel::new(self.settings.clone(), req) } }