Skip to content

[wasi] Add WasiHttpHandler functional test project - #136684

Open
lewing wants to merge 3 commits into
dotnet:mainfrom
lewing:lewing-wasi-http-handler-tests
Open

lewing wants to merge 3 commits into
dotnet:mainfrom
lewing:lewing-wasi-http-handler-tests

Conversation

@lewing

@lewing lewing commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Since #136234 (and with the handler fixes from #136261), System.Net.Http.Functional.Tests sets UseNativeHttpHandler=false on WASI, so it covers SocketsHttpHandler. The switch is process-wide and trimmed, so one assembly can't also test the wasi:http handler (WasiHttpHandler). This adds a WASI-only test project, System.Net.Http.WasiHttpHandler.Functional.Tests, that leaves the switch at its WASI default (true).

Test project

The project adds WasiHttpHandler_* classes for these shared test bases:

  • HttpClientHandlerTest
  • Asynchrony
  • Cancellation
  • IdnaProtocolTests
  • PostScenarioTest
  • ResponseStreamTest

It also includes HttpClientHandler_RemoteServerTest. PostScenarioTest and RemoteServerTest are OuterLoop on WASI.

The existing tests.proj glob picks the project up, which adds one Helix work item.

Skips

  • Capability gates:
    • The AutoRedirect, Decompression, Proxy and DefaultProxyCredentials classes use ConditionalClass on SupportsRedirectConfiguration, SupportsAutomaticDecompression and SupportsProxy. Those probes now live in the shared HttpClientHandlerTestBase.
    • In-body checks cover the same capabilities.
  • IsWasiHttpHandler (alongside IsWinHttpHandler) adds early returns for handler gaps with no public capability flag:
    • Credentials and PreAuthenticate
    • CookieContainer
    • MaxConnectionsPerServer
    • redirect following
    • synchronous stream I/O
  • Host behaviour: wasmtime's wasi:http behaviour is also gated:
    • It forbids hop-by-hop request headers and control characters.
    • It strips hop-by-hop response headers and rejects obs-fold.
    • It doesn't expose the reason phrase or let the client choose the HTTP version.
  • Outerloop helpers:
    • MD5 checks are gated on PlatformDetection.IsMD5Supported, using the echo server's existing Content-MD5-Skip path.
    • The HTTPS/HTTP2 local echo endpoints are dropped on WASI, which doesn't trust their dev certificate.

HttpProtocolTests isn't included: it checks status-line parsing that the wasi:http host performs, and Browser excludes it too.

Validation

CoreCLR WASI, Release, wasmtime 49.0.1, on main a932cb67bf6:

Suite Run Passed Failed Skipped
System.Net.Http.WasiHttpHandler.Functional.Tests 195 184 0 11
System.Net.Http.Functional.Tests (shared test changes) 1994 1810 0 184

Outerloop was validated before the rebase onto current main: 311 of 325 tests passed, with 0 failures, with every class except the two SupportsProxy-gated proxy classes.

Running the full outerloop scope still runs those proxy classes. WasmTestRunner lets -trait category=OuterLoop override -notrait category=failing, so ConditionalClass-gated classes run anyway. That's a separate runner issue affecting all WASI/browser projects. The WASI outerloop CI leg currently runs innerloop scope only.

Note

This PR description and the changes were generated with GitHub Copilot.

@azure-pipelines

azure-pipelines Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@lewing lewing added arch-wasm WebAssembly architecture os-wasi Related to WASI variant of arch-wasm labels Oct 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

lewing and others added 2 commits October 30, 2026 10:12
System.Net.Http.Functional.Tests now runs SocketsHttpHandler on WASI, so add
System.Net.Http.WasiHttpHandler.Functional.Tests, which leaves the
UseNativeHttpHandler switch at its WASI default and runs the shared
HttpClientHandler tests against WasiHttpHandler. Classes for proxy,
decompression and redirect configuration are gated on the HttpClientHandler
Supports* capabilities; handler limitations in shared tests are guarded with a
new IsWasiHttpHandler property next to IsWinHttpHandler.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Skip the MD5 checks in shared remote-server helpers when MD5 isn't supported
  (reuse the existing Content-MD5-Skip echo-server path).
- Drop the HTTPS local echo server endpoints on WASI, which doesn't trust
  their development certificate.
- Move the SupportsProxy/AutomaticDecompression/RedirectConfiguration probes to
  the shared test base and use them in the remote-server tests.
- Guard WasiHttpHandler gaps (Credentials, redirects, sync stream I/O) with
  IsWasiHttpHandler, and let the request-content-failure tests tolerate the
  wasi:http host abandoning the request before it connects.
- Remove the guards that the WasiHttpHandler content-failure fix makes
  unnecessary.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Net.Http os-wasi Related to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant