Proxy: Only use HTTP CONNECT for HTTPS requests
Previously, `ureq` used `HTTP CONNECT` for *all* requests, including plain-text HTTP requests. However, some proxy servers like Squid only allow tunneling via the `HTTP CONNECT` method on port 443 - since it is usually only used to proxy HTTPS requests. As a result, it was not possible to use `ureq` with a Squid server in its default configuration. With the changes from this commit, ureq will interact with HTTP proxies in a more standard-conforming way, where `CONNECT` is only used for HTTPS requests. HTTP request paths are transformed in such a way that they comply with RFC 7230 [1]. Tested against Squid 4.13 in standard configuration, with and without basic authentication, for HTTP and HTTPS requests. [1] https://www.rfc-editor.org/rfc/rfc7230#section-5.3.2
This commit is contained in:
committed by
Martin Algesten
parent
bdcee72c53
commit
20a9ae7977
@@ -199,14 +199,14 @@ to encode the request body using that.
|
||||
|
||||
## Proxying
|
||||
|
||||
ureq supports two kinds of proxies, HTTP [`CONNECT`], [`SOCKS4`] and [`SOCKS5`], the former is
|
||||
ureq supports two kinds of proxies, [`HTTP`], [`SOCKS4`] and [`SOCKS5`], the former is
|
||||
always available while the latter must be enabled using the feature
|
||||
`ureq = { version = "*", features = ["socks-proxy"] }`.
|
||||
|
||||
Proxies settings are configured on an [Agent] (using [AgentBuilder]). All request sent
|
||||
through the agent will be proxied.
|
||||
|
||||
### Example using HTTP CONNECT
|
||||
### Example using HTTP
|
||||
|
||||
```rust
|
||||
fn proxy_example_1() -> std::result::Result<(), ureq::Error> {
|
||||
|
||||
Reference in New Issue
Block a user