Skip to content

Commit 3641ea7

Browse files
authored
deps: make hyper optional dependency (#1133)
1 parent f4d8e08 commit 3641ea7

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ futures-util = { version = "0.3", default-features = false, features = ["sink"]
2929
futures-channel = { version = "0.3.17", features = ["sink"]}
3030
headers = "0.4"
3131
http = "1"
32+
http-body = "1"
3233
http-body-util = "0.1.2"
33-
hyper = { version = "1", features = ["server", "http1", "http2"] }
34+
hyper = { version = "1", optional = true }
3435
hyper-util = { version = "0.1.12", features = ["server", "server-graceful", "server-auto", "http1", "http2", "service", "tokio"], optional = true }
3536
log = "0.4"
3637
mime = "0.3"
@@ -40,7 +41,7 @@ scoped-tls = "1.0"
4041
serde = "1.0"
4142
serde_json = "1.0"
4243
serde_urlencoded = "0.7.1"
43-
tokio = { version = "1.0", features = ["fs", "sync", "time"] }
44+
tokio = { version = "1.0", features = ["io-util", "fs", "sync", "time"] }
4445
tokio-util = { version = "0.7.1", features = ["io"] }
4546
tracing = { version = "0.1.21", default-features = false, features = ["log", "std"] }
4647
tower-service = "0.3"
@@ -62,9 +63,9 @@ tokio-stream = { version = "0.1.1", features = ["net"] }
6263
[features]
6364
default = []
6465
multipart = ["dep:multer"]
65-
websocket = ["hyper/client", "hyper/http1", "dep:tokio-tungstenite", "hyper-util/tokio"]
66-
server = ["hyper/server", "hyper/http1", "hyper/http2", "dep:hyper-util", "tokio/net"]
67-
test = ["server"]
66+
websocket = ["dep:hyper", "dep:tokio-tungstenite", "hyper-util/tokio"]
67+
server = ["dep:hyper", "dep:hyper-util", "tokio/net"]
68+
test = ["server", "hyper/client", "hyper/http1"]
6869
# tls might come back, uncertain
6970
#tls = ["tokio-rustls", "rustls-pemfile"]
7071

src/bodyt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::task::{Context, Poll};
44
use bytes::Buf;
55
use bytes::Bytes;
66
use futures_util::StreamExt;
7+
use http_body::Frame;
78
use http_body_util::{combinators::BoxBody, BodyExt};
8-
use hyper::body::Frame;
99

1010
#[derive(Debug)]
1111
pub struct Body(BoxBody<Bytes, crate::Error>);
@@ -16,7 +16,7 @@ impl Default for Body {
1616
}
1717
}
1818

19-
impl hyper::body::Body for Body {
19+
impl http_body::Body for Body {
2020
type Data = Bytes;
2121
type Error = crate::Error;
2222

@@ -31,7 +31,7 @@ impl hyper::body::Body for Body {
3131
self.0.is_end_stream()
3232
}
3333

34-
fn size_hint(&self) -> hyper::body::SizeHint {
34+
fn size_hint(&self) -> http_body::SizeHint {
3535
self.0.size_hint()
3636
}
3737
}
@@ -47,7 +47,7 @@ impl Body {
4747

4848
pub(crate) fn wrap<B>(body: B) -> Self
4949
where
50-
B: hyper::body::Body + Send + Sync + 'static,
50+
B: http_body::Body + Send + Sync + 'static,
5151
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
5252
{
5353
let body = body

src/filter/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
F: Filter,
7676
<F::Future as TryFuture>::Ok: Reply,
7777
<F::Future as TryFuture>::Error: IsReject,
78-
B: hyper::body::Body + Send + Sync + 'static,
78+
B: http_body::Body + Send + Sync + 'static,
7979
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
8080
{
8181
type Response = Response;

src/filters/compression.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use async_compression::tokio::bufread::BrotliEncoder;
99
use async_compression::tokio::bufread::{DeflateEncoder, GzipEncoder};
1010

1111
use crate::bodyt::Body;
12-
use http::header::HeaderValue;
13-
use hyper::header::{CONTENT_ENCODING, CONTENT_LENGTH};
12+
use http::header::{HeaderValue, CONTENT_ENCODING, CONTENT_LENGTH};
1413
use tokio_util::io::{ReaderStream, StreamReader};
1514

1615
use crate::filter::{Filter, WrapSealed};

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ pub use self::server::Server;
171171
pub use self::service::service;
172172
#[doc(hidden)]
173173
pub use http;
174+
#[cfg(any(feature = "server", feature = "websocket"))]
174175
#[doc(hidden)]
175176
pub use hyper;
176177

0 commit comments

Comments
 (0)