fix TestBuffer

This commit is contained in:
fakeshadow 2020-12-16 00:21:26 +08:00
parent 9e6037e565
commit 178e802642
12 changed files with 78 additions and 76 deletions

View File

@ -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-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" } actix-codec = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" }
h2 = { git = "https://github.com/hyperium/h2.git" } 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]] [[bench]]
name = "server" name = "server"

View File

@ -125,8 +125,9 @@ impl Files {
/// Set custom directory renderer /// Set custom directory renderer
pub fn files_listing_renderer<F>(mut self, f: F) -> Self pub fn files_listing_renderer<F>(mut self, f: F) -> Self
where where
for<'r, 's> F: Fn(&'r Directory, &'s HttpRequest) -> Result<ServiceResponse, io::Error> for<'r, 's> F:
+ 'static, Fn(&'r Directory, &'s HttpRequest) -> Result<ServiceResponse, io::Error>
+ 'static,
{ {
self.renderer = Rc::new(f); self.renderer = Rc::new(f);
self self
@ -200,11 +201,11 @@ impl Files {
where where
F: IntoServiceFactory<U>, F: IntoServiceFactory<U>,
U: ServiceFactory< U: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
> + 'static, > + 'static,
{ {
// create and configure default resource // create and configure default resource
self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory( self.default = Rc::new(RefCell::new(Some(Rc::new(boxed::factory(

View File

@ -61,7 +61,6 @@ futures-channel = { version = "0.3.5", default-features = false }
futures-core = { 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"] } futures-util = { version = "0.3.5", default-features = false, features = ["sink"] }
fxhash = "0.2.1" fxhash = "0.2.1"
h2 = "0.3.0" h2 = "0.3.0"
http = "0.2.1" http = "0.2.1"
httparse = "1.3" httparse = "1.3"

View File

@ -62,10 +62,10 @@ impl Connector<(), ()> {
#[allow(clippy::new_ret_no_self, clippy::let_unit_value)] #[allow(clippy::new_ret_no_self, clippy::let_unit_value)]
pub fn new() -> Connector< pub fn new() -> Connector<
impl Service< impl Service<
Request = TcpConnect<Uri>, Request = TcpConnect<Uri>,
Response = TcpConnection<Uri, TcpStream>, Response = TcpConnection<Uri, TcpStream>,
Error = actix_connect::ConnectError, Error = actix_connect::ConnectError,
> + Clone, > + Clone,
TcpStream, TcpStream,
> { > {
Connector { Connector {
@ -117,10 +117,10 @@ impl<T, U> Connector<T, U> {
where where
U1: AsyncRead + AsyncWrite + Unpin + fmt::Debug, U1: AsyncRead + AsyncWrite + Unpin + fmt::Debug,
T1: Service< T1: Service<
Request = TcpConnect<Uri>, Request = TcpConnect<Uri>,
Response = TcpConnection<Uri, U1>, Response = TcpConnection<Uri, U1>,
Error = actix_connect::ConnectError, Error = actix_connect::ConnectError,
> + Clone, > + Clone,
{ {
Connector { Connector {
connector, connector,
@ -135,10 +135,10 @@ impl<T, U> Connector<T, U>
where where
U: AsyncRead + AsyncWrite + Unpin + fmt::Debug + 'static, U: AsyncRead + AsyncWrite + Unpin + fmt::Debug + 'static,
T: Service< T: Service<
Request = TcpConnect<Uri>, Request = TcpConnect<Uri>,
Response = TcpConnection<Uri, U>, Response = TcpConnection<Uri, U>,
Error = actix_connect::ConnectError, Error = actix_connect::ConnectError,
> + Clone > + Clone
+ 'static, + 'static,
{ {
/// Connection timeout, i.e. max time to connect to remote host including dns name resolution. /// Connection timeout, i.e. max time to connect to remote host including dns name resolution.

View File

@ -337,7 +337,7 @@ where
if let ConnectionType::H1(ref mut s) = io { if let ConnectionType::H1(ref mut s) = io {
match Pin::new(s).poll_read(cx, &mut read_buf) { match Pin::new(s).poll_read(cx, &mut read_buf) {
Poll::Pending => (), 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 Some(timeout) = self.config.disconnect_timeout {
if let ConnectionType::H1(io) = io { if let ConnectionType::H1(io) = io {
actix_rt::spawn(CloseConnection::new( actix_rt::spawn(CloseConnection::new(

View File

@ -247,7 +247,9 @@ impl AsyncRead for TestBuffer {
_: &mut Context<'_>, _: &mut Context<'_>,
buf: &mut ReadBuf<'_>, buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> { ) -> Poll<io::Result<()>> {
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)
} }
} }

View File

@ -270,11 +270,11 @@ where
where where
F: IntoServiceFactory<U>, F: IntoServiceFactory<U>,
U: ServiceFactory< U: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
> + 'static, > + 'static,
U::InitError: fmt::Debug, U::InitError: fmt::Debug,
{ {
// create and configure default resource // create and configure default resource

View File

@ -107,12 +107,12 @@ impl AppService {
) where ) where
F: IntoServiceFactory<S>, F: IntoServiceFactory<S>,
S: ServiceFactory< S: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
InitError = (), InitError = (),
> + 'static, > + 'static,
{ {
self.services.push(( self.services.push((
rdef, rdef,

View File

@ -164,10 +164,10 @@ impl<T: FromRequest, S> Extract<T, S> {
impl<T: FromRequest, S> ServiceFactory for Extract<T, S> impl<T: FromRequest, S> ServiceFactory for Extract<T, S>
where where
S: Service< S: Service<
Request = (T, HttpRequest), Request = (T, HttpRequest),
Response = ServiceResponse, Response = ServiceResponse,
Error = Infallible, Error = Infallible,
> + Clone, > + Clone,
{ {
type Config = (); type Config = ();
type Request = ServiceRequest; type Request = ServiceRequest;
@ -193,10 +193,10 @@ pub struct ExtractService<T: FromRequest, S> {
impl<T: FromRequest, S> Service for ExtractService<T, S> impl<T: FromRequest, S> Service for ExtractService<T, S>
where where
S: Service< S: Service<
Request = (T, HttpRequest), Request = (T, HttpRequest),
Response = ServiceResponse, Response = ServiceResponse,
Error = Infallible, Error = Infallible,
> + Clone, > + Clone,
{ {
type Request = ServiceRequest; type Request = ServiceRequest;
type Response = ServiceResponse; type Response = ServiceResponse;

View File

@ -347,11 +347,11 @@ where
where where
F: IntoServiceFactory<U>, F: IntoServiceFactory<U>,
U: ServiceFactory< U: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
> + 'static, > + 'static,
U::InitError: fmt::Debug, U::InitError: fmt::Debug,
{ {
// create and configure default resource // create and configure default resource
@ -368,12 +368,12 @@ where
impl<T> HttpServiceFactory for Resource<T> impl<T> HttpServiceFactory for Resource<T>
where where
T: ServiceFactory< T: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
InitError = (), InitError = (),
> + 'static, > + 'static,
{ {
fn register(mut self, config: &mut AppService) { fn register(mut self, config: &mut AppService) {
let guards = if self.guards.is_empty() { let guards = if self.guards.is_empty() {

View File

@ -287,11 +287,11 @@ where
where where
F: IntoServiceFactory<U>, F: IntoServiceFactory<U>,
U: ServiceFactory< U: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
> + 'static, > + 'static,
U::InitError: fmt::Debug, U::InitError: fmt::Debug,
{ {
// create and configure default resource // create and configure default resource
@ -410,12 +410,12 @@ where
impl<T> HttpServiceFactory for Scope<T> impl<T> HttpServiceFactory for Scope<T>
where where
T: ServiceFactory< T: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
InitError = (), InitError = (),
> + 'static, > + 'static,
{ {
fn register(mut self, config: &mut AppService) { fn register(mut self, config: &mut AppService) {
// update default resource if needed // update default resource if needed

View File

@ -488,12 +488,12 @@ impl WebService {
where where
F: IntoServiceFactory<T>, F: IntoServiceFactory<T>,
T: ServiceFactory< T: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
InitError = (), InitError = (),
> + 'static, > + 'static,
{ {
WebServiceImpl { WebServiceImpl {
srv: service.into_factory(), srv: service.into_factory(),
@ -514,12 +514,12 @@ struct WebServiceImpl<T> {
impl<T> HttpServiceFactory for WebServiceImpl<T> impl<T> HttpServiceFactory for WebServiceImpl<T>
where where
T: ServiceFactory< T: ServiceFactory<
Config = (), Config = (),
Request = ServiceRequest, Request = ServiceRequest,
Response = ServiceResponse, Response = ServiceResponse,
Error = Error, Error = Error,
InitError = (), InitError = (),
> + 'static, > + 'static,
{ {
fn register(mut self, config: &mut AppService) { fn register(mut self, config: &mut AppService) {
let guards = if self.guards.is_empty() { let guards = if self.guards.is_empty() {