Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Client<(), ()> {
/// # Example
///
/// ```
/// # #[cfg(feature = "tokio")]
/// # #[cfg(all(feature = "tokio", feature = "http2"))]
/// # fn run () {
/// use std::time::Duration;
/// use hyper_util::client::legacy::Client;
Expand Down Expand Up @@ -994,7 +994,7 @@ fn is_schema_secure(uri: &Uri) -> bool {
/// # Example
///
/// ```
/// # #[cfg(feature = "tokio")]
/// # #[cfg(all(feature = "tokio", feature = "http2"))]
/// # fn run () {
/// use std::time::Duration;
/// use hyper_util::client::legacy::Client;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ impl Builder {
/// # Example
///
/// ```
/// # #[cfg(feature = "tokio")]
/// # #[cfg(all(feature = "tokio", feature = "http2"))]
/// # fn run () {
/// use std::time::Duration;
/// use hyper_util::client::legacy::Client;
Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/connect/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct CaptureConnection {
/// connection is available.
///
/// ```rust
/// # #[cfg(feature = "tokio")]
/// # #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
/// # async fn example() {
/// use hyper_util::client::legacy::connect::capture_connection;
/// use hyper_util::client::legacy::Client;
Expand Down
22 changes: 22 additions & 0 deletions tests/legacy_client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(all(feature = "client-legacy", any(feature = "http1", feature = "http2")))]

mod test_utils;

use std::io::{Read, Write};
Expand Down Expand Up @@ -38,6 +40,7 @@ fn s(buf: &[u8]) -> &str {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn drop_body_before_eof_closes_connection() {
// https://github.com/hyperium/hyper/issues/1353
Expand Down Expand Up @@ -86,6 +89,7 @@ fn drop_body_before_eof_closes_connection() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn drop_client_closes_idle_connections() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -150,6 +154,7 @@ async fn drop_client_closes_idle_connections() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn drop_response_future_closes_in_progress_connection() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -199,6 +204,7 @@ async fn drop_response_future_closes_in_progress_connection() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn drop_response_body_closes_in_progress_connection() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -255,6 +261,7 @@ async fn drop_response_body_closes_in_progress_connection() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn no_keep_alive_closes_connection() {
// https://github.com/hyperium/hyper/issues/1383
Expand Down Expand Up @@ -308,6 +315,7 @@ async fn no_keep_alive_closes_connection() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn socket_disconnect_closes_idle_conn() {
// notably when keep-alive is enabled
Expand Down Expand Up @@ -378,6 +386,7 @@ fn connect_call_is_lazy() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn client_keep_alive_0() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -445,6 +454,7 @@ fn client_keep_alive_0() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn client_keep_alive_extra_body() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -508,6 +518,7 @@ fn client_keep_alive_extra_body() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn client_keep_alive_when_response_before_request_body_ends() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -577,6 +588,7 @@ async fn client_keep_alive_when_response_before_request_body_ends() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[tokio::test]
async fn client_keep_alive_eager_when_chunked() {
// If a response body has been read to completion, with completion
Expand Down Expand Up @@ -663,6 +675,7 @@ async fn client_keep_alive_eager_when_chunked() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn connect_proxy_sends_absolute_uri() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -700,6 +713,7 @@ fn connect_proxy_sends_absolute_uri() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn connect_proxy_http_connect_sends_authority_form() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -738,6 +752,7 @@ fn connect_proxy_http_connect_sends_authority_form() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn client_upgrade() {
use tokio::io::{AsyncReadExt, AsyncWriteExt};
Expand Down Expand Up @@ -800,6 +815,7 @@ fn client_upgrade() {
}

#[cfg(not(miri))]
#[cfg(feature = "server")]
#[test]
fn client_http2_upgrade() {
use http::{Method, Response, Version};
Expand Down Expand Up @@ -882,6 +898,7 @@ fn client_http2_upgrade() {
}

#[cfg(not(miri))]
#[cfg(feature = "http2")]
#[test]
fn alpn_h2() {
use http::Response;
Expand Down Expand Up @@ -950,6 +967,7 @@ fn alpn_h2() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn capture_connection_on_client() {
let _ = pretty_env_logger::try_init();
Expand Down Expand Up @@ -981,6 +999,7 @@ fn capture_connection_on_client() {
}

#[cfg(not(miri))]
#[cfg(feature = "http1")]
#[test]
fn connection_poisoning() {
use std::sync::atomic::AtomicUsize;
Expand Down Expand Up @@ -1327,6 +1346,7 @@ impl tower_service::Service<hyper::Uri> for MockConnector {
// Test for connection error propagation with PR #184.
// Simulates a connection failure by setting failed=true and returning a custom io::Error.
// Verifies the error propagates through hyper’s client as a hyper::Error(Io, ...).
#[cfg(feature = "http1")]
#[tokio::test]
async fn test_connection_error_propagation_pr184() {
// Define the error message for the simulated connection failure.
Expand Down Expand Up @@ -1384,6 +1404,7 @@ async fn test_connection_error_propagation_pr184() {
// Simulates a connection that returns EOF immediately, causing hyper’s HTTP/1.1 parser
// to fail with IncompleteMessage due to no response data.
// Uses MockConnector with conn_error=None to keep failed=false, ensuring EOF behavior.
#[cfg(feature = "http1")]
#[tokio::test]
async fn test_incomplete_message_error_pr184() {
// Create an empty IoBuilder to simulate a connection with no data.
Expand Down Expand Up @@ -1443,6 +1464,7 @@ async fn test_incomplete_message_error_pr184() {
// Test for a successful HTTP/1.1 connection using a mock connector.
// Simulates a server that accepts a request and responds with a 200 OK.
// Verifies the client correctly sends the request and receives the response.
#[cfg(feature = "http1")]
#[tokio::test]
async fn test_successful_connection() {
// Define the expected server response: a valid HTTP/1.1 200 OK with no body.
Expand Down
2 changes: 2 additions & 0 deletions tests/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(all(feature = "client-legacy", feature = "client-proxy"))]

use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tower_service::Service;
Expand Down
Loading