Skip to content

Conversation

@jcamiel
Copy link
Contributor

@jcamiel jcamiel commented Oct 15, 2025

This PR re-enables the proxy_headers method (see https://curl.se/libcurl/c/CURLOPT_PROXYHEADER.html available since curl 7.37.0)

It is basically the same code as http_headers.

The rational for this PR is to be used in Hurl, a cli HTTP engine powered by curl-rust. Hurl exposes various curl commands, basically delegating everything to curl-rust/libcurl and adding some syntax to test HTTP responses. One issue Orange-OpenSource/hurl#3944 and one draft PR Orange-OpenSource/hurl#4482 needs to use this new method exposed by curl-rust.

To test it, I've used this sample:

use curl::easy::{Easy, List};

#[test]
fn test_proxy_header() {
    let mut easy = Easy::new();
    easy.url("https://google.com").unwrap();
    easy.ssl_verify_peer(false).unwrap();

    let mut headers = List::new();
    headers.append("Proxy-Only: foo").unwrap();
    easy.proxy_headers(headers).unwrap();

    let mut headers = List::new();
    headers.append("All: bar").unwrap();
    easy.http_headers(headers).unwrap();

    easy.proxy("http://127.0.0.1:8080").unwrap();
    easy.verbose(true).unwrap();
    easy.write_function(|data| Ok(data.len())).unwrap();
    easy.perform().unwrap();
}

And with mitmproxy:

$ mitmproxy

We can see that only "All: bar" header is sent to the target :

mitmproxy

@jcamiel
Copy link
Contributor Author

jcamiel commented Oct 20, 2025

The CI/CD is failing because of the status code change for https://www.rust-lang.org (I've made another PR #627 to fix this)

@jcamiel jcamiel force-pushed the implement-proxy-headers branch from f331277 to de8db90 Compare October 20, 2025 16:20
@jcamiel jcamiel force-pushed the implement-proxy-headers branch from de8db90 to e737d34 Compare October 20, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant