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-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"

View File

@ -125,7 +125,8 @@ impl Files {
/// Set custom directory renderer
pub fn files_listing_renderer<F>(mut self, f: F) -> Self
where
for<'r, 's> F: Fn(&'r Directory, &'s HttpRequest) -> Result<ServiceResponse, io::Error>
for<'r, 's> F:
Fn(&'r Directory, &'s HttpRequest) -> Result<ServiceResponse, io::Error>
+ 'static,
{
self.renderer = Rc::new(f);

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-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"

View File

@ -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(

View File

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