reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Not sending ALPN when using socks5 proxy

Open cxw620 opened this issue 1 year ago • 2 comments

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

I simply verified my thoughts with testing, but I'm still uncertain, so I submit this issue.

cxw620 avatar Jan 30 '24 14:01 cxw620

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.

abacabadabacaba avatar Feb 11 '24 12:02 abacabadabacaba

Since hyper v1 upgrade is on the way, #2131 will be closed and I open a new PR to branch hyper-v1. If needed, add the following in Cargo.toml for temp patch before hyper v1 upgrade finishes and you upgrade reqwest to latest version:

[patch.crates-io]
reqwest = { git = 'https://github.com/cxw620/lib_reqwest.git', rev = 'ed9dbc7649f53cd18b5bdfe88173064c95bd6b78' }

cxw620 avatar Feb 22 '24 09:02 cxw620