Skip to content

Getting Started

TurboHTTP is a high-performance HTTP client for .NET built on Akka.Streams. It supports HTTP/1.0, HTTP/1.1, HTTP/2, and HTTP/3 (QUIC) with automatic retries, caching, cookies, and connection pooling — all built in.

New to TurboHTTP?

See Installation & Setup for DI registration, named clients, and the fluent builder API. Coming from HttpClient? Check the Migration Guide.

Quick Start

bash
dotnet add package TurboHTTP
csharp
using TurboHTTP;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddTurboHttpClient(options =>
{
    options.BaseAddress = new Uri("https://api.example.com");
});

var app = builder.Build();

var factory = app.Services.GetRequiredService<ITurboHttpClientFactory>();
var client = factory.CreateClient();

var response = await client.SendAsync(
    new HttpRequestMessage(HttpMethod.Get, "/users"),
    CancellationToken.None);

Console.WriteLine($"Status: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());

High-Throughput Usage

In addition to SendAsync, TurboHTTP exposes a channel-based API for scenarios where you want to stream requests and responses without await-ing each one individually.

csharp
var client = factory.CreateClient();

// Write requests to the input channel
ChannelWriter<HttpRequestMessage> requestWriter = client.Requests;

// Read responses from the output channel
ChannelReader<HttpResponseMessage> responseReader = client.Responses;

Use the channel API when:

  • You have a producer loop generating requests faster than you can await responses
  • You want to decouple request creation from response processing
  • You are integrating TurboHTTP into a pipeline that already uses System.Threading.Channels

Batch Pattern

Write requests from one task and read responses from another, running concurrently:

csharp
var client = factory.CreateClient();
client.BaseAddress = new Uri("https://api.example.com");
client.DefaultRequestVersion = HttpVersion.Version20;

var ids = Enumerable.Range(1, 1000).ToList();

// Producer: write all requests without waiting for responses
var producer = Task.Run(async () =>
{
    foreach (var id in ids)
    {
        var request = new HttpRequestMessage(HttpMethod.Get, $"/items/{id}");
        await client.Requests.WriteAsync(request);
    }
    client.Requests.Complete();
});

// Consumer: process responses as they arrive
var consumer = Task.Run(async () =>
{
    await foreach (var response in client.Responses.ReadAllAsync())
    {
        var body = await response.Content.ReadAsStringAsync();
        Console.WriteLine($"{(int)response.StatusCode}: {body.Length} bytes");
    }
});

await Task.WhenAll(producer, consumer);

With HTTP/2, all 1000 requests flow over a single TCP connection as concurrent streams. With HTTP/1.1, they are serialised per connection but the producer/consumer split still keeps throughput high.

Backpressure

The channel has a bounded capacity. If the connection cannot keep up with your producer, WriteAsync will pause automatically until there is room. You never drop requests — the channel applies backpressure instead.

What's Included

TurboHTTP works out of the box — no middleware to wire up, no Polly policies to configure.

FeatureDescription
HTTP/1.0, HTTP/1.1, HTTP/2 & HTTP/3Automatic version negotiation; HTTP/2 multiplexes over TCP, HTTP/3 multiplexes over QUIC
Automatic RetriesIdempotent methods (GET, PUT, DELETE) are retried automatically; respects Retry-After headers
Built-in CachingIn-memory LRU cache with ETag/Last-Modified conditional requests and Vary support
Redirect FollowingFollows 301/302/303/307/308 with correct method rewriting, loop detection, and auth header stripping
Cookie ManagementCookieJar stores Set-Cookie responses and injects cookies on subsequent requests automatically
Content EncodingAutomatic gzip, deflate, and Brotli decompression
Connection PoolingPer-host pools with idle eviction, automatic reconnect, and configurable concurrency limits
Channel-based APIChannelWriter/ChannelReader interface for backpressure-aware, high-throughput request pipelines

Next Steps

Setup & migration:

Feature guides:

Deep dive:

Released under the MIT License.