Unobtanium.Web.Proxy.Events 0.9.0-beta.1

This is a prerelease version of Unobtanium.Web.Proxy.Events.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Unobtanium.Web.Proxy.Events --version 0.9.0-beta.1
                    
NuGet\Install-Package Unobtanium.Web.Proxy.Events -Version 0.9.0-beta.1
                    
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="Unobtanium.Web.Proxy.Events" Version="0.9.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unobtanium.Web.Proxy.Events" Version="0.9.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="Unobtanium.Web.Proxy.Events" />
                    
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 Unobtanium.Web.Proxy.Events --version 0.9.0-beta.1
                    
#r "nuget: Unobtanium.Web.Proxy.Events, 0.9.0-beta.1"
                    
#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 Unobtanium.Web.Proxy.Events@0.9.0-beta.1
                    
#: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=Unobtanium.Web.Proxy.Events&version=0.9.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Unobtanium.Web.Proxy.Events&version=0.9.0-beta.1&prerelease
                    
Install as a Cake Tool

Unobtanium Web Proxy

A lightweight HTTP(S) proxy server written in C# NET8.0.

Unobtanium web proxy nuget github issues License Build status Support me on Github

Report bugs or raise issues here.

Project reboot

Unobtanium web proxy

This project is a reboot of the original Titanium-Web-Proxy project. The original project was last updated two years ago, has been archived by the author on July 9th 2023 and has been inactive since then. This project aims to continue the development of the original project and provide a stable and reliable proxy server library for .NET developers.

Announcement Reboot discussion Issues

Reboot focus

  • net8.0 only (no support for older versions of .NET!)
  • Support for ILogger See #4
  • Support for diagnostic events using ActivitySource and Activity See #3
  • Using the latest .NET features like Span<T> and Memory<T> to improve performance
  • Update dependencies to the latest versions
  • TLS 1.2 and TLS 1.3 only support
  • Modern Event System: Event-handlers with HttpRequestMessage and HttpResponseMessage, to greatly improve the portability of the library See #6
  • HttpClient as the default client, and using the IHttpClientFactory to handle pooling of the clients
  • Testing, testing, testing!

Modern Event System

This proxy server uses a modern, clean event system based on standard HttpRequestMessage and HttpResponseMessage objects, making it easier to integrate with existing .NET HTTP libraries and patterns.

Request Interception

var config = new ProxyServerConfiguration();
config.Events.OnRequest += async (sender, e, cancellationToken) =>
{
    Console.WriteLine($"Request: {e.Request.Method} {e.Request.RequestUri}");
    
    // Block specific domains
    if (e.Request.RequestUri?.Host.Contains("blocked.com") == true)
    {
        var blockedResponse = new HttpResponseMessage(HttpStatusCode.Forbidden)
        {
            Content = new StringContent("Access Denied")
        };
        return RequestEventResponse.EarlyResponse(blockedResponse);
    }
    
    // Modify request headers
    e.Request.Headers.Add("X-Proxy-Agent", "Unobtanium");
    
    // Redirect requests
    if (e.Request.RequestUri?.Host.Contains("example.com") == true)
    {
        var redirectedRequest = new HttpRequestMessage(e.Request.Method, "https://microsoft.com")
        {
            Content = e.Request.Content,
            Version = e.Request.Version
        };
        
        // Copy headers
        foreach (var header in e.Request.Headers)
        {
            redirectedRequest.Headers.TryAddWithoutValidation(header.Key, header.Value);
        }
        
        return RequestEventResponse.ModifyRequest(redirectedRequest);
    }
    
    return RequestEventResponse.ContinueResponse();
};

Response Interception

config.Events.OnResponse += async (sender, e, cancellationToken) =>
{
    Console.WriteLine($"Response: {e.Response.StatusCode} from {e.Request.RequestUri}");
    
    // Modify responses
    if (e.Response.Content != null)
    {
        var content = await e.Response.Content.ReadAsStringAsync(cancellationToken);
        if (content.Contains("error"))
        {
            var modifiedResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(content.Replace("error", "success")),
                Version = e.Response.Version
            };
            
            // Copy headers
            foreach (var header in e.Response.Headers)
            {
                modifiedResponse.Headers.TryAddWithoutValidation(header.Key, header.Value);
            }
            
            return ResponseEventResponse.ModifyResponse(modifiedResponse);
        }
    }
    
    return ResponseEventResponse.ContinueResponse();
};

Features

  • API Documentation
  • Wiki & Contribution guidelines
  • Multithreaded and asynchronous proxy employing server connection pooling, certificate cache, and buffer pooling
  • View, modify, redirect and block requests or responses
  • Modern event system based on HttpRequestMessage and HttpResponseMessage
  • Supports mutual SSL authentication, proxy authentication & automatic upstream proxy detection
  • Supports kerberos, NTLM authentication over HTTP protocols on windows domain controlled networks
  • SOCKS4/5 Proxy support

Installation

Package on NuGet, Unobtanium.Web.Proxy will be a partial drop-in replacement for Titanium.Web.Proxy, if you're on NET8.0 or higher.

dotnet add package Unobtanium.Web.Proxy

Supports

  • .NET 8.0 and above

As stated above, this project is a reboot of the original project. Expect things to change, everything marked as obsolete in the original project will be removed in this project. And until this is v1.0.0, expect breaking changes.

Usage

using Unobtanium.Web.Proxy;
using Microsoft.Extensions.DependencyInjection;

// Use dependency injection to create the proxy server (this will be the preferred way to create the proxy server in the future)
// ActivitySource (for tracing) and ILogger are optional, but recommended
// Since the ProxyServer has to be a singleton, you have to register the configuration as a singleton as well
services.AddSingleton<ProxyServerConfiguration>(...);
services.AddSingleton<ProxyServer>();

// Get the proxy server from the service provider
var proxyServer = provider.GetRequiredService<ProxyServer>();

Complete Example

var config = new ProxyServerConfiguration();

// Handle requests with HttpRequestMessage
config.Events.OnRequest += async (sender, e, cancellationToken) =>
{
    Console.WriteLine($"Request: {e.Request.Method} {e.Request.RequestUri}");
    
    // Block specific domains
    if (e.Request.RequestUri?.Host.Contains("blocked.com") == true)
    {
        var blockedResponse = new HttpResponseMessage(HttpStatusCode.Forbidden)
        {
            Content = new StringContent("Access Denied")
        };
        return RequestEventResponse.EarlyResponse(blockedResponse);
    }
    
    // Modify request headers
    e.Request.Headers.Add("X-Proxy-Agent", "Unobtanium");
    
    return RequestEventResponse.ContinueResponse();
};

// Handle responses with HttpResponseMessage  
config.Events.OnResponse += async (sender, e, cancellationToken) =>
{
    Console.WriteLine($"Response: {e.Response.StatusCode} from {e.Request.RequestUri}");
    return ResponseEventResponse.ContinueResponse();
};

var proxyServer = new ProxyServer(config);

// Add endpoints
var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true);
proxyServer.AddEndPoint(explicitEndPoint);

// Start the proxy
await proxyServer.StartAsync();

Console.WriteLine($"Proxy listening on {explicitEndPoint.IpAddress}:{explicitEndPoint.Port}");

// Set as system proxy
proxyServer.SetAsSystemProxy(explicitEndPoint, ProxyProtocolType.AllHttp);

// Stop when done
proxyServer.Stop();

Collaborators

The owner of this project, justcoding121, is considered to be inactive from this project due to his busy work schedule. See project reboot for more information.

Previous contributors:

Current contributors:

You contributions are more then welcome! Let's make this project great again!

Development environment

Since this is a dotnet project I would suggest to use Visual Studio 2022 or Visual Studio Code as your development environment. The project is set up to use the dotnet CLI, so you can also use that to build and run the project.

Console example application screenshot

alt tag

GUI example application screenshot

alt tag

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Unobtanium.Web.Proxy.Events:

Package Downloads
Unobtanium.Web.Proxy

A web inspecting proxy library you can intgrate in your own application. Build in NET8.0 for maximum speed.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.1-beta-2 139 8/18/2025
0.9.1-beta.2 125 8/18/2025
0.9.1-beta.1 123 8/14/2025
0.9.0-beta.1 199 8/7/2025