Skip to content

Commit 891f1a4

Browse files
committed
Update ReadMe
1 parent b155431 commit 891f1a4

1 file changed

Lines changed: 58 additions & 11 deletions

File tree

README.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,25 @@ TurboHTTP replaces `HttpClient` with a reactive, backpressure-aware HTTP pipelin
3232
### HTTP Features
3333

3434
- **Redirect following** — 301, 302, 303, 307, 308 with correct method rewriting (POST to GET on 303), body preservation on 307/308, loop detection, and HTTPS-to-HTTP downgrade protection. Configurable max redirects.
35-
- **Cookie management** — automatic cookie storage and injection across requests. Supports domain/path matching, `Secure`, `HttpOnly`, `SameSite`, `Max-Age`, and `Expires`. Bring your own `CookieJar` or use the built-in one.
36-
- **HTTP caching** — in-memory LRU cache with `Vary` support, conditional requests via `ETag`/`If-None-Match` and `Last-Modified`/`If-Modified-Since`, freshness evaluation (`max-age`, `s-maxage`, `Expires`, heuristic), and 304 response merging. Configurable via `CachePolicy`.
35+
- **Cookie management** — automatic cookie storage and injection across requests. Supports domain/path matching, `Secure`, `HttpOnly`, `SameSite`, `Max-Age`, and `Expires`. Bring your own `ICookieJar` implementation or use the built-in `CookieJar`.
36+
- **HTTP caching** — in-memory LRU cache with `Vary` support, conditional requests via `ETag`/`If-None-Match` and `Last-Modified`/`If-Modified-Since`, freshness evaluation (`max-age`, `s-maxage`, `Expires`, heuristic), and 304 response merging. Pluggable via `ICacheStore` for custom storage backends (Redis, disk, etc.).
3737
- **Content encoding** — automatic gzip, deflate, and Brotli response decompression. Optional request body compression. Can be disabled per-client if you need raw compressed bytes.
3838
- **100-Continue**`Expect: 100-continue` handling for large request bodies.
3939

4040
### Performance
4141

42-
- **Zero-allocation internals**`MemoryPool<byte>`, `Span<T>`, `ReadOnlyMemory<byte>`, `IBufferWriter<byte>`, and `System.Threading.Channels` throughout the hot path
42+
- **Zero-allocation internals**`MemoryPool<byte>`, `Span<T>`, `ReadOnlyMemory<byte>`, and `System.Threading.Channels` throughout the hot path
4343
- **HTTP/2 multiplexing** — multiple concurrent requests over a single TCP connection with header compression and per-stream flow control
4444
- **Backpressure** — Akka.Streams backpressure propagates end-to-end from the network to the caller, preventing buffer bloat and memory exhaustion under load
4545
- **Channel-based API** — for high-throughput scenarios, bypass `SendAsync` and write/read directly to `System.Threading.Channels` for pipelined I/O
4646

4747
### Extensibility
4848

4949
- **Handler pipeline** — compose custom request/response transforms via `TurboHandler` subclasses or inline delegates, ordered FIFO
50+
- **Pluggable storage** — bring your own `ICookieJar` for custom cookie persistence or `ICacheStore` for external cache backends (Redis, disk, etc.)
5051
- **Distributed tracing** — built-in OpenTelemetry-compatible tracing via `TracingBidiStage` for request/response lifecycle visibility
5152
- **DI integration** — first-class `IServiceCollection` support with named and typed clients, `IOptionsMonitor` for runtime configuration changes
52-
- **4,200+ tests** — unit tests, stream stage tests, integration tests, and benchmarks
53+
- **6,300+ tests** — unit tests, stream stage tests, acceptance tests, integration tests, API tests, and benchmarks
5354

5455
---
5556

@@ -106,8 +107,8 @@ services
106107
.WithRedirect()
107108
.WithCookies()
108109
.WithDecompression()
109-
.WithRetry(new RetryPolicy { MaxRetries = 3 })
110-
.WithCache(new CachePolicy { MaxEntries = 1000 });
110+
.WithRetry(retry => retry.MaxRetries = 3)
111+
.WithCache(cache => cache.MaxEntries = 1000);
111112
```
112113

113114
Then inject and use:
@@ -152,6 +153,48 @@ await foreach (var response in client.Responses.ReadAllAsync())
152153
}
153154
```
154155

156+
### Custom Cookie Jar
157+
158+
Implement `ICookieJar` to plug in your own cookie storage (e.g. encrypted, persistent, or shared across clients):
159+
160+
```csharp
161+
public sealed class PersistentCookieJar : ICookieJar
162+
{
163+
public void ProcessResponse(Uri requestUri, HttpResponseMessage response)
164+
{
165+
// parse Set-Cookie headers and persist to your backing store
166+
}
167+
168+
public void AddCookiesToRequest(Uri requestUri, ref HttpRequestMessage request)
169+
{
170+
// load cookies from your backing store and add Cookie header
171+
}
172+
}
173+
174+
services
175+
.AddTurboHttpClient("MyApi", options => { ... })
176+
.WithCookies(new PersistentCookieJar());
177+
```
178+
179+
### Custom Cache Store
180+
181+
Implement `ICacheStore` to use Redis, disk, or any other backend instead of the built-in in-memory LRU cache:
182+
183+
```csharp
184+
public sealed class RedisCacheStore : ICacheStore
185+
{
186+
public ICacheEntry? Get(HttpRequestMessage request) { /* Redis lookup */ }
187+
public void Put(HttpRequestMessage request, HttpResponseMessage response,
188+
IMemoryOwner<byte> bodyOwner, int bodyLength,
189+
DateTimeOffset requestTime, DateTimeOffset responseTime) { /* Redis store */ }
190+
public void Invalidate(Uri uri) { /* Redis delete */ }
191+
}
192+
193+
services
194+
.AddTurboHttpClient("MyApi", options => { ... })
195+
.WithCache(new RedisCacheStore(), cache => cache.MaxBodyBytes = 10_485_760);
196+
```
197+
155198
### Custom Handlers
156199

157200
Extend the pipeline with custom request/response transforms:
@@ -236,11 +279,15 @@ Full documentation — including feature guides, architecture deep-dives, and a
236279

237280
```bash
238281
# Restore and build
239-
dotnet restore ./src/TurboHTTP.sln
240-
dotnet build --configuration Release ./src/TurboHTTP.sln
241-
242-
# Run all tests
243-
dotnet test ./src/TurboHTTP.sln
282+
dotnet restore ./src/TurboHTTP.slnx
283+
dotnet build --configuration Release ./src/TurboHTTP.slnx
284+
285+
# Run tests by project
286+
dotnet test --project ./src/TurboHTTP.Tests/TurboHTTP.Tests.csproj # unit
287+
dotnet test --project ./src/TurboHTTP.StreamTests/TurboHTTP.StreamTests.csproj # stream stages
288+
dotnet test --project ./src/TurboHTTP.AcceptanceTests/TurboHTTP.AcceptanceTests.csproj # acceptance
289+
dotnet test --project ./src/TurboHTTP.IntegrationTests/TurboHTTP.IntegrationTests.csproj # integration (network)
290+
dotnet test --project ./src/TurboHTTP.API.Tests/TurboHTTP.API.Tests.csproj # public API surface
244291

245292
# Run benchmarks
246293
dotnet run --configuration Release --project ./src/TurboHTTP.Benchmarks/TurboHTTP.Benchmarks.csproj

0 commit comments

Comments
 (0)