Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Hyper 1. Also updated all other depends. #45

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ edition = "2018"

[dependencies]
tokio = { version = "1", features = ["io-std", "io-util"] }
hyper = { version = "0.14", features = ["client"] }
hyper = { version = "1", features = ["client"] }

tower-service = "0.3"
http = "0.2"
http = "1"
futures-util = { version = "0.3", default-features = false }
bytes = "1.0"
hyper-tls = { version = "0.5.0", optional = true }
hyper-tls = { version = "0.6.0", optional = true }
tokio-native-tls = { version = "0.3.0", optional = true }
native-tls = { version = "0.2", optional = true }
openssl = { version = "0.10", optional = true }
tokio-openssl = { version = "0.6", optional = true }
tokio-rustls = { version = "0.22", optional = true }
hyper-rustls = { version = "0.22", optional = true }

webpki = { version = "0.21", optional = true }
rustls-native-certs = { version = "0.5.0", optional = true }
webpki-roots = { version = "0.21.0", optional = true }
headers = "0.3"
tokio-rustls = { version = "0.26", optional = true }
hyper-rustls = { version = "0.27", optional = true }

webpki = { version = "0.22", optional = true }
rustls-native-certs = { version = "0.7.0", optional = true }
webpki-roots = { version = "0.26.0", optional = true }
headers = "0.4"
hyper-util = "0.1.3"
[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
hyper = { version = "0.14", features = ["client", "http1", "tcp"] }
hyper = { version = "1", features = ["client", "http1"] }

[features]
openssl-tls = ["openssl", "tokio-openssl"]
Expand Down
24 changes: 9 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ use hyper::{service::Service, Uri};

use futures_util::future::TryFutureExt;
use std::{fmt, io, sync::Arc};
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use std::{future::Future, pin::Pin};

pub use stream::ProxyStream;
use tokio::io::{AsyncRead, AsyncWrite};
Expand Down Expand Up @@ -430,19 +426,17 @@ where
type Error = io::Error;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
match self.connector.poll_ready(cx) {
Poll::Ready(Ok(())) => Poll::Ready(Ok(())),
Poll::Ready(Err(e)) => Poll::Ready(Err(io_err(e.into()))),
Poll::Pending => Poll::Pending,
}
}

fn call(&mut self, uri: Uri) -> Self::Future {
fn call(&self, uri: Uri) -> Self::Future {
if let (Some(p), Some(host)) = (self.match_proxy(&uri), uri.host()) {
if uri.scheme() == Some(&http::uri::Scheme::HTTPS) || p.force_connect {
let host = host.to_owned();
let port = uri.port_u16().unwrap_or(if uri.scheme() == Some(&http::uri::Scheme::HTTP) { 80 } else { 443 });
let port =
uri.port_u16()
.unwrap_or(if uri.scheme() == Some(&http::uri::Scheme::HTTP) {
80
} else {
443
});
let tunnel = tunnel::new(&host, port, &p.headers);
let connection =
proxy_dst(&uri, &p.uri).map(|proxy_url| self.connector.call(proxy_url));
Expand Down
2 changes: 1 addition & 1 deletion src/stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use hyper_util::client::legacy::connect::{Connected, Connection};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

#[cfg(feature = "rustls-base")]
Expand All @@ -12,7 +13,6 @@ use tokio_native_tls::TlsStream;
#[cfg(feature = "openssl-tls")]
use tokio_openssl::SslStream as OpenSslStream;

use hyper::client::connect::{Connected, Connection};

#[cfg(feature = "rustls-base")]
pub type TlsStream<R> = RustlsStream<R>;
Expand Down