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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
needs: [style]
strategy:
matrix:
rust: [ 1.64 ] # keep in sync with 'rust-version' in Cargo.toml
rust: [ 1.85 ] # keep in sync with 'rust-version' in Cargo.toml
os:
- ubuntu-latest
- windows-latest
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ license = "MIT"
authors = ["Sean McArthur <sean@seanmonstar.com>"]
keywords = ["http", "hyper", "hyperium"]
categories = ["network-programming", "web-programming::http-client", "web-programming::http-server"]
edition = "2021"
rust-version = "1.64"
edition = "2024"
rust-version = "1.85"

[package.metadata.docs.rs]
features = ["full"]
Expand Down
2 changes: 1 addition & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;

use http_body_util::Empty;
use hyper::Request;
use hyper_util::client::legacy::{connect::HttpConnector, Client};
use hyper_util::client::legacy::{Client, connect::HttpConnector};

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
4 changes: 2 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::{convert::Infallible, error::Error};

use bytes::Bytes;
use http::{header::CONTENT_TYPE, Request, Response};
use http_body_util::{combinators::BoxBody, BodyExt, Full};
use http::{Request, Response, header::CONTENT_TYPE};
use http_body_util::{BodyExt, Full, combinators::BoxBody};
use hyper::{body::Incoming, service::service_fn};
use hyper_util::{
rt::{TokioExecutor, TokioIo},
Expand Down
12 changes: 6 additions & 6 deletions src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

use std::error::Error as StdError;
use std::fmt;
use std::future::{poll_fn, Future};
use std::future::{Future, poll_fn};
use std::pin::Pin;
use std::task::{self, Poll};
use std::time::Duration;

use futures_util::future::{self, Either, FutureExt, TryFutureExt};
use http::uri::Scheme;
use hyper::client::conn::TrySendError as ConnTrySendError;
use hyper::header::{HeaderValue, HOST};
use hyper::header::{HOST, HeaderValue};
use hyper::rt::Timer;
use hyper::{body::Body, Method, Request, Response, Uri, Version};
use hyper::{Method, Request, Response, Uri, Version, body::Body};
use tracing::{debug, trace, warn};

use super::connect::capture::CaptureConnectionExtension;
#[cfg(feature = "tokio")]
use super::connect::HttpConnector;
use super::connect::capture::CaptureConnectionExtension;
use super::connect::{Alpn, Connect, Connected, Connection};
use super::pool::{self, Ver};

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

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

Expand Down Expand Up @@ -484,7 +484,7 @@ where
fn connect_to(
&self,
pool_key: PoolKey,
) -> impl Lazy<Output = Result<pool::Pooled<PoolClient<B>, PoolKey>, Error>> + Send + Unpin
) -> impl Lazy<Output = Result<pool::Pooled<PoolClient<B>, PoolKey>, Error>> + Send + Unpin + use<C, B>
{
let executor = self.exec.clone();
let pool = self.pool.clone();
Expand Down
35 changes: 19 additions & 16 deletions src/client/legacy/connect/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,20 @@ mod test {
"connection has not been set"
);
tx.set(&Connected::new().proxy(true));
assert!(rx
.connection_metadata()
.as_ref()
.expect("connected should be set")
.is_proxied());
assert!(
rx.connection_metadata()
.as_ref()
.expect("connected should be set")
.is_proxied()
);

// ensure it can be called multiple times
assert!(rx
.connection_metadata()
.as_ref()
.expect("connected should be set")
.is_proxied());
assert!(
rx.connection_metadata()
.as_ref()
.expect("connected should be set")
.is_proxied()
);
}

#[tokio::test]
Expand All @@ -153,12 +155,13 @@ mod test {
"connection has not been set"
);
let test_task = tokio::spawn(async move {
assert!(rx
.wait_for_connection_metadata()
.await
.as_ref()
.expect("connection should be set")
.is_proxied());
assert!(
rx.wait_for_connection_metadata()
.await
.as_ref()
.expect("connection should be set")
.is_proxied()
);
// can be awaited multiple times
assert!(
rx.wait_for_connection_metadata().await.is_some(),
Expand Down
12 changes: 4 additions & 8 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::marker::PhantomData;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use std::pin::Pin;
use std::sync::Arc;
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};
use std::time::Duration;

use futures_util::future::Either;
Expand All @@ -17,7 +17,7 @@ use tokio::net::{TcpSocket, TcpStream};
use tokio::time::Sleep;
use tracing::{debug, trace, warn};

use super::dns::{self, resolve, GaiResolver, Resolve};
use super::dns::{self, GaiResolver, Resolve, resolve};
use super::{Connected, Connection};
use crate::rt::TokioIo;

Expand Down Expand Up @@ -114,11 +114,7 @@ impl TcpKeepaliveConfig {
if let Some(retries) = self.retries {
ka = Self::ka_with_retries(ka, retries, &mut dirty)
};
if dirty {
Some(ka)
} else {
None
}
if dirty { Some(ka) } else { None }
}

#[cfg(
Expand Down Expand Up @@ -1169,8 +1165,8 @@ mod tests {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, TcpListener};
use std::time::{Duration, Instant};

use super::dns;
use super::ConnectingTcp;
use super::dns;

let server4 = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = server4.local_addr().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/client/legacy/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
use std::{
fmt::{self, Formatter},
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
};

Expand All @@ -83,7 +83,7 @@ mod http;
pub mod proxy;

pub(crate) mod capture;
pub use capture::{capture_connection, CaptureConnection};
pub use capture::{CaptureConnection, capture_connection};

pub use self::sealed::Connect;

Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/connect/proxy/socks/v5/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl ProxyReq<'_> {
let addr_len = match self.0 {
Address::Socket(SocketAddr::V4(_)) => 1 + 4 + 2,
Address::Socket(SocketAddr::V6(_)) => 1 + 16 + 2,
Address::Domain(ref domain, _) => 1 + 1 + domain.len() + 2,
Address::Domain(domain, _) => 1 + 1 + domain.len() + 2,
};

if buf.capacity() - buf.len() < 3 + addr_len {
Expand Down
6 changes: 3 additions & 3 deletions src/client/legacy/connect/proxy/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::error::Error as StdError;
use std::future::Future;
use std::marker::{PhantomData, Unpin};
use std::pin::Pin;
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};

use http::{HeaderMap, HeaderValue, Uri};
use hyper::rt::{Read, Write};
Expand Down Expand Up @@ -249,8 +249,8 @@ impl std::fmt::Display for TunnelError {
impl std::error::Error for TunnelError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
TunnelError::Io(ref e) => Some(e),
TunnelError::ConnectFailed(ref e) => Some(&**e),
TunnelError::Io(e) => Some(e),
TunnelError::ConnectFailed(e) => Some(&**e),
_ => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::hash::Hash;
use std::ops::{Deref, DerefMut};
use std::pin::Pin;
use std::sync::{Arc, Mutex, Weak};
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};

use std::time::{Duration, Instant};

Expand Down Expand Up @@ -1032,8 +1032,8 @@ mod tests {

#[tokio::test]
async fn test_pool_checkout_task_unparked() {
use futures_util::future::join;
use futures_util::FutureExt;
use futures_util::future::join;

let pool = pool_no_timer();
let key = host_key("foo");
Expand Down
2 changes: 1 addition & 1 deletion src/client/pool/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod internal {
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex, Weak};
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};

use futures_util::future;
use tokio::sync::oneshot;
Expand Down
18 changes: 9 additions & 9 deletions src/client/pool/negotiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod internal {
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};

use pin_project_lite::pin_project;
use tower_layer::Layer;
Expand Down Expand Up @@ -353,7 +353,7 @@ mod internal {

/// Get a reference to the fallback service if this is it.
pub fn fallback_ref(&self) -> Option<&L> {
if let Negotiated::Fallback(ref left) = self {
if let Negotiated::Fallback(left) = self {
Some(left)
} else {
None
Expand All @@ -362,7 +362,7 @@ mod internal {

/// Get a mutable reference to the fallback service if this is it.
pub fn fallback_mut(&mut self) -> Option<&mut L> {
if let Negotiated::Fallback(ref mut left) = self {
if let Negotiated::Fallback(left) = self {
Some(left)
} else {
None
Expand All @@ -371,7 +371,7 @@ mod internal {

/// Get a reference to the upgraded service if this is it.
pub fn upgraded_ref(&self) -> Option<&R> {
if let Negotiated::Upgraded(ref right) = self {
if let Negotiated::Upgraded(right) = self {
Some(right)
} else {
None
Expand All @@ -380,7 +380,7 @@ mod internal {

/// Get a mutable reference to the upgraded service if this is it.
pub fn upgraded_mut(&mut self) -> Option<&mut R> {
if let Negotiated::Upgraded(ref mut right) = self {
if let Negotiated::Upgraded(right) = self {
Some(right)
} else {
None
Expand All @@ -399,17 +399,17 @@ mod internal {

fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
match self {
Negotiated::Fallback(ref mut s) => s.poll_ready(cx),
Negotiated::Upgraded(ref mut s) => s.poll_ready(cx),
Negotiated::Fallback(s) => s.poll_ready(cx),
Negotiated::Upgraded(s) => s.poll_ready(cx),
}
}

fn call(&mut self, req: Req) -> Self::Future {
match self {
Negotiated::Fallback(ref mut s) => NegotiatedFuture::Fallback {
Negotiated::Fallback(s) => NegotiatedFuture::Fallback {
future: s.call(req),
},
Negotiated::Upgraded(ref mut s) => NegotiatedFuture::Upgraded {
Negotiated::Upgraded(s) => NegotiatedFuture::Upgraded {
future: s.call(req),
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/pool/singleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod internal {
use std::future::Future;
use std::pin::Pin;
use std::sync::{Mutex, Weak};
use std::task::{self, ready, Poll};
use std::task::{self, Poll, ready};

use pin_project_lite::pin_project;
use tokio::sync::oneshot;
Expand Down
42 changes: 24 additions & 18 deletions src/client/proxy/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,25 +905,31 @@ mod tests {
};

// should bypass proxy (case insensitive match)
assert!(p
.intercept(&"http://example.com".parse().unwrap())
.is_none());
assert!(p
.intercept(&"http://EXAMPLE.COM".parse().unwrap())
.is_none());
assert!(p
.intercept(&"http://Example.com".parse().unwrap())
.is_none());
assert!(
p.intercept(&"http://example.com".parse().unwrap())
.is_none()
);
assert!(
p.intercept(&"http://EXAMPLE.COM".parse().unwrap())
.is_none()
);
assert!(
p.intercept(&"http://Example.com".parse().unwrap())
.is_none()
);

// subdomain should bypass proxy (case insensitive match)
assert!(p
.intercept(&"http://www.example.com".parse().unwrap())
.is_none());
assert!(p
.intercept(&"http://WWW.EXAMPLE.COM".parse().unwrap())
.is_none());
assert!(p
.intercept(&"http://Www.Example.Com".parse().unwrap())
.is_none());
assert!(
p.intercept(&"http://www.example.com".parse().unwrap())
.is_none()
);
assert!(
p.intercept(&"http://WWW.EXAMPLE.COM".parse().unwrap())
.is_none()
);
assert!(
p.intercept(&"http://Www.Example.Com".parse().unwrap())
.is_none()
);
}
}
2 changes: 1 addition & 1 deletion src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ pub(crate) mod timer;
pub(crate) use exec::Exec;

#[cfg(feature = "client-legacy")]
pub(crate) use lazy::{lazy, Started as Lazy};
pub(crate) use lazy::{Started as Lazy, lazy};
#[cfg(feature = "client-legacy")]
pub(crate) use sync::SyncWrapper;
2 changes: 1 addition & 1 deletion src/rt/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::Unpin;
use std::pin::Pin;
use std::task::{ready, Poll};
use std::task::{Poll, ready};

use hyper::rt::{Read, ReadBuf, Write};

Expand Down
Loading