From 178e802642222a176c3bc5a702b96e60221acd04 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Wed, 16 Dec 2020 00:21:26 +0800 Subject: [PATCH] fix TestBuffer --- Cargo.toml | 2 +- actix-files/src/files.rs | 15 ++++++++------- actix-http/Cargo.toml | 1 - actix-http/src/client/connector.rs | 24 ++++++++++++------------ actix-http/src/client/pool.rs | 2 +- actix-http/src/test.rs | 4 +++- src/app.rs | 10 +++++----- src/config.rs | 12 ++++++------ src/handler.rs | 16 ++++++++-------- src/resource.rs | 22 +++++++++++----------- src/scope.rs | 22 +++++++++++----------- src/service.rs | 24 ++++++++++++------------ 12 files changed, 78 insertions(+), 76 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a3ad671b3..6d9fef657 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,7 +142,7 @@ actix-connect = { git = "https://github.com/fakeshadow/actix-net.git", branch = actix-utils = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } actix-codec = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } h2 = { git = "https://github.com/hyperium/h2.git" } -http = { git = "https://github.com/paolobarbolini/http.git", branch = "bytes06" } +http = { git = "https://github.com/fakeshadow/http.git" } [[bench]] name = "server" diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index a99b4699e..642579cd5 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -125,8 +125,9 @@ impl Files { /// Set custom directory renderer pub fn files_listing_renderer(mut self, f: F) -> Self where - for<'r, 's> F: Fn(&'r Directory, &'s HttpRequest) -> Result - + 'static, + for<'r, 's> F: + Fn(&'r Directory, &'s HttpRequest) -> Result + + 'static, { self.renderer = Rc::new(f); self @@ -200,11 +201,11 @@ impl Files { where F: IntoServiceFactory, U: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + > + 'static, { // create and configure default resource self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory( diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index fe3963aa2..7ea05dfcc 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -61,7 +61,6 @@ futures-channel = { version = "0.3.5", default-features = false } futures-core = { version = "0.3.5", default-features = false } futures-util = { version = "0.3.5", default-features = false, features = ["sink"] } fxhash = "0.2.1" - h2 = "0.3.0" http = "0.2.1" httparse = "1.3" diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index e1aed6382..09cbf5b0f 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -62,10 +62,10 @@ impl Connector<(), ()> { #[allow(clippy::new_ret_no_self, clippy::let_unit_value)] pub fn new() -> Connector< impl Service< - Request = TcpConnect, - Response = TcpConnection, - Error = actix_connect::ConnectError, - > + Clone, + Request = TcpConnect, + Response = TcpConnection, + Error = actix_connect::ConnectError, + > + Clone, TcpStream, > { Connector { @@ -117,10 +117,10 @@ impl Connector { where U1: AsyncRead + AsyncWrite + Unpin + fmt::Debug, T1: Service< - Request = TcpConnect, - Response = TcpConnection, - Error = actix_connect::ConnectError, - > + Clone, + Request = TcpConnect, + Response = TcpConnection, + Error = actix_connect::ConnectError, + > + Clone, { Connector { connector, @@ -135,10 +135,10 @@ impl Connector where U: AsyncRead + AsyncWrite + Unpin + fmt::Debug + 'static, T: Service< - Request = TcpConnect, - Response = TcpConnection, - Error = actix_connect::ConnectError, - > + Clone + Request = TcpConnect, + Response = TcpConnection, + Error = actix_connect::ConnectError, + > + Clone + 'static, { /// Connection timeout, i.e. max time to connect to remote host including dns name resolution. diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index f1e80eecf..59d1d4e29 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -337,7 +337,7 @@ where if let ConnectionType::H1(ref mut s) = io { match Pin::new(s).poll_read(cx, &mut read_buf) { Poll::Pending => (), - Poll::Ready(Ok(())) if read_buf.filled().len() > 0 => { + Poll::Ready(Ok(())) if !read_buf.filled().is_empty() => { if let Some(timeout) = self.config.disconnect_timeout { if let ConnectionType::H1(io) = io { actix_rt::spawn(CloseConnection::new( diff --git a/actix-http/src/test.rs b/actix-http/src/test.rs index 227823a0c..0b42946eb 100644 --- a/actix-http/src/test.rs +++ b/actix-http/src/test.rs @@ -247,7 +247,9 @@ impl AsyncRead for TestBuffer { _: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll> { - Poll::Ready(self.get_mut().read(buf.filled_mut()).map(|_| ())) + let dst = buf.initialize_unfilled(); + let res = self.get_mut().read(dst).map(|n| buf.advance(n)); + Poll::Ready(res) } } diff --git a/src/app.rs b/src/app.rs index 8dd86f7ec..e5e76b20c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -270,11 +270,11 @@ where where F: IntoServiceFactory, U: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + > + 'static, U::InitError: fmt::Debug, { // create and configure default resource diff --git a/src/config.rs b/src/config.rs index 01959daa1..3eea23ff0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -107,12 +107,12 @@ impl AppService { ) where F: IntoServiceFactory, S: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - InitError = (), - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + InitError = (), + > + 'static, { self.services.push(( rdef, diff --git a/src/handler.rs b/src/handler.rs index 669512ab3..aa015ea6b 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -164,10 +164,10 @@ impl Extract { impl ServiceFactory for Extract where S: Service< - Request = (T, HttpRequest), - Response = ServiceResponse, - Error = Infallible, - > + Clone, + Request = (T, HttpRequest), + Response = ServiceResponse, + Error = Infallible, + > + Clone, { type Config = (); type Request = ServiceRequest; @@ -193,10 +193,10 @@ pub struct ExtractService { impl Service for ExtractService where S: Service< - Request = (T, HttpRequest), - Response = ServiceResponse, - Error = Infallible, - > + Clone, + Request = (T, HttpRequest), + Response = ServiceResponse, + Error = Infallible, + > + Clone, { type Request = ServiceRequest; type Response = ServiceResponse; diff --git a/src/resource.rs b/src/resource.rs index 501e40174..72617f21d 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -347,11 +347,11 @@ where where F: IntoServiceFactory, U: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + > + 'static, U::InitError: fmt::Debug, { // create and configure default resource @@ -368,12 +368,12 @@ where impl HttpServiceFactory for Resource where T: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - InitError = (), - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + InitError = (), + > + 'static, { fn register(mut self, config: &mut AppService) { let guards = if self.guards.is_empty() { diff --git a/src/scope.rs b/src/scope.rs index 681d142be..013b54756 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -287,11 +287,11 @@ where where F: IntoServiceFactory, U: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + > + 'static, U::InitError: fmt::Debug, { // create and configure default resource @@ -410,12 +410,12 @@ where impl HttpServiceFactory for Scope where T: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - InitError = (), - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + InitError = (), + > + 'static, { fn register(mut self, config: &mut AppService) { // update default resource if needed diff --git a/src/service.rs b/src/service.rs index 189ba5554..11865fbcc 100644 --- a/src/service.rs +++ b/src/service.rs @@ -488,12 +488,12 @@ impl WebService { where F: IntoServiceFactory, T: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - InitError = (), - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + InitError = (), + > + 'static, { WebServiceImpl { srv: service.into_factory(), @@ -514,12 +514,12 @@ struct WebServiceImpl { impl HttpServiceFactory for WebServiceImpl where T: ServiceFactory< - Config = (), - Request = ServiceRequest, - Response = ServiceResponse, - Error = Error, - InitError = (), - > + 'static, + Config = (), + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + InitError = (), + > + 'static, { fn register(mut self, config: &mut AppService) { let guards = if self.guards.is_empty() {