Skip to content

interface: add custom proxy#47

Merged
bdbai merged 11 commits into
mainfrom
interface/proxy
May 17, 2026
Merged

interface: add custom proxy#47
bdbai merged 11 commits into
mainfrom
interface/proxy

Conversation

@bdbai
Copy link
Copy Markdown
Owner

@bdbai bdbai commented May 16, 2026

Fixes #41

@bdbai bdbai marked this pull request as ready for review May 17, 2026 11:57
@bdbai bdbai merged commit 73e0fff into main May 17, 2026
27 checks passed
@bdbai bdbai deleted the interface/proxy branch May 17, 2026 12:01
@bdbai bdbai requested a review from Copilot May 17, 2026 14:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds per-client custom proxy configuration across the public client API, interface options, backend implementations, and backend test fixtures.

Changes:

  • Introduces CustomProxy and replaces the boolean default-proxy flag with ProxyOptions.
  • Implements proxy handling for curl, reqwest, WinHTTP, NSURLSession, and no/custom handling for WinRT.
  • Adds proxy backend tests and refactors shared Hyper test fixture setup.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/client/proxy.rs Adds public custom proxy builder type.
src/client/builder.rs Adds custom_proxy and updates no_proxy.
src/client.rs Exports CustomProxy.
README.md Moves WinHTTP to completed MVP backends.
nyquest-interface/src/client/options.rs Adds ProxyOptions to client configuration.
nyquest-interface/src/client.rs Exports ProxyOptions.
nyquest-backend-tests/src/lib.rs Refactors shared fixture server setup.
nyquest-backend-tests/src/hyper_fixture_collection.rs Extracts reusable Hyper fixture collection.
nyquest-backend-tests/src/fixtures/client_options/proxy.rs Adds proxy behavior tests.
nyquest-backend-tests/src/fixtures/client_options.rs Registers proxy tests.
Cargo.lock Updates platform dependency lock entries.
backends/winrt/src/response.rs Moves stream reader state out of common response.
backends/winrt/src/client.rs Adapts WinRT proxy option handling.
backends/winrt/src/blocking/timer_ext.rs Updates Windows async blocking call.
backends/winrt/src/blocking.rs Moves blocking reader state into blocking response.
backends/winrt/src/async/read_task.rs Adds async read state machine.
backends/winrt/src/async.rs Uses new WinRT async read task.
backends/winrt/Cargo.toml Updates Windows crate versions.
backends/winhttp/src/session.rs Passes proxy options to session creation.
backends/winhttp/src/handle/session.rs Adds WinHTTP proxy option mapping.
backends/winhttp/src/async/threadpool.rs Removes custom threadpool helper.
backends/winhttp/src/async/client.rs Uses windows-threading for async setup work.
backends/winhttp/src/async.rs Removes deleted threadpool module.
backends/winhttp/Cargo.toml Updates Windows dependencies and adds windows-threading.
backends/reqwest/src/client.rs Adds reqwest proxy option mapping.
backends/nsurlsession/src/response.rs Adjusts Objective-C API calls for updated bindings.
backends/nsurlsession/src/datatask/delegate.rs Adjusts Objective-C API calls for updated bindings.
backends/nsurlsession/src/client.rs Adds NSURLSession proxy dictionary support.
backends/nsurlsession/src/blocking.rs Adjusts Objective-C API calls for updated bindings.
backends/nsurlsession/src/async.rs Adjusts Objective-C API calls for updated bindings.
backends/nsurlsession/Cargo.toml Updates Objective-C Foundation dependency/features.
backends/curl/src/request.rs Adds curl proxy option setup.
backends/curl/src/curl_ng/easy/opt.rs Adds curl proxy-related option wrappers.
Comments suppressed due to low confidence (2)

backends/reqwest/src/client.rs:110

  • Invalid HTTPS proxy URLs are also silently ignored, which leaves HTTPS traffic without the requested custom proxy while the client still builds successfully. Propagate Proxy::https failures when proxy_url_for_https is provided so invalid per-client proxy settings are not accepted silently.
            if let Some(Ok(proxy_https)) = proxy_url_for_https.as_deref().map(Proxy::https) {
                builder = builder.proxy(proxy_https.no_proxy(no_proxy));
            }

backends/nsurlsession/src/client.rs:60

  • A provided HTTPS proxy URL that fails parsing (including otherwise valid URLs without an explicit port) is silently dropped, so HTTPS requests will not use the caller's requested proxy. Treat an invalid proxy_url_for_https as a client build error or derive the default port from the scheme rather than ignoring it.
                        if let Some(https_proxy) =
                            proxy_url_for_https.and_then(|url| parse_proxy_host_port(&url))
                        {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +48
ProxyOptions::Default => unsafe {
WinHttpOpen(
user_agent_ptr,
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
std::ptr::null(),
std::ptr::null(),
flags,
)
Comment on lines +105 to +108
if let Ok(proxy_http) = Proxy::http(&**proxy_url_for_http) {
builder = builder.proxy(proxy_http.no_proxy(no_proxy.clone()));
}
if let Some(Ok(proxy_https)) = proxy_url_for_https.as_deref().map(Proxy::https) {
Comment on lines +57 to +62
raw.as_mut().set_proxy(&**proxy_url_for_http)?;
if proxy_url_for_https.is_some() {
// TODO: curl doesn't have a separate option for HTTPS proxy.
raw.as_mut().set_http_proxy_tunnel(true)?;
raw.as_mut().set_suppress_connect_headers(true)?;
}
Comment on lines +44 to +45
if let Some(http_proxy) = parse_proxy_host_port(&proxy_url_for_http) {
let dict = NSMutableDictionary::from_retained_objects(
@bdbai
Copy link
Copy Markdown
Owner Author

bdbai commented May 17, 2026

@copilot apply changes based on the comments in this thread

@bdbai bdbai mentioned this pull request May 18, 2026
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.

Per-client http proxy

2 participants