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
21 changes: 17 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- test
- msrv
- miri
- features
- client-features
- server-features
- semver
- doc
steps:
Expand Down Expand Up @@ -94,15 +95,27 @@ jobs:
MIRIFLAGS: "-Zmiri-disable-isolation"
run: cargo miri test --all-features

features:
name: features
client-features:
name: client-features
needs: [style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack --no-dev-deps check --feature-powerset --depth 2
- uses: taiki-e/install-action@just
- run: just check-client-features

server-features:
name: server-features
needs: [style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@just
- run: just check-server-features

semver:
name: semver
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ tracing = ["dep:tracing"]
# Temporary compatibility opt-in, deliberately excluded from `full`.
rt-tracing-exec-force = ["tokio", "tracing"]

# internal features used in CI
__internal_happy_eyeballs_tests = []

[[example]]
name = "client"
required-features = ["client-legacy", "http1", "tokio"]
Expand Down
9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
check-client-features:
cargo hack --no-dev-deps check --feature-powerset --depth 2 \
--features=client \
--include-features client-legacy,client-pool,client-proxy,client-proxy-system,http1,http2,tokio,tracing

check-server-features:
cargo hack --no-dev-deps check --feature-powerset --depth 2 \
--features=server \
--include-features server-auto,server-graceful,http1,http2,tokio,tracing
12 changes: 9 additions & 3 deletions src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ use tracing::{debug, trace, warn};
use super::connect::HttpConnector;
use super::connect::capture::CaptureConnectionExtension;
use super::connect::{Alpn, Connect, Connected, Connection};
use super::exec::Exec;
use super::lazy::{Started as Lazy, lazy as hyper_lazy};
use super::pool::{self, Ver};

use crate::common::{Exec, Lazy, lazy as hyper_lazy, timer};
use super::timer;

type BoxSendFuture = Pin<Box<dyn Future<Output = ()> + Send>>;

Expand Down Expand Up @@ -64,6 +65,7 @@ pub struct Error {
#[derive(Debug)]
enum ErrorKind {
Canceled,
#[cfg(feature = "http1")]
ChannelClosed,
Connect,
UserUnsupportedRequestMethod,
Expand Down Expand Up @@ -1549,7 +1551,10 @@ impl Builder {
/// details.
///
/// [`hyper::client::conn::http2::Builder::timer`]: https://docs.rs/hyper/latest/hyper/client/conn/http2/struct.Builder.html#method.timer
pub fn timer<M>(&mut self, timer: M) -> &mut Self
pub fn timer<M>(
&mut self,
#[cfg_attr(not(feature = "http2"), allow(unused_variables))] timer: M,
) -> &mut Self
where
M: Timer + Send + Sync + 'static,
{
Expand Down Expand Up @@ -1707,6 +1712,7 @@ impl Error {
e!(SendRequest, src)
}

#[cfg(feature = "http1")]
fn closed(src: hyper::Error) -> Self {
e!(ChannelClosed, src)
}
Expand Down
4 changes: 3 additions & 1 deletion src/client/legacy/connect/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ pub fn capture_connection<B>(request: &mut Request<B>) -> CaptureConnection {
/// This is inserted into `Extensions` to allow Hyper to back channel connection info
#[derive(Clone)]
pub(crate) struct CaptureConnectionExtension {
#[cfg_attr(not(any(feature = "http1", feature = "http2")), allow(dead_code))]
tx: Arc<watch::Sender<Option<Connected>>>,
}

impl CaptureConnectionExtension {
#[cfg(any(feature = "http1", feature = "http2"))]
pub(crate) fn set(&self, connected: &Connected) {
self.tx.send_replace(Some(connected.clone()));
}
Expand Down Expand Up @@ -119,7 +121,7 @@ impl CaptureConnection {
}
}

#[cfg(test)]
#[cfg(all(test, any(feature = "http1", feature = "http2")))]
mod test {
use super::*;

Expand Down
3 changes: 1 addition & 2 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,15 +1020,14 @@ fn set_port(addr: &mut SocketAddr, host_port: u16, explicit: bool) {

#[cfg(test)]
mod tests {
use std::io;
use std::net::SocketAddr;

use ::http::Uri;

use crate::client::legacy::connect::http::TcpKeepaliveConfig;

use super::super::sealed::{Connect, ConnectSvc};
use super::{Config, ConnectError, HttpConnector};
use super::HttpConnector;

use super::set_port;

Expand Down
2 changes: 2 additions & 0 deletions src/client/legacy/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl PoisonPill {
self.poisoned.store(true, Ordering::Relaxed)
}

#[cfg(any(feature = "http1", feature = "http2"))]
pub(crate) fn poisoned(&self) -> bool {
self.poisoned.load(Ordering::Relaxed)
}
Expand Down Expand Up @@ -224,6 +225,7 @@ impl Connected {

// Don't public expose that `Connected` is `Clone`, unsure if we want to
// keep that contract...
#[cfg(any(feature = "http1", feature = "http2"))]
pub(super) fn clone(&self) -> Connected {
Connected {
alpn: self.alpn,
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/client/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
mod client;
#[cfg(any(feature = "http1", feature = "http2"))]
pub use client::{Builder, Client, Error, ResponseFuture};
#[cfg(any(feature = "http1", feature = "http2"))]
mod lazy;

mod exec;
mod timer;

pub mod connect;
#[doc(hidden)]
Expand Down
6 changes: 3 additions & 3 deletions src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use tracing::{debug, trace};

use hyper::rt::Timer as _;

use crate::common::{exec, exec::Exec, timer::Timer};
use super::exec::{self, Exec};
use super::timer::Timer;

// FIXME: allow() required due to `impl Trait` leaking types to this lint
#[allow(missing_debug_implementations)]
Expand Down Expand Up @@ -846,10 +847,9 @@ mod tests {
use std::time::Duration;

use super::{Connecting, Key, Pool, Poolable, Reservation, WeakOpt};
use crate::client::legacy::timer;
use crate::rt::{TokioExecutor, TokioTimer};

use crate::common::timer;

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
struct KeyImpl(http::uri::Scheme, http::uri::Authority);

Expand Down
File renamed without changes.
15 changes: 0 additions & 15 deletions src/common/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(missing_docs)]
#![deny(unused)]
#![cfg_attr(docsrs, feature(doc_cfg))]

//! Utilities for working with hyper.
Expand Down Expand Up @@ -60,7 +61,6 @@

#[cfg(feature = "client")]
pub mod client;
mod common;
pub mod rt;
#[cfg(feature = "server")]
pub mod server;
Expand Down
42 changes: 26 additions & 16 deletions src/server/conn/auto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Http1 or Http2 connection.

mod rewind;
pub mod upgrade;

use hyper::service::HttpService;
Expand Down Expand Up @@ -29,7 +30,7 @@ use std::marker::PhantomData;

use pin_project_lite::pin_project;

use crate::common::rewind::Rewind;
use self::rewind::Rewind;

type Error = Box<dyn std::error::Error + Send + Sync>;

Expand Down Expand Up @@ -1132,22 +1133,27 @@ impl<E> Http2Builder<'_, E> {
}
}

#[cfg(all(feature = "tokio", test))]
#[cfg(all(feature = "tokio", feature = "http1", feature = "http2", test))]
mod tests {
use crate::{
rt::{TokioExecutor, TokioIo},
server::conn::auto,
};
use http::{Request, Response};
use http_body::Body;
use http_body_util::{BodyExt, Empty, Full};
use hyper::{body, body::Bytes, client, service::service_fn};
use std::{convert::Infallible, error::Error as StdError, net::SocketAddr, time::Duration};
use tokio::{
net::{TcpListener, TcpStream},
pin,
};
use crate::{rt::TokioExecutor, server::conn::auto};

#[cfg(not(miri))]
use prelude::*;
#[cfg(not(miri))]
mod prelude {
pub use crate::rt::TokioIo;
pub use http::{Request, Response};
pub use http_body::Body;
pub use http_body_util::{BodyExt, Empty, Full};
pub use hyper::client;
pub use hyper::{body, body::Bytes, service::service_fn};
pub use std::{convert::Infallible, time::Duration};
pub use std::{error::Error as StdError, net::SocketAddr};
pub use tokio::net::TcpListener;
pub use tokio::net::TcpStream;
}

#[cfg(not(miri))]
const BODY: &[u8] = b"Hello, world!";

#[test]
Expand Down Expand Up @@ -1299,7 +1305,7 @@ mod tests {
let builder = auto::Builder::new(TokioExecutor::new());
let connection = builder.serve_connection(stream, service_fn(hello));

pin!(connection);
tokio::pin!(connection);

connection.as_mut().graceful_shutdown();

Expand All @@ -1314,6 +1320,7 @@ mod tests {
assert_eq!(connection_error.kind(), std::io::ErrorKind::Interrupted);
}

#[cfg(not(miri))]
async fn connect_h1<B>(addr: SocketAddr) -> client::conn::http1::SendRequest<B>
where
B: Body + Send + 'static,
Expand All @@ -1328,6 +1335,7 @@ mod tests {
sender
}

#[cfg(not(miri))]
async fn connect_h2<B>(addr: SocketAddr) -> client::conn::http2::SendRequest<B>
where
B: Body + Unpin + Send + 'static,
Expand All @@ -1345,6 +1353,7 @@ mod tests {
sender
}

#[cfg(not(miri))]
async fn start_server(h1_only: bool, h2_only: bool) -> SocketAddr {
let addr: SocketAddr = ([127, 0, 0, 1], 0).into();
let listener = TcpListener::bind(addr).await.unwrap();
Expand Down Expand Up @@ -1378,6 +1387,7 @@ mod tests {
local_addr
}

#[cfg(not(miri))]
async fn hello(_req: Request<body::Incoming>) -> Result<Response<Full<Bytes>>, Infallible> {
Ok(Response::new(Full::new(Bytes::from(BODY))))
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/server/conn/auto/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hyper::{
upgrade::Upgraded,
};

use crate::common::rewind::Rewind;
use super::rewind::Rewind;

/// Tries to downcast the internal trait object to the type passed.
///
Expand Down
Loading
Loading