diff --git a/Cargo.toml b/Cargo.toml index f8dbf1ed..23a36331 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,9 @@ futures-util = { version = "0.3", default-features = false, features = ["sink"] futures-channel = { version = "0.3.17", features = ["sink"]} headers = "0.4" http = "1" +http-body = "1" http-body-util = "0.1.2" -hyper = { version = "1", features = ["server", "http1", "http2"] } +hyper = { version = "1", optional = true } hyper-util = { version = "0.1.12", features = ["server", "server-graceful", "server-auto", "http1", "http2", "service", "tokio"], optional = true } log = "0.4" mime = "0.3" @@ -40,7 +41,7 @@ scoped-tls = "1.0" serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7.1" -tokio = { version = "1.0", features = ["fs", "sync", "time"] } +tokio = { version = "1.0", features = ["io-util", "fs", "sync", "time"] } tokio-util = { version = "0.7.1", features = ["io"] } tracing = { version = "0.1.21", default-features = false, features = ["log", "std"] } tower-service = "0.3" @@ -62,9 +63,9 @@ tokio-stream = { version = "0.1.1", features = ["net"] } [features] default = [] multipart = ["dep:multer"] -websocket = ["hyper/client", "hyper/http1", "dep:tokio-tungstenite", "hyper-util/tokio"] -server = ["hyper/server", "hyper/http1", "hyper/http2", "dep:hyper-util", "tokio/net"] -test = ["server"] +websocket = ["dep:hyper", "dep:tokio-tungstenite", "hyper-util/tokio"] +server = ["dep:hyper", "dep:hyper-util", "tokio/net"] +test = ["server", "hyper/client", "hyper/http1"] # tls might come back, uncertain #tls = ["tokio-rustls", "rustls-pemfile"] diff --git a/src/bodyt.rs b/src/bodyt.rs index b6c04fb8..36775404 100644 --- a/src/bodyt.rs +++ b/src/bodyt.rs @@ -4,8 +4,8 @@ use std::task::{Context, Poll}; use bytes::Buf; use bytes::Bytes; use futures_util::StreamExt; +use http_body::Frame; use http_body_util::{combinators::BoxBody, BodyExt}; -use hyper::body::Frame; #[derive(Debug)] pub struct Body(BoxBody); @@ -16,7 +16,7 @@ impl Default for Body { } } -impl hyper::body::Body for Body { +impl http_body::Body for Body { type Data = Bytes; type Error = crate::Error; @@ -31,7 +31,7 @@ impl hyper::body::Body for Body { self.0.is_end_stream() } - fn size_hint(&self) -> hyper::body::SizeHint { + fn size_hint(&self) -> http_body::SizeHint { self.0.size_hint() } } @@ -47,7 +47,7 @@ impl Body { pub(crate) fn wrap(body: B) -> Self where - B: hyper::body::Body + Send + Sync + 'static, + B: http_body::Body + Send + Sync + 'static, B::Error: Into>, { let body = body diff --git a/src/filter/service.rs b/src/filter/service.rs index 75a0682f..61b33ec5 100644 --- a/src/filter/service.rs +++ b/src/filter/service.rs @@ -75,7 +75,7 @@ where F: Filter, ::Ok: Reply, ::Error: IsReject, - B: hyper::body::Body + Send + Sync + 'static, + B: http_body::Body + Send + Sync + 'static, B::Error: Into>, { type Response = Response; diff --git a/src/filters/compression.rs b/src/filters/compression.rs index 90d95ca1..f042836d 100644 --- a/src/filters/compression.rs +++ b/src/filters/compression.rs @@ -9,8 +9,7 @@ use async_compression::tokio::bufread::BrotliEncoder; use async_compression::tokio::bufread::{DeflateEncoder, GzipEncoder}; use crate::bodyt::Body; -use http::header::HeaderValue; -use hyper::header::{CONTENT_ENCODING, CONTENT_LENGTH}; +use http::header::{HeaderValue, CONTENT_ENCODING, CONTENT_LENGTH}; use tokio_util::io::{ReaderStream, StreamReader}; use crate::filter::{Filter, WrapSealed}; diff --git a/src/lib.rs b/src/lib.rs index cd3f721e..7cc85641 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,6 +171,7 @@ pub use self::server::Server; pub use self::service::service; #[doc(hidden)] pub use http; +#[cfg(any(feature = "server", feature = "websocket"))] #[doc(hidden)] pub use hyper;