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

feat: add tls_info flag to connections using proxy #2590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl ConnectorService {
return Ok(Conn {
inner: self.verbose.wrap(RustlsTlsConn { inner: io }),
is_proxy: false,
tls_info: false,
tls_info: self.tls_info,
});
}
}
Expand All @@ -404,7 +404,7 @@ impl ConnectorService {
socks::connect(proxy, dst, dns).await.map(|tcp| Conn {
inner: self.verbose.wrap(TokioIo::new(tcp)),
is_proxy: false,
tls_info: false,
tls_info: self.tls_info,
})
}

Expand Down Expand Up @@ -540,7 +540,7 @@ impl ConnectorService {
inner: TokioIo::new(io),
}),
is_proxy: false,
tls_info: false,
tls_info: self.tls_info,
});
}
}
Expand Down Expand Up @@ -575,7 +575,7 @@ impl ConnectorService {
inner: TokioIo::new(io),
}),
is_proxy: false,
tls_info: false,
tls_info: self.tls_info,
});
}
}
Expand Down
28 changes: 28 additions & 0 deletions tests/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,31 @@ async fn http_over_http() {
assert_eq!(res.url().as_str(), url);
assert_eq!(res.status(), reqwest::StatusCode::OK);
}

#[tokio::test]
async fn test_tls_info_not_present_to_http_proxy() {
let url = "http://hyper.rs/prox";

let server = server::http(move |req| {
assert_eq!(req.method(), "GET");
assert_eq!(req.uri(), url);
assert_eq!(req.headers()["host"], "hyper.rs");

async { http::Response::default() }
});

let proxy = format!("http://{}", server.addr());

let res = reqwest::Client::builder()
.proxy(reqwest::Proxy::http(&proxy).unwrap())
.tls_info(true)
.build()
.unwrap()
.get(url)
.send()
.await
.unwrap();

let tls_info = res.extensions().get::<reqwest::tls::TlsInfo>();
assert!(tls_info.is_none());
}