HttpRecorder.DevProxy 0.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HttpRecorder.DevProxy --version 0.5.0
                    
NuGet\Install-Package HttpRecorder.DevProxy -Version 0.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HttpRecorder.DevProxy" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HttpRecorder.DevProxy" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="HttpRecorder.DevProxy" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HttpRecorder.DevProxy --version 0.5.0
                    
#r "nuget: HttpRecorder.DevProxy, 0.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HttpRecorder.DevProxy@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HttpRecorder.DevProxy&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=HttpRecorder.DevProxy&version=0.5.0
                    
Install as a Cake Tool

HttpRecorder Dev Proxy Extension

This directory contains a Microsoft Dev Proxy plugin that integrates HttpRecorder to capture HTTP traffic and save it as HAR (HTTP Archive) files.

Overview

The HttpRecorder Dev Proxy plugin allows you to:

  • Intercept HTTP requests and responses passing through Dev Proxy
  • Record them using the HttpRecorder library
  • Save interactions as HAR files for later replay or analysis
  • Anonymize sensitive data like authorization headers
  • Filter which URLs to record

Project Structure

DevProxyExtension/
├── HttpRecorder.DevProxy/
│   ├── HttpRecorderPlugin.cs              # Main plugin implementation
│   ├── HttpRecorderPluginConfiguration.cs # Plugin configuration class
│   ├── BasePlugin.cs                      # Base class stub (replace with DevProxy.Abstractions)
│   └── HttpRecorder.DevProxy.csproj       # Project file
├── README.md                               # This file
└── devproxyrc.example.json                # Example Dev Proxy configuration

Prerequisites

  1. Microsoft Dev Proxy - Install using winget (recommended):

    # Stable version
    winget install DevProxy.DevProxy --silent
    
    # OR Beta version (for latest preview features)
    winget install DevProxy.DevProxy.Beta --silent
    

    Important: After installation, restart your command prompt to refresh the PATH environment variable.

    Alternative: Manual installation from Microsoft Dev Proxy Documentation

  2. .NET 9.0 SDK - Required for building the plugin

First Time Setup

When you start Dev Proxy for the first time:

  1. Trust the certificate: Dev Proxy installs a certificate named "Dev Proxy CA". Select Yes to confirm installation.
  2. Allow firewall access: Windows Firewall will show a warning. Select Allow access to permit traffic through the firewall.

Dev Proxy will display:

 info    Dev Proxy API listening on http://localhost:8897...
 info    Dev Proxy Listening on 127.0.0.1:8000...

Hotkeys: issue (w)eb request, (r)ecord, (s)top recording, (c)lear screen
Press CTRL+C to stop Dev Proxy

Important: Always stop Dev Proxy using Ctrl+C to safely unregister it as the system proxy. Closing the terminal without stopping Dev Proxy may cause connection issues.

Building the Plugin

# From the DevProxyExtension directory
cd HttpRecorder.DevProxy
dotnet build

# The plugin DLL will be at:
# bin/Debug/net9.0/HttpRecorder.DevProxy.dll

Configuration

Dev Proxy Configuration

Create or update your devproxyrc.json file:

{
  "plugins": [
    {
      "name": "HttpRecorderPlugin",
      "enabled": true,
      "pluginPath": "./DevProxyExtension/HttpRecorder.DevProxy/bin/Debug/net9.0/HttpRecorder.DevProxy.dll",
      "configSection": "httpRecorder"
    }
  ],
  "urlsToWatch": [
    "https://api.example.com/*",
    "https://graph.microsoft.com/*"
  ],
  "httpRecorder": {
    "outputDirectory": "./recordings",
    "mode": "Record",
    "includeBodies": true,
    "anonymizeSensitiveData": true,
    "sensitiveHeaders": [
      "Authorization",
      "Cookie",
      "Set-Cookie",
      "X-API-Key",
      "X-Auth-Token"
    ]
  }
}

Configuration Options

  • outputDirectory: Directory where HAR files will be saved (default: ./recordings)
  • mode: Recording mode - currently supports "Record" (default)
  • includeBodies: Whether to include request/response bodies (default: true)
  • anonymizeSensitiveData: Redact sensitive headers (default: true)
  • sensitiveHeaders: Array of header names to anonymize

Running Dev Proxy with the Plugin

# Start Dev Proxy with your configuration
devproxy --config-file devproxyrc.json

# Or if devproxyrc.json is in the current directory
devproxy

# For beta version
devproxy-beta --config-file devproxyrc.json

Verifying Dev Proxy is Working

Before using the plugin, confirm Dev Proxy is intercepting requests:

# Test with Invoke-WebRequest (PowerShell)
Invoke-WebRequest -Uri https://jsonplaceholder.typicode.com/posts

# Or with curl
curl -ikx http://localhost:8000 https://jsonplaceholder.typicode.com/posts

You should see output in the Dev Proxy terminal like:

 req   ╭ GET https://jsonplaceholder.typicode.com/posts
 time  │ 1/31/2025 12:12:14 PM +00:00
 api   ╰ Passed through

How It Works

  1. Request Interception: When Dev Proxy intercepts an HTTP request matching urlsToWatch, the BeforeRequestAsync method is called
  2. Request Recording: The plugin creates an Interaction object and stores request details (URL, method, headers, body)
  3. Response Interception: When the response arrives, AfterResponseAsync is called
  4. Response Recording: The plugin updates the interaction with response details (status code, headers, body, timing)
  5. HAR Export: The complete interaction is saved as a HAR file using HttpArchiveInteractionRepository

HAR File Output

Each recorded interaction is saved as a separate HAR file:

recordings/
├── 20251104_143022_1_api_example_com_users.har
├── 20251104_143023_2_api_example_com_orders.har
└── ...

Filenames include:

  • Timestamp (yyyyMMdd_HHmmss)
  • Interaction ID
  • Sanitized URL path

Integration with Dev Proxy Abstractions

Note: The current implementation includes a stub BasePlugin.cs class. For production use:

  1. Install Dev Proxy and locate DevProxy.Abstractions.dll
  2. Add it as a reference in the .csproj file:
<ItemGroup>
  <Reference Include="DevProxy.Abstractions">
    <HintPath>path/to/DevProxy.Abstractions.dll</HintPath>
  </Reference>
</ItemGroup>
  1. Remove the stub BasePlugin.cs file
  2. Update imports to use DevProxy.Abstractions namespace

Use Cases

  • API Testing: Record API interactions for test fixtures
  • Documentation: Generate HAR files to document API behavior
  • Debugging: Capture full request/response cycles for troubleshooting
  • Replay: Save production traffic for replay in test environments
  • Analysis: Analyze API performance and payloads

Example Workflow

# 1. Build the plugin
cd DevProxyExtension/HttpRecorder.DevProxy
dotnet build

# 2. Configure Dev Proxy (edit devproxyrc.json)

# 3. Start Dev Proxy
devproxy

# 4. Configure your application to use the proxy
$env:HTTP_PROXY = "http://localhost:8000"
$env:HTTPS_PROXY = "http://localhost:8000"

# 5. Run your application
# HTTP traffic will be recorded to ./recordings/

# 6. Stop Dev Proxy (Ctrl+C)

# 7. Review HAR files
ls ./recordings/*.har

Viewing HAR Files

HAR files can be viewed in:

Advanced Usage

Custom Anonymization Rules

Extend the plugin to add custom anonymization logic:

private void AnonymizeSensitiveHeaders(Dictionary<string, string> headers)
{
    // Existing logic...
    
    // Custom: Anonymize API keys in query strings
    if (headers.ContainsKey("X-Custom-Header"))
    {
        headers["X-Custom-Header"] = MaskApiKey(headers["X-Custom-Header"]);
    }
}

Filtering Requests

Modify BeforeRequestAsync to add custom filtering:

public override Task BeforeRequestAsync(ProxyRequestArgs e)
{
    // Only record POST/PUT requests
    if (e.Session.HttpClient.Request.Method != "POST" && 
        e.Session.HttpClient.Request.Method != "PUT")
    {
        return Task.CompletedTask;
    }
    
    // Continue with recording...
}

Troubleshooting

Plugin Not Loading

  • Verify the pluginPath in devproxyrc.json is correct
  • Check that the DLL was built successfully
  • Ensure .NET 9.0 runtime is installed

No HAR Files Generated

  • Check the outputDirectory has write permissions
  • Verify urlsToWatch patterns match your requests
  • Check Dev Proxy console for error messages

Missing Request/Response Bodies

  • Set includeBodies: true in configuration
  • Some content types may not be captured (binary, streaming)

Contributing

This plugin is part of the HttpRecorder.Next project. See the main README for contribution guidelines.

License

MIT License - see LICENSE file in the project root.

References

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.4 188 11/6/2025
0.7.0 178 11/6/2025
0.6.0 187 11/6/2025
0.5.0 180 11/5/2025
0.4.0 183 11/5/2025
0.3.0 184 11/5/2025
0.2.0 180 11/5/2025
0.0.2 191 11/5/2025
0.0.1 185 11/5/2025