diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml index 953f6635..39b09f86 100644 --- a/core/http/Cargo.toml +++ b/core/http/Cargo.toml @@ -22,16 +22,17 @@ private-cookies = ["cookie/private", "cookie/key-expansion"] [dependencies] smallvec = "1.0" percent-encoding = "1" -hyper = { version = "=0.13.0-alpha.1", default-features = false } +# TODO.async: stop using stream-unstable +hyper = { version = "=0.13.0-alpha.2", default-features = false, features = ["unstable-stream"] } http = "0.1.17" mime = "0.3.13" time = "0.2.11" indexmap = "1.0" state = "0.4" -tokio-rustls = { version = "0.12.0-alpha.2", optional = true } -tokio-io = "=0.2.0-alpha.4" -tokio-net = "=0.2.0-alpha.4" -tokio-timer = "=0.3.0-alpha.4" +tokio-rustls = { version = "0.12.0-alpha.3", optional = true } +tokio-io = "=0.2.0-alpha.5" +tokio-net = "=0.2.0-alpha.5" +tokio-timer = "=0.3.0-alpha.5" cookie = { version = "0.14.0", features = ["percent-encode"] } pear = "0.1" unicode-xid = "0.2" diff --git a/core/http/src/listener.rs b/core/http/src/listener.rs index f4b13d1e..758b4218 100644 --- a/core/http/src/listener.rs +++ b/core/http/src/listener.rs @@ -6,8 +6,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use std::time::{Duration, Instant}; -use futures::ready; -use futures::stream::Stream; +use hyper::server::accept::Accept; use log::{debug, error}; @@ -35,8 +34,8 @@ pub trait Connection: AsyncRead + AsyncWrite { /// This is a genericized version of hyper's AddrIncoming that is intended to be /// usable with listeners other than a plain TCP stream, e.g. TLS and/or Unix -/// sockets. It does this by briding the `Listener` trait to what hyper wants (a -/// Stream of AsyncRead+AsyncWrite). This type is internal to Rocket. +/// sockets. It does this by bridging the `Listener` trait to what hyper wants +/// (an Accept). This type is internal to Rocket. #[must_use = "streams do nothing unless polled"] pub struct Incoming { listener: L, @@ -73,7 +72,7 @@ impl Incoming { self.sleep_on_errors = val; } - fn poll_next_(&mut self, cx: &mut Context<'_>) -> Poll> { + fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll> { // Check if a previous delay is active that was set by IO errors. if let Some(ref mut delay) = self.pending_error_delay { match Pin::new(delay).poll(cx) { @@ -124,11 +123,12 @@ impl Incoming { } } -impl Stream for Incoming { - type Item = io::Result; +impl Accept for Incoming { + type Conn = L::Connection; + type Error = io::Error; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let result = ready!(self.poll_next_(cx)); + fn poll_accept(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>> { + let result = futures::ready!(self.poll_next(cx)); Poll::Ready(Some(result)) } } diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index 67a03ff5..026950a8 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -29,7 +29,7 @@ rocket_codegen = { version = "0.5.0-dev", path = "../codegen" } rocket_http = { version = "0.5.0-dev", path = "../http" } futures-preview = "0.3.0-alpha.18" futures-tokio-compat = { git = "https://github.com/Nemo157/futures-tokio-compat", rev = "8a93702" } -tokio = "=0.2.0-alpha.4" +tokio = "=0.2.0-alpha.5" yansi = "0.5" log = { version = "0.4", features = ["std"] } toml = "0.4.7"