Http2Client 1.1.3

dotnet add package Http2Client --version 1.1.3
                    
NuGet\Install-Package Http2Client -Version 1.1.3
                    
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="Http2Client" Version="1.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Http2Client" Version="1.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Http2Client" />
                    
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 Http2Client --version 1.1.3
                    
#r "nuget: Http2Client, 1.1.3"
                    
#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 Http2Client@1.1.3
                    
#: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=Http2Client&version=1.1.3
                    
Install as a Cake Addin
#tool nuget:?package=Http2Client&version=1.1.3
                    
Install as a Cake Tool

Target Frameworks Build and Release GitHub Release NuGet

Http2Client

Http2Client provides customizable HTTP/2 clients with TLS fingerprinting capabilities. Based on bogdanfinn/tls-client, it allows you to mimic specific browser fingerprints and control detailed aspects of TLS behavior in your .NET applications.

Installation

dotnet add package Http2Client

Native Library Dependencies

Http2Client requires the native TLS library from the original bogdanfinn/tls-client repository. Download the appropriate library for your platform from the latest release:

Operating System Architecture Library File Download Link
Windows x64 (64-bit) tls-client-windows-64-1.11.0.dll Download
Windows x86 (32-bit) tls-client-windows-32-1.11.0.dll Download
Linux AMD64 (64-bit) tls-client-linux-ubuntu-amd64-1.11.0.so Download
Linux ARM64 tls-client-linux-arm64-1.11.0.so Download
Linux ARMv7 tls-client-linux-armv7-1.11.0.so Download
macOS AMD64 (Intel) tls-client-darwin-amd64-1.11.0.dylib Download
macOS ARM64 (Apple Silicon) tls-client-darwin-arm64-1.11.0.dylib Download

📋 Full Library List: For additional architectures and XGO builds (including Linux 386, ARM variants, PowerPC, RISC-V, s390x), see the complete list at v1.11.0 release page.

Installation Instructions:

  1. Download the appropriate library file for your platform from the table above
  2. Place the native library in your application's output directory, or
  3. Specify the custom path using the WithLibraryPath() method in your code

Example for Windows:

using var client = new HttpClientBuilder()
    .WithLibraryPath("tls-client-windows-64-1.11.0.dll")
    .Build();

Important: The native library is required for Http2Client to function properly. Always use the latest version from the original repository releases.

Note: When building your application, ensure the correct native library is included in your published application. For cross-platform deployment, you may need to include multiple libraries and select the appropriate one at runtime based on the target platform.

Basic Usage

Below is a full example that shows how to configure an Http2Client, build a request, and send it.

using Http2Client;
using Http2Client.Builders;
using Http2Client.Core.Enums;
using Http2Client.Core.Request;

// Create an Http2Client instance using the builder
using var client = new HttpClientBuilder()
    .WithLibraryPath("tls-client-windows-64-1.11.0.dll")
    .WithBrowserType(BrowserType.Chrome133)
    .WithUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithCookies()
    .Build();

// Create a request
var request = new HttpRequest
{
    RequestUrl = "https://httpbin.org/post",
    RequestMethod = "POST",
    RequestBody = "{\"message\": \"Hello from Http2Client\"}",
    Headers = { ["Content-Type"] = "application/json" }
};

// Send the request
var response = client.Send(request);

Console.WriteLine($"Status: {response.Status}");
Console.WriteLine($"Body: {response.Body}");

Session Management

Http2Client provides methods for managing cookies and sessions:

// Get cookies for a specific URL
var cookies = client.GetCookies("https://example.com");

// Add cookies to session
var newCookies = new List<ClientCookie> 
{
    new ClientCookie("session", "abc123")
};
client.AddCookies("https://example.com", newCookies);

// Clean up session when done
client.DestroySession();

HttpClientBuilder

The HttpClientBuilder class provides a fluent interface to create and configure an Http2Client instance with custom options such as browser fingerprints, headers, proxy settings, timeouts, and other TLS behaviors.

using var client = new HttpClientBuilder()
    .WithBrowserType(BrowserType.Chrome133)
    .WithUserAgent("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36")
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithCookies()
    .Build();

Builder Methods

Method Description
WithLibraryPath(string) Sets the path to the native TLS library.
WithBrowserType(BrowserType) Sets the browser fingerprint to mimic.
WithUserAgent(string) Sets the User-Agent header.
WithTimeout(TimeSpan) Sets the request timeout.
WithProxy(string, bool) Configures proxy URL and rotation setting.
WithInsecureSkipVerify(bool) Skips SSL certificate verification.
WithRandomTlsExtensions(bool) Randomizes TLS extension order.
WithCookies(bool) Enables automatic cookie handling.
WithoutCookieJar(bool) Disables all cookie handling.
WithDebug(bool) Enables debug logging.
WithDisableIPv4(bool) Disables IPv4 connections.
WithDisableIPv6(bool) Disables IPv6 connections.
WithFollowRedirects(bool) Enables automatic redirect following.
WithForceHttp1(bool) Forces HTTP/1.1 instead of HTTP/2.
WithHeader(string, string) Sets a default header.
WithHeaders(Dictionary<string, string>) Sets multiple default headers.
WithHeaderOrder(params string[]) Sets the order of HTTP headers.
WithSessionId(Guid) Sets the session ID for this client.
WithCustomHttp2Client(CustomHttp2Client) Uses custom TLS fingerprint.
WithCatchPanics(bool) Catches native library panics.

Advanced Example

using var client = new HttpClientBuilder()
    .WithLibraryPath("tls-client-windows-64-1.11.0.dll")
    .WithBrowserType(BrowserType.Firefox132)
    .WithUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
    .WithProxy("http://127.0.0.1:8888", isRotating: true)
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithDebug(true)
    .WithFollowRedirects(true)
    .WithInsecureSkipVerify(false)
    .WithDisableIPv6(true)
    .WithHeader("X-Custom-Header", "MyValue")
    .WithCookies()
    .Build();

HttpRequest

The HttpRequest class represents an HTTP request with all necessary configuration. You can create it directly or use the builder pattern.

HttpRequestBuilder

For more complex request configuration, use the fluent HttpRequestBuilder:

var request = new HttpRequestBuilder()
    .WithUrl("https://api.example.com/data")
    .WithMethod(HttpMethod.Post)
    .WithJsonBody(new { name = "John", age = 30 })
    .WithBrowserType(BrowserType.Chrome133)
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithProxy("http://proxy.example.com:8080")
    .Build();

var response = client.Send(request);

Direct Usage

var request = new HttpRequest
{
    RequestUrl = "https://example.com/api/data",
    RequestMethod = "POST",
    RequestBody = "{\"id\": 123, \"name\": \"example\"}",
    Headers = 
    {
        ["Content-Type"] = "application/json",
        ["Authorization"] = "Bearer token"
    },
    BrowserType = BrowserType.Chrome133,
    TimeoutMilliseconds = 30000
};

Key Properties

Property Description
RequestUrl The target URL (required).
RequestMethod HTTP method (GET, POST, etc.).
RequestBody Request body content.
Headers Dictionary of HTTP headers.
BrowserType Browser fingerprint to use.
TimeoutMilliseconds Request timeout in milliseconds.
TimeoutSeconds Request timeout in seconds.
ProxyUrl Proxy server URL.
InsecureSkipVerify Skip SSL certificate verification.
FollowRedirects Follow HTTP redirects automatically.
RequestCookies List of cookies for this request.
WithDebug Enable debug logging for this request.

Features

  • HTTP/2 and HTTP/1.1 support
  • TLS fingerprinting with multiple browser profiles
  • Cross-platform (Windows, Linux, macOS)
  • Proxy support (HTTP, HTTPS, SOCKS5)
  • Cookie management
  • Custom headers and SSL configuration

Examples

GET Request with Custom Headers

using var client = new HttpClientBuilder()
    .WithLibraryPath("tls-client-windows-64-1.11.0.dll")
    .WithBrowserType(BrowserType.Chrome133)
    .Build();

var request = new HttpRequest
{
    RequestUrl = "https://httpbin.org/headers",
    RequestMethod = "GET",
    Headers = 
    {
        ["X-Custom-Header"] = "custom-value",
        ["User-Agent"] = "MyApp/1.0"
    }
};

var response = client.Send(request);
Console.WriteLine(response.Body);

POST Request with JSON Body

var request = new HttpRequest
{
    RequestUrl = "https://httpbin.org/post",
    RequestMethod = "POST",
    RequestBody = "{\"name\": \"John\", \"age\": 30}",
    Headers = { ["Content-Type"] = "application/json" }
};

var response = client.Send(request);

Using Proxy

using var client = new HttpClientBuilder()
    .WithLibraryPath("tls-client-windows-64-1.11.0.dll")
    .WithBrowserType(BrowserType.Chrome133)
    .WithProxy("http://proxy.example.com:8080")
    .Build();

Target Frameworks

Http2Client supports multiple .NET versions:

  • .NET Standard 2.0 - For maximum compatibility
  • .NET 5.0 - Legacy LTS support
  • .NET 6.0 - LTS support
  • .NET 8.0 - Current LTS
  • .NET 9.0 - Latest version

License

Licensed under MIT. Report an Issue

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
1.1.3 18 8/10/2025
1.0.3 164 8/6/2025
1.0.0 318 8/6/2025 1.0.0 is deprecated because it is no longer maintained and has critical bugs.