Skip to content

Commit 6cc8957

Browse files
committed
feat(client): implement hyper::service::Service instead of tower::Service on client::conn::SendRequest
1 parent 7c7055c commit 6cc8957

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ h2 = { version = "0.3.9", optional = true }
3535
itoa = "1"
3636
tracing = { version = "0.1", default-features = false, features = ["std"] }
3737
pin-project-lite = "0.2.4"
38-
tower-service = "0.3"
3938
tokio = { version = "1", features = ["sync"] }
4039
want = "0.3"
4140

@@ -65,7 +64,6 @@ tokio = { version = "1", features = [
6564
] }
6665
tokio-test = "0.4"
6766
tokio-util = { version = "0.7", features = ["codec"] }
68-
tower = { version = "0.4", features = ["make", "util"] }
6967
url = "2.2"
7068

7169
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]

src/client/conn/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//! ```no_run
1414
//! # #[cfg(all(feature = "client", feature = "http1", feature = "runtime"))]
1515
//! # mod rt {
16-
//! use tower::ServiceExt;
1716
//! use http::{Request, StatusCode};
1817
//! use hyper::{client::conn, Body};
1918
//! use tokio::net::TcpStream;
@@ -39,9 +38,6 @@
3938
//! let response = request_sender.send_request(request).await?;
4039
//! assert!(response.status() == StatusCode::OK);
4140
//!
42-
//! // To send via the same connection again, it may not work as it may not be ready,
43-
//! // so we have to wait until the request_sender becomes ready.
44-
//! request_sender.ready().await?;
4541
//! let request = Request::builder()
4642
//! .header("Host", "example.com")
4743
//! .method("GET")
@@ -67,7 +63,6 @@ use futures_util::future;
6763
use httparse::ParserConfig;
6864
use pin_project_lite::pin_project;
6965
use tokio::io::{AsyncRead, AsyncWrite};
70-
use tower_service::Service;
7166
use tracing::{debug, trace};
7267

7368
use super::dispatch;
@@ -83,6 +78,7 @@ use crate::rt::Executor;
8378
#[cfg(feature = "http1")]
8479
use crate::upgrade::Upgraded;
8580
use crate::{Body, Request, Response};
81+
use crate::service::Service;
8682

8783
#[cfg(feature = "http1")]
8884
pub mod http1;
@@ -292,10 +288,6 @@ where
292288
type Error = crate::Error;
293289
type Future = ResponseFuture;
294290

295-
fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
296-
self.poll_ready(cx)
297-
}
298-
299291
fn call(&mut self, req: Request<B>) -> Self::Future {
300292
self.send_request(req)
301293
}

src/service/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ mod util;
2727

2828
#[cfg(all(any(feature = "http1", feature = "http2"), feature = "server"))]
2929
pub(super) use self::http::HttpService;
30-
#[cfg(all(any(feature = "http1", feature = "http2"), feature = "server"))]
30+
#[cfg(all(
31+
any(feature = "http1", feature = "http2"),
32+
any(feature = "server", feature = "client")
33+
))]
3134
pub use self::service::Service;
3235

3336
pub use self::util::service_fn;

0 commit comments

Comments
 (0)