Skip to content

Commit

Permalink
Merge branch 'hyperium:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
allan2 authored Jan 3, 2024
2 parents a6bdc5d + 43ddd6d commit 05b6161
Show file tree
Hide file tree
Showing 11 changed files with 1,374 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
env:
# Can't enable tcp feature since Miri does not support the tokio runtime
MIRIFLAGS: "-Zmiri-disable-isolation"
run: cargo miri test
run: cargo miri test --all-features

features:
name: features
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 0.1.2 (2023-12-20)

### Added

- Add `graceful_shutdown()` method to `auto` connections.
- Add `rt::TokioTimer` type that implements `hyper::rt::Timer`.
- Add `service::TowerToHyperService` adapter, allowing using `tower::Service`s as a `hyper::service::Service`.
- Implement `Clone` for `auto::Builder`.
- Exports `legacy::{Builder, ResponseFuture}`.

### Fixed

- Enable HTTP/1 upgrades on the `legacy::Client`.
- Prevent divide by zero if DNS returns 0 addresses.

# 0.1.1 (2023-11-17)

### Added
Expand Down
16 changes: 10 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyper-util"
version = "0.1.1"
version = "0.1.2"
description = "hyper utilities"
readme = "README.md"
homepage = "https://hyper.rs"
Expand All @@ -17,7 +17,7 @@ features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
hyper = "1.0.0"
hyper = "1.1.0"
futures-channel = "0.3"
futures-util = { version = "0.3.16", default-features = false }
http = "1.0"
Expand All @@ -27,15 +27,16 @@ pin-project-lite = "0.2.4"
socket2 = { version = "0.5", optional = true, features = ["all"] }
tracing = { version = "0.1", default-features = false, features = ["std"] }
tokio = { version = "1", optional = true, features = ["net", "rt", "time"] }
tower-service = "0.3"
tower = { version = "0.4.1", features = ["make", "util"] }
tower-service ={ version = "0.3", optional = true }
tower = { version = "0.4.1", optional = true, features = ["make", "util"] }

[dev-dependencies]
hyper = { version = "1.0.0", features = ["full"] }
hyper = { version = "1.1.0", features = ["full"] }
bytes = "1"
http-body-util = "0.1.0"
tokio = { version = "1", features = ["macros", "test-util"] }
tokio-test = "0.4"
pretty_env_logger = "0.5"

[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]
pnet_datalink = "0.34.0"
Expand All @@ -49,17 +50,20 @@ full = [
"client-legacy",
"server",
"server-auto",
"service",
"http1",
"http2",
"tokio",
]

client = ["hyper/client"]
client = ["hyper/client", "dep:tower", "dep:tower-service"]
client-legacy = ["client"]

server = ["hyper/server"]
server-auto = ["server", "http1", "http2"]

service = ["dep:tower", "dep:tower-service"]

http1 = ["hyper/http1"]
http2 = ["hyper/http2"]

Expand Down
9 changes: 8 additions & 1 deletion src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ where
&self,
pool_key: PoolKey,
) -> Result<pool::Pooled<PoolClient<B>, PoolKey>, ClientConnectError> {
// Return a single connection if pooling is not enabled
if !self.pool.is_enabled() {
return self
.connect_to(pool_key)
.await
.map_err(ClientConnectError::Normal);
}

// This actually races 2 different futures to try to get a ready
// connection the fastest, and to reduce connection churn.
//
Expand Down Expand Up @@ -1471,7 +1479,6 @@ impl fmt::Debug for Builder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Builder")
.field("client_config", &self.client_config)
//.field("conn_builder", &self.conn_builder)
.field("pool_config", &self.pool_config)
.finish()
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<T, K: Key> Pool<T, K> {
Pool { inner }
}

fn is_enabled(&self) -> bool {
pub(crate) fn is_enabled(&self) -> bool {
self.inner.is_some()
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod rt;
#[cfg(feature = "server")]
pub mod server;
#[cfg(all(
feature = "service",
any(feature = "http1", feature = "http2"),
any(feature = "server", feature = "client")
))]
Expand Down
5 changes: 5 additions & 0 deletions src/rt/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ impl<T> TokioIo<T> {
&self.inner
}

/// Mut borrow the inner type.
pub fn inner_mut(&mut self) -> &mut T {
&mut self.inner
}

/// Consume this wrapper and get the inner type.
pub fn into_inner(self) -> T {
self.inner
Expand Down
Loading

0 comments on commit 05b6161

Please sign in to comment.