Test HTTP server for YetAnotherHttpHandler, supporting HTTP/1, HTTP/2, and HTTPS with configurable TLS versions. Launch in-process or via Docker container with endpoints for testing various client scenarios including streaming, trailers, and request cancellation. Essential for validating HTTP client implementations in Unity projects.
NuGet package
Add via NuGetForUnity (recommended for Unity), a <PackageReference> in your .csproj,
or the dotnet CLI. Click Install for the full instructions.
HttpClientTestServer.Launcher.Container README
Rendered from GitHubHttpClientTestServer
Test HTTP Server for YetAnotherHttpHandler
Usage
Using Docker
docker run --rm -it -p 8080:80 ghcr.io/cysharp/httpclienttestserver:main --port 80 --protocol Http1AndHttp2 --secure --tls Tls13
Commandline options
--port <port>: Port to listen on (default: 80)--protocol <Http1|Http2|Http1AndHttp2>: Protocol to support (default: Http1AndHttp2)--secure: Enable HTTPS (default: false)--tls <None|Tls12|Tls13>: TLS protocol version to use (default: None(Auto))--uds <path>: Unix Domain Socket path to listen on (default: none)--enable-client-cert-validation: Enable client certificate validation (default: false)
Using from C#
Reference the HttpClientTestServer.Launcher project and call the {InProcess,Container}TestServer.LaunchAsync method.
await using var server = await InProcessTestServer.LaunchAsync(
TestServerListenMode.SecureHttp1AndHttp2,
new TestOutputLoggerProvider(TestOutputHelper),
TimeoutToken,
new TestServerOptions(SslProtocols.Tls13)
);
Endpoint
The server exposes the following endpoints:
/- Returns
__OK__as the response body.
- Returns
/not-found- Returns
__Not_Found__with status code404 Not Found.
- Returns
/response-headers- Sets response header
x-test: fooand returns__OK__.
- Sets response header
/slow-response-headers- Waits 1 second, then sets response header
x-test: fooand returns__OK__. If the request is aborted, marksSessionStateFeature.Items["IsCanceled"] = true.
- Waits 1 second, then sets response header
/ハロー- Returns
Konnichiwa(Japanese path).
- Returns
/slow-upload(POST)- Slowly reads and discards the entire request body (1-second delay per read) and then returns
OK.
- Slowly reads and discards the entire request body (1-second delay per read) and then returns
/post-echo(POST)- Reads the entire request body and returns it as
application/octet-stream. Also echoes the requestContent-Typeinto response headerx-request-content-type.
- Reads the entire request body and returns it as
/post-streaming(POST)- Immediately sends status code
200 OKand headerx-header-1: foo, streams and counts all incoming request bytes, then writes the total byte length as the response body and returns an empty result.
- Immediately sends status code
/post-response-trailers(POST)- Appends response trailers
x-trailer-1: fooandx-trailer-2: bar, then returns__OK__with status200 OK.
- Appends response trailers
/post-response-headers-immediately(POST)- Immediately sends status code
202 Acceptedand headerx-header-1: foo, waits 100 seconds, then writes__OK__and returns an empty result.
- Immediately sends status code
/post-abort-while-reading(POST)- Reads once from the request body, then aborts the HTTP context, terminating the connection, and returns an empty result.
/post-null(POST)- Continuously reads and discards the request body until it is completed, canceled, or the request is aborted, then returns an empty result.
/post-null-duplex(POST)- Immediately sends status code
200 OKand headerx-header-1: foo, then continues to read and discard the request body until it is completed, canceled, or the request is aborted, and returns an empty result.
- Immediately sends status code
/post-never-read(POST)- Immediately sends status code
200 OKand headerx-header-1: foo, never reads the request body, and loops until the request is aborted, then returns an empty result.
- Immediately sends status code
/random(GET, querysize)- Generates
sizerandom bytes usingRandom.Sharedand returns them asapplication/octet-stream.
- Generates
/error-reset(GET, HTTP/2 only)- Uses
IHttpResetFeatureto send an HTTP/2 stream reset with error code2(INTERNAL_ERROR) and then returns an empty result.
- Uses
/connection-state/active-connections- Returns the current status of active connections
Certificates
The server uses a self-signed certificate. You can obtain this certificate from the repository or by accessing /_certs/localhost.{crt,key,pfx}.
License
MIT License
Versions 0
No versions tracked yet.
Dependencies 0
No dependencies.
Changelog 0 releases
No changelog entries yet. Run the admin Changelog & Version Scanner to pull from the repository's CHANGELOG.md.
README Markdown
Copy this to your project's README.md
## Installation
Add **Container** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/httpclienttestserver.git
```
[](https://www.pkglnk.dev/pkg/httpclienttestserver)Embed badge README snippet
[](https://www.pkglnk.dev/pkg/httpclienttestserver) <a href="https://www.pkglnk.dev/pkg/httpclienttestserver"><img src="https://www.pkglnk.dev/badge/httpclienttestserver.svg" alt="pkglnk installs"></a> https://www.pkglnk.dev/badge/httpclienttestserver.svg Comments
No comments yet. Be the first!


Sign in to join the conversation
Sign In