|
| 1 | +#![cfg(all(feature = "client-legacy", any(feature = "http1", feature = "http2")))] |
| 2 | + |
1 | 3 | mod test_utils; |
2 | 4 |
|
3 | 5 | use std::io::{Read, Write}; |
@@ -38,6 +40,7 @@ fn s(buf: &[u8]) -> &str { |
38 | 40 | } |
39 | 41 |
|
40 | 42 | #[cfg(not(miri))] |
| 43 | +#[cfg(feature = "http1")] |
41 | 44 | #[test] |
42 | 45 | fn drop_body_before_eof_closes_connection() { |
43 | 46 | // https://github.com/hyperium/hyper/issues/1353 |
@@ -86,6 +89,7 @@ fn drop_body_before_eof_closes_connection() { |
86 | 89 | } |
87 | 90 |
|
88 | 91 | #[cfg(not(miri))] |
| 92 | +#[cfg(feature = "http1")] |
89 | 93 | #[tokio::test] |
90 | 94 | async fn drop_client_closes_idle_connections() { |
91 | 95 | let _ = pretty_env_logger::try_init(); |
@@ -150,6 +154,7 @@ async fn drop_client_closes_idle_connections() { |
150 | 154 | } |
151 | 155 |
|
152 | 156 | #[cfg(not(miri))] |
| 157 | +#[cfg(feature = "http1")] |
153 | 158 | #[tokio::test] |
154 | 159 | async fn drop_response_future_closes_in_progress_connection() { |
155 | 160 | let _ = pretty_env_logger::try_init(); |
@@ -199,6 +204,7 @@ async fn drop_response_future_closes_in_progress_connection() { |
199 | 204 | } |
200 | 205 |
|
201 | 206 | #[cfg(not(miri))] |
| 207 | +#[cfg(feature = "http1")] |
202 | 208 | #[tokio::test] |
203 | 209 | async fn drop_response_body_closes_in_progress_connection() { |
204 | 210 | let _ = pretty_env_logger::try_init(); |
@@ -255,6 +261,7 @@ async fn drop_response_body_closes_in_progress_connection() { |
255 | 261 | } |
256 | 262 |
|
257 | 263 | #[cfg(not(miri))] |
| 264 | +#[cfg(feature = "http1")] |
258 | 265 | #[tokio::test] |
259 | 266 | async fn no_keep_alive_closes_connection() { |
260 | 267 | // https://github.com/hyperium/hyper/issues/1383 |
@@ -308,6 +315,7 @@ async fn no_keep_alive_closes_connection() { |
308 | 315 | } |
309 | 316 |
|
310 | 317 | #[cfg(not(miri))] |
| 318 | +#[cfg(feature = "http1")] |
311 | 319 | #[tokio::test] |
312 | 320 | async fn socket_disconnect_closes_idle_conn() { |
313 | 321 | // notably when keep-alive is enabled |
@@ -378,6 +386,7 @@ fn connect_call_is_lazy() { |
378 | 386 | } |
379 | 387 |
|
380 | 388 | #[cfg(not(miri))] |
| 389 | +#[cfg(feature = "http1")] |
381 | 390 | #[test] |
382 | 391 | fn client_keep_alive_0() { |
383 | 392 | let _ = pretty_env_logger::try_init(); |
@@ -445,6 +454,7 @@ fn client_keep_alive_0() { |
445 | 454 | } |
446 | 455 |
|
447 | 456 | #[cfg(not(miri))] |
| 457 | +#[cfg(feature = "http1")] |
448 | 458 | #[test] |
449 | 459 | fn client_keep_alive_extra_body() { |
450 | 460 | let _ = pretty_env_logger::try_init(); |
@@ -508,6 +518,7 @@ fn client_keep_alive_extra_body() { |
508 | 518 | } |
509 | 519 |
|
510 | 520 | #[cfg(not(miri))] |
| 521 | +#[cfg(feature = "http1")] |
511 | 522 | #[tokio::test] |
512 | 523 | async fn client_keep_alive_when_response_before_request_body_ends() { |
513 | 524 | let _ = pretty_env_logger::try_init(); |
@@ -577,6 +588,7 @@ async fn client_keep_alive_when_response_before_request_body_ends() { |
577 | 588 | } |
578 | 589 |
|
579 | 590 | #[cfg(not(miri))] |
| 591 | +#[cfg(feature = "http1")] |
580 | 592 | #[tokio::test] |
581 | 593 | async fn client_keep_alive_eager_when_chunked() { |
582 | 594 | // If a response body has been read to completion, with completion |
@@ -663,6 +675,7 @@ async fn client_keep_alive_eager_when_chunked() { |
663 | 675 | } |
664 | 676 |
|
665 | 677 | #[cfg(not(miri))] |
| 678 | +#[cfg(feature = "http1")] |
666 | 679 | #[test] |
667 | 680 | fn connect_proxy_sends_absolute_uri() { |
668 | 681 | let _ = pretty_env_logger::try_init(); |
@@ -700,6 +713,7 @@ fn connect_proxy_sends_absolute_uri() { |
700 | 713 | } |
701 | 714 |
|
702 | 715 | #[cfg(not(miri))] |
| 716 | +#[cfg(feature = "http1")] |
703 | 717 | #[test] |
704 | 718 | fn connect_proxy_http_connect_sends_authority_form() { |
705 | 719 | let _ = pretty_env_logger::try_init(); |
@@ -738,6 +752,7 @@ fn connect_proxy_http_connect_sends_authority_form() { |
738 | 752 | } |
739 | 753 |
|
740 | 754 | #[cfg(not(miri))] |
| 755 | +#[cfg(feature = "http1")] |
741 | 756 | #[test] |
742 | 757 | fn client_upgrade() { |
743 | 758 | use tokio::io::{AsyncReadExt, AsyncWriteExt}; |
@@ -800,6 +815,7 @@ fn client_upgrade() { |
800 | 815 | } |
801 | 816 |
|
802 | 817 | #[cfg(not(miri))] |
| 818 | +#[cfg(feature = "server")] |
803 | 819 | #[test] |
804 | 820 | fn client_http2_upgrade() { |
805 | 821 | use http::{Method, Response, Version}; |
@@ -882,6 +898,7 @@ fn client_http2_upgrade() { |
882 | 898 | } |
883 | 899 |
|
884 | 900 | #[cfg(not(miri))] |
| 901 | +#[cfg(feature = "http2")] |
885 | 902 | #[test] |
886 | 903 | fn alpn_h2() { |
887 | 904 | use http::Response; |
@@ -950,6 +967,7 @@ fn alpn_h2() { |
950 | 967 | } |
951 | 968 |
|
952 | 969 | #[cfg(not(miri))] |
| 970 | +#[cfg(feature = "http1")] |
953 | 971 | #[test] |
954 | 972 | fn capture_connection_on_client() { |
955 | 973 | let _ = pretty_env_logger::try_init(); |
@@ -981,6 +999,7 @@ fn capture_connection_on_client() { |
981 | 999 | } |
982 | 1000 |
|
983 | 1001 | #[cfg(not(miri))] |
| 1002 | +#[cfg(feature = "http1")] |
984 | 1003 | #[test] |
985 | 1004 | fn connection_poisoning() { |
986 | 1005 | use std::sync::atomic::AtomicUsize; |
@@ -1327,6 +1346,7 @@ impl tower_service::Service<hyper::Uri> for MockConnector { |
1327 | 1346 | // Test for connection error propagation with PR #184. |
1328 | 1347 | // Simulates a connection failure by setting failed=true and returning a custom io::Error. |
1329 | 1348 | // Verifies the error propagates through hyper’s client as a hyper::Error(Io, ...). |
| 1349 | +#[cfg(feature = "http1")] |
1330 | 1350 | #[tokio::test] |
1331 | 1351 | async fn test_connection_error_propagation_pr184() { |
1332 | 1352 | // Define the error message for the simulated connection failure. |
@@ -1384,6 +1404,7 @@ async fn test_connection_error_propagation_pr184() { |
1384 | 1404 | // Simulates a connection that returns EOF immediately, causing hyper’s HTTP/1.1 parser |
1385 | 1405 | // to fail with IncompleteMessage due to no response data. |
1386 | 1406 | // Uses MockConnector with conn_error=None to keep failed=false, ensuring EOF behavior. |
| 1407 | +#[cfg(feature = "http1")] |
1387 | 1408 | #[tokio::test] |
1388 | 1409 | async fn test_incomplete_message_error_pr184() { |
1389 | 1410 | // Create an empty IoBuilder to simulate a connection with no data. |
@@ -1443,6 +1464,7 @@ async fn test_incomplete_message_error_pr184() { |
1443 | 1464 | // Test for a successful HTTP/1.1 connection using a mock connector. |
1444 | 1465 | // Simulates a server that accepts a request and responds with a 200 OK. |
1445 | 1466 | // Verifies the client correctly sends the request and receives the response. |
| 1467 | +#[cfg(feature = "http1")] |
1446 | 1468 | #[tokio::test] |
1447 | 1469 | async fn test_successful_connection() { |
1448 | 1470 | // Define the expected server response: a valid HTTP/1.1 200 OK with no body. |
|
0 commit comments