Skip to content

Commit

Permalink
move behind stream feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fredr committed Oct 18, 2021
1 parent 983cbff commit faf6d34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ blocking = ["futures-util/io", "tokio/rt-multi-thread", "tokio/sync"]

cookies = ["cookie_crate", "cookie_store", "time"]

gzip = ["async-compression", "async-compression/gzip"]
gzip = ["async-compression", "async-compression/gzip", "tokio-util"]

brotli = ["async-compression", "async-compression/brotli"]
brotli = ["async-compression", "async-compression/brotli", "tokio-util"]

deflate = ["async-compression", "async-compression/zlib"]
deflate = ["async-compression", "async-compression/zlib", "tokio-util"]

json = ["serde_json"]

multipart = ["mime_guess"]

trust-dns = ["trust-dns-resolver"]

stream = []
stream = ["tokio-util"]

socks = ["tokio-socks"]

Expand Down Expand Up @@ -101,7 +101,6 @@ log = "0.4"
mime = "0.3.16"
percent-encoding = "2.1"
tokio = { version = "1.0", default-features = false, features = ["net", "time", "fs"] }
tokio-util = { version = "0.6.0", default-features = false, features = ["codec", "io"] }
pin-project-lite = "0.2.0"
ipnet = "2.3"

Expand All @@ -126,6 +125,7 @@ time = { version = "0.2.11", optional = true }

## compression
async-compression = { version = "0.3.7", default-features = false, features = ["tokio"], optional = true }
tokio-util = { version = "0.6.0", default-features = false, features = ["codec", "io"], optional = true }

## socks
tokio-socks = { version = "0.5.1", optional = true }
Expand Down
5 changes: 4 additions & 1 deletion src/async_impl/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use bytes::Bytes;
use futures_core::Stream;
use http_body::Body as HttpBody;
use pin_project_lite::pin_project;
#[cfg(feature = "stream")]
use tokio::fs::File;
use tokio::time::Sleep;
#[cfg(feature = "stream")]
use tokio_util::io::ReaderStream;

/// An asynchronous request body.
Expand Down Expand Up @@ -210,10 +212,11 @@ impl From<&'static str> for Body {
}
}

#[cfg(feature = "stream")]
impl From<File> for Body {
#[inline]
fn from(file: File) -> Body {
Body::stream(ReaderStream::new(file))
Body::wrap_stream(ReaderStream::new(file))
}
}

Expand Down

0 comments on commit faf6d34

Please sign in to comment.