Repository: seanmonstar/reqwest (language: rust)

Issue:
Not sending ALPN when using socks5 proxy
I met with a weird issue. When using socks5 proxy, reqwest will use HTTP/1.1 during request, though HTTP/2 when using http/https proxy. Through Charles and verbose log I found that no ALPN were sent when using socks5 proxy.

I checked source code and noticed such codes:
https://github.com/seanmonstar/reqwest/blob/ddf7f24dcadb9a310b52300c531fe516a05e0c43/src/connect.rs#L148-L150
https://github.com/seanmonstar/reqwest/blob/ddf7f24dcadb9a310b52300c531fe516a05e0c43/src/connect.rs#L205-L225

I think here should clone `tls` instead of `tls_proxy` since `tls_proxy.alpn_protocols.clear()` introduced in #466 fixing #459.
![image](https://github.com/seanmonstar/reqwest/assets/70561268/3c64025c-7ce5-4c66-b456-1fa9dbea68da)

I simply verified my thoughts with testing, but I'm still uncertain, so I submit this issue.


Discussion / hints:
I encountered the same issue. Looking at the code, it looks like a bug.

This "feature" was introduced by #466. It seems that before it, it tried to use ALPN, but not properly activating h2 backend for some reason.

Fix patch:
diff --git a/src/connect.rs b/src/connect.rs
index ac0e07ffd..ff76c57f8 100644
--- a/src/connect.rs
+++ b/src/connect.rs
@@ -236,12 +236,12 @@ impl Connector {
                 }
             }
             #[cfg(feature = "__rustls")]
-            Inner::RustlsTls { tls_proxy, .. } => {
+            Inner::RustlsTls { tls, .. } => {
                 if dst.scheme() == Some(&Scheme::HTTPS) {
                     use std::convert::TryFrom;
                     use tokio_rustls::TlsConnector as RustlsConnector;
 
-                    let tls = tls_proxy.clone();
+                    let tls = tls.clone();
                     let host = dst.host().ok_or("no host in url")?.to_string();
                     let conn = socks::connect(proxy, dst, dns).await?;
                     let conn = TokioIo::new(conn);


Test patch: