Skip to content

🚀 Getting Started

Welcome to CoreSystem.Http, a lightweight HTTP infrastructure library for ASP.NET Core and .NET 8.

This guide will help you capture and replay HTTP responses in just a few minutes.

By the end of this guide you will know how to:

  • Install the package
  • Register CoreSystem.Http
  • Capture an HTTP response
  • Replay a captured response

Estimated time: 5 minutes


📋 Prerequisites

Before getting started, ensure you have:

  • .NET 8 SDK
  • An ASP.NET Core application
  • Basic knowledge of Dependency Injection
  • Basic understanding of ASP.NET Core middleware

📦 Step 1 — Install the Package

Install the NuGet package.

dotnet add package CoreSystem.Http

⚙️ Step 2 — Register CoreSystem.Http

Register the framework in the dependency injection container.

builder.Services.AddCoreHttp();

This registers all services required to capture and replay HTTP responses.


🧩 Step 3 — Inject the Services

Inject the required services into your middleware, endpoint or application service.

public sealed class MyHandler(
    IResponseCapture responseCapture,
    IHttpResponseWriter responseWriter)
{
}

Both services are lightweight and registered by the framework.


▶️ Step 4 — Capture a Response

Capture the HTTP response generated by the ASP.NET Core pipeline.

CapturedResponse response =
    await responseCapture.CaptureAsync(
        context,
        next,
        cancellationToken);

The captured response contains:

  • Status code
  • Headers
  • Content type
  • Response body

The original response is restored automatically after capture.


🔁 Step 5 — Replay the Response

Replay a previously captured response.

await responseWriter.WriteAsync(
    context,
    response,
    cancellationToken);

The framework restores:

  • Status code
  • Headers
  • Content type
  • Response body

HEAD requests are handled automatically.


🛠 Typical Usage

CoreSystem.Http is designed as reusable infrastructure.

Typical scenarios include:

  • Response caching
  • Idempotency
  • Audit logging
  • API Gateways
  • Reverse proxies
  • Middleware development

Applications typically capture a response once and replay it multiple times depending on their business requirements.