API v1 checking… · p50 — · 0 installs/hr
v0.1.0
NuGet
View on GitHub
Cysharp
New
1 0

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.

Install via NuGet

NuGet package

Add via NuGetForUnity (recommended for Unity), a <PackageReference> in your .csproj, or the dotnet CLI. Click Install for the full instructions.

id HttpClientTestServer.Launcher.Container
Targets netstandard2.1, net8.0, net10.0 · Unity-compatible · Updated Apr 28, 2026
Install 0
nuget.org

README

Rendered from GitHub

HttpClientTestServer

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.
  • /not-found
    • Returns __Not_Found__ with status code 404 Not Found.
  • /response-headers
    • Sets response header x-test: foo and returns __OK__.
  • /slow-response-headers
    • Waits 1 second, then sets response header x-test: foo and returns __OK__. If the request is aborted, marks SessionStateFeature.Items["IsCanceled"] = true.
  • /ハロー
    • Returns Konnichiwa (Japanese path).
  • /slow-upload (POST)
    • Slowly reads and discards the entire request body (1-second delay per read) and then returns OK.
  • /post-echo (POST)
    • Reads the entire request body and returns it as application/octet-stream. Also echoes the request Content-Type into response header x-request-content-type.
  • /post-streaming (POST)
    • Immediately sends status code 200 OK and header x-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.
  • /post-response-trailers (POST)
    • Appends response trailers x-trailer-1: foo and x-trailer-2: bar, then returns __OK__ with status 200 OK.
  • /post-response-headers-immediately (POST)
    • Immediately sends status code 202 Accepted and header x-header-1: foo, waits 100 seconds, then writes __OK__ and returns an empty result.
  • /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 OK and header x-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.
  • /post-never-read (POST)
    • Immediately sends status code 200 OK and header x-header-1: foo, never reads the request body, and loops until the request is aborted, then returns an empty result.
  • /random (GET, query size)
    • Generates size random bytes using Random.Shared and returns them as application/octet-stream.
  • /error-reset (GET, HTTP/2 only)
    • Uses IHttpResetFeature to send an HTTP/2 stream reset with error code 2 (INTERNAL_ERROR) and then returns an empty result.
  • /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

Style
Preview
pkglnk installs badge
## 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
```

[![pkglnk](https://www.pkglnk.dev/badge/httpclienttestserver.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/httpclienttestserver)
Embed badge README snippet
Markdown
[![pkglnk installs](https://www.pkglnk.dev/badge/httpclienttestserver.svg)](https://www.pkglnk.dev/pkg/httpclienttestserver)
HTML
<a href="https://www.pkglnk.dev/pkg/httpclienttestserver"><img src="https://www.pkglnk.dev/badge/httpclienttestserver.svg" alt="pkglnk installs"></a>
URL
https://www.pkglnk.dev/badge/httpclienttestserver.svg

Comments

No comments yet. Be the first!