Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/body/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl Incoming {
/// Create a `Body` stream with an associated sender half.
///
/// Useful when wanting to stream chunks from another thread.
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[inline]
#[cfg(test)]
pub(crate) fn channel() -> (Sender, Incoming) {
Expand Down Expand Up @@ -460,9 +461,12 @@ mod tests {
use std::mem;
use std::task::Poll;

use super::{Body, DecodedLength, Incoming, Sender, SizeHint};
use super::{Body, Incoming, SizeHint};
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
use super::{DecodedLength, Sender};
use http_body_util::BodyExt;

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[test]
fn test_size_of() {
// These are mostly to help catch *accidentally* increasing
Expand Down Expand Up @@ -492,6 +496,7 @@ mod tests {
);
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[test]
fn size_hint() {
fn eq(body: Incoming, b: SizeHint, note: &str) {
Expand All @@ -511,6 +516,7 @@ mod tests {
);
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[cfg(not(miri))]
#[tokio::test]
async fn channel_abort() {
Expand All @@ -522,6 +528,7 @@ mod tests {
assert!(err.is_body_write_aborted(), "{:?}", err);
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[cfg(all(not(miri), feature = "http1"))]
#[tokio::test]
async fn channel_abort_when_buffer_is_full() {
Expand Down Expand Up @@ -556,6 +563,7 @@ mod tests {
assert_eq!(chunk2, "chunk 2");
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[cfg(not(miri))]
#[tokio::test]
async fn channel_empty() {
Expand All @@ -564,6 +572,7 @@ mod tests {
assert!(rx.frame().await.is_none());
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[test]
fn channel_ready() {
let (mut tx, _rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter = */ false);
Expand All @@ -573,6 +582,7 @@ mod tests {
assert!(tx_ready.poll().is_ready(), "tx is ready immediately");
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[test]
fn channel_wanter() {
let (mut tx, mut rx) =
Expand All @@ -595,6 +605,7 @@ mod tests {
);
}

#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
#[test]
fn channel_notices_closure() {
let (mut tx, rx) = Incoming::new_channel(DecodedLength::CHUNKED, /*wanter = */ true);
Expand Down
Loading