RuriLib.Http 2.0.0

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

RuriLib.Http

This is a library that provides a custom HTTP client, an HttpMessageHandler to be used with the default HttpClient of System.Net, and a curl-impersonate-backed HTTP client for browser-like TLS and HTTP fingerprints. It sits on top of RuriLib.Proxies which provides a layer 4 proxied connection.

Features:

  • Custom proxied HTTP client
  • HttpMessageHandler integration with System.Net.Http.HttpClient
  • curl-impersonate integration with packaged native runtime assets
  • HTTP, SOCKS and proxiless connections through RuriLib.Proxies
  • gzip, deflate, brotli and zstd response decoding
  • Cookie parsing and cookie container support

Requirements

Version 2.x targets .NET 10.

Installation

NuGet: dotnet add package RuriLib.Http

Example (Custom Client)

using RuriLib.Http;
using RuriLib.Http.Models;
using RuriLib.Proxies;
using RuriLib.Proxies.Clients;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace HttpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            _ = MainAsync(args);
            Console.ReadLine();
        }

        static async Task MainAsync(string[] args)
        {
            // Set up the proxy client (see RuriLib.Proxies documentation, here we use
            // a NoProxyClient for simplicity)
            var settings = new ProxySettings();
            var proxyClient = new NoProxyClient(settings);

            // Create the custom proxied client
            using var client = new RLHttpClient(proxyClient);

            // Create the request
            using var request = new HttpRequest
            {
                Uri = new Uri("https://httpbin.org/anything"),
                Method = HttpMethod.Post,
                Headers = new Dictionary<string, string>
                {
                    { "Authorization", "Bearer ey..." }
                },
                Cookies = new Dictionary<string, string>
                {
                    { "PHPSESSID", "12345" }
                },

                // Content a.k.a. the "post data"
                Content = new StringContent("My content", Encoding.UTF8, "text/plain")
            };

            // Send the request and get the response (this can fail so make sure to wrap it in a try/catch block)
            using var response = await client.SendAsync(request);

            // Read and print the content of the response
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Example (HttpClient)

This example is equivalent to the one above, but it uses the default HttpClient so you can take advantage of the API you are already familiar with.

using RuriLib.Http;
using RuriLib.Proxies;
using RuriLib.Proxies.Clients;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace HttpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            _ = MainAsync(args);
            Console.ReadLine();
        }

        static async Task MainAsync(string[] args)
        {
            // Set up the proxy client (see RuriLib.Proxies documentation, here we use
            // a NoProxyClient for simplicity)
            var settings = new ProxySettings();
            var proxyClient = new NoProxyClient(settings);

            // Create the handler that will be passed to HttpClient
            var handler = new ProxyClientHandler(proxyClient)
            {
                // This adds cookie support
                CookieContainer = new CookieContainer()
            };

            // Create the proxied HttpClient and the cookie container
            using var client = new HttpClient(handler);

            // Create the request
            using var request = new HttpRequestMessage
            {
                RequestUri = new Uri("https://httpbin.org/anything"),
                Method = HttpMethod.Post,
                
                // Content a.k.a. the "post data"
                Content = new StringContent("My content", Encoding.UTF8, "text/plain")
            };

            request.Headers.TryAddWithoutValidation("Authorization", "Bearer ey...");
            handler.CookieContainer.Add(request.RequestUri, new Cookie("PHPSESSID", "12345"));

            // Send the request and get the response (this can fail so make sure to wrap it in a try/catch block)
            using var response = await client.SendAsync(request);

            // Read and print the content of the response
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Example (curl-impersonate)

This example uses curl-impersonate for browser-like TLS and HTTP fingerprints.

using RuriLib.Http.Curl;
using RuriLib.Http.Models;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace HttpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            _ = MainAsync(args);
            Console.ReadLine();
        }

        static async Task MainAsync(string[] args)
        {
            var options = new CurlImpersonateHandlerOptions
            {
                BrowserProfile = CurlImpersonateBrowserProfile.Chrome142
            };

            using var client = new CurlImpersonateHttpClient(options);
            using var request = new HttpRequest
            {
                Uri = new Uri("https://example.com"),
                Method = HttpMethod.Get
            };

            using var response = await client.SendAsync(request);
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Changelog

See CHANGELOG.md for release notes.

Credits

Some portions of the code were the work of Ruslan Khuduev and Artem Dontsov, to which I am grateful, all rights are reserved to them. Their work is under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
2.0.0 58 6/6/2026
1.0.1 1,771 3/9/2022
1.0.0 1,603 1/10/2022