Commit 25d1d31
committed
refactor(rust): read the proxy environment through hyper-util's matcher
`hyper_util` ships `client::proxy::matcher::Matcher` behind its `client-proxy`
feature: the `*_PROXY` convention including `ALL_PROXY`, `NO_PROXY` matched the
way curl matches it, and credentials taken out of a proxy URL. This crate had
written all of that again, so `resolve_proxy`, `system_proxy`, `read_env_first`
and `no_proxy_matches` are gone, and `system` now means what it means for any
hyper-based client.
Only `system` goes through the matcher. It answers `None` for a target with no
host or a scheme other than `http`/`https`, so routing an explicitly named proxy
through it would silently skip the proxy the caller configured; that path dials
its URI directly, as it did before.
The tunnel stays ours. `hyper_util`'s reads the `CONNECT` response as
if recvd.starts_with(b"HTTP/1.1 200") || recvd.starts_with(b"HTTP/1.0 200")
else if recvd.starts_with(b"HTTP/1.1 407") ...
else return Err(TunnelError::TunnelUnsuccessful)
so a status line split across reads is rejected although the tunnel is good, and
`HTTP/1.0 407` loses its meaning. Ours reads to the blank line before parsing.
`basic_auth` now returns the whole header value, scheme included, so that it and
`Intercept::basic_auth` are interchangeable at the call site. Getting that wrong
sent `Basic Basic <b64>` and was caught by the authentication tests.
Measured, from `packages/rust`:
$ cargo test -p armonik-transport --all-features
70 passing
$ cargo clippy --workspace --all-features --all-targets --no-deps -- -Dwarnings
$ cargo clippy --workspace --all-features --no-deps \
-- -Dwarnings -Dunused-crate-dependencies
$ RUSTDOCFLAGS="-Dwarnings" cargo doc --workspace --no-deps
$ cargo build --workspace --locked
$ cargo build -p armonik-transport
$ cargo fmt --all --check
all silent
proxy.rs goes from 730 to 611 lines. Prompted by a maintainer asking whether
hyper-util already did this.1 parent 8f1c836 commit 25d1d31
5 files changed
Lines changed: 193 additions & 196 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
216 | | - | |
217 | | - | |
| 221 | + | |
| 222 | + | |
218 | 223 | | |
219 | 224 | | |
220 | 225 | | |
| |||
0 commit comments