Skip to content

[release/10.0.1xx] [Foundation] Implement NSUrlSessionHandler proxy support. Fixes #14632 - #26858

Merged
rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-26021-release/10.0.1xx-2026-10-13
Oct 14, 2026
Merged

rolfbjarne merged 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-26021-release/10.0.1xx-2026-10-13

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The Proxy setter previously threw PlatformNotSupportedException, and UseProxy/SupportsProxy didn't allow any custom proxy configuration.

This implements custom proxy support:

  • Proxy is now a real IWebProxy property. Since NSUrlSession applies proxy settings per-session (not per-request), the proxy returned by IWebProxy.GetProxy for the first request is translated into the session's ConnectionProxyDictionary and the session is recreated before the first request is sent (mirroring the UseCookies pattern).
  • UseProxy is now a real settable bool. Setting it to false applies an empty connection proxy dictionary, which overrides any proxy configured in the OS.
  • SupportsProxy now returns true.
  • Proxy authentication is wired up: DefaultProxyCredentials is a real property, and proxy authentication challenges (IsProxy protection spaces) use Proxy.Credentials ?? DefaultProxyCredentials.

Added an in-process HTTP forwarding proxy test server and tests covering proxy routing, proxy authentication (via Proxy.Credentials and DefaultProxyCredentials) and the proxy-related property behavior.

Fixes #14632.
Fixes #18635.

🤖 Pull request created by Copilot


Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Backport of #26021.

#26021)

The `Proxy` setter previously threw `PlatformNotSupportedException`, and `UseProxy`/`SupportsProxy` didn't allow any custom proxy configuration.

This implements custom proxy support:

* `Proxy` is now a real `IWebProxy` property. Since NSUrlSession applies proxy settings per-session (not per-request), the proxy returned by `IWebProxy.GetProxy` for the first request is translated into the session's `ConnectionProxyDictionary` and the session is recreated before the first request is sent (mirroring the `UseCookies` pattern).
* `UseProxy` is now a real settable bool. Setting it to `false` applies an empty connection proxy dictionary, which overrides any proxy configured in the OS.
* `SupportsProxy` now returns `true`.
* Proxy authentication is wired up: `DefaultProxyCredentials` is a real property, and proxy authentication challenges (`IsProxy` protection spaces) use `Proxy.Credentials ?? DefaultProxyCredentials`.

Added an in-process HTTP forwarding proxy test server and tests covering proxy routing, proxy authentication (via `Proxy.Credentials` and `DefaultProxyCredentials`) and the proxy-related property behavior.

Fixes #14632.
Fixes #18635.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 13, 2026 21:13
Copilot AI balanced review requested due to automatic review settings October 13, 2026 21:13
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Oct 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

CredentialCache proxy authentication can use the wrong URI scheme for HTTPS CONNECT challenges.

1 open finding
What changed in this PR

Backports custom proxy routing and authentication support for NSUrlSessionHandler.

Changes:

  • Configures per-session HTTP proxies and proxy disabling.
  • Handles proxy credentials and authentication challenges.
  • Adds local proxy/TLS infrastructure and regression tests.
File Description
src/​Foundation/​NSUrlSessionHandler.cs Implements proxy configuration and authentication.
tests/​monotouch-test/​System.Net.Http/​NSUrlSessionHandlerTest.cs Tests proxy routing, authentication, and properties.
tests/​monotouch-test/​System.Net.Http/​ProxyTestServer.cs Adds an HTTP forwarding proxy test server.
tests/​monotouch-test/​System.Net.Http/​TlsTestServer.cs Adds reusable local TLS infrastructure.
tests/​monotouch-test/​System.Net.Http/​MessageHandlers.cs Uses the shared TLS test server.

🧠 Review effort: Balanced

Comment thread src/Foundation/NSUrlSessionHandler.cs Resolved
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: a06dd61ff12e68d9d89941545679f64f32f5f674 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #a06dd61] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 200 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: a06dd61ff12e68d9d89941545679f64f32f5f674 [PR build]

@rolfbjarne
rolfbjarne merged commit 72b7bed into release/10.0.1xx Oct 14, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/backport-pr-26021-release/10.0.1xx-2026-10-13 branch October 14, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants