Skip to content

The Proxy Client library allows the user to send and receive requests over Http, Socks4/4a/5 proxies.

License

Notifications You must be signed in to change notification settings

proxykingdom/proxy-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proxy.Client

Proxy.Client Build NuGet GitHub .NET .NET Downloads

The Proxy Client library allows the user to send and receive requests over Http, Socks4/4a/5 proxies.

Installation

Install as Nuget Package

Install-Package Proxy.Client

.NET CLI:

dotnet add package Proxy.Client

Basic Usage

using(var socks4ProxyClient = new Socks4ProxyClient("212.86.75.9", 4153))
{
    var response = await socks4ProxyClient.GetAsync("https://www.example.com/");
}

Adding Headers

using(var socks4ProxyClient = new Socks4ProxyClient("212.86.75.9", 4153))
{
    var proxyHeaders = new List<ProxyHeader>
    {
        ProxyHeader.Create("User-Agent", "My-UserAgent"),
        ProxyHeader.Create("Cache-Control", "no-cache")
    };
    
    var response = await socks4ProxyClient.GetAsync("https://www.example.com/", headers: proxyHeaders);
}

Adding Cookies

using(var socks4ProxyClient = new Socks4ProxyClient("212.86.75.9", 4153))
{
    var proxyCookies = new List<Cookie>
    {
        new Cookie("Id", "a3fWa"),
        new Cookie("Expires", "Thu, 31 Oct 2021 07:28:00 GMT")
    };
    
    var response = await socks4ProxyClient.GetAsync("https://www.example.com/", cookies: proxyCookies);
}

Adding Timeouts

Below is an example of a request with a 10 second total timeout and 1 second read/write timeout:

using(var socks4ProxyClient = new Socks4ProxyClient("212.86.75.9", 4153))
{
    var response = await socks4ProxyClient.GetAsync("https://www.example.com/", totalTimeout: 10000, readTimeout: 1000, writeTimeout: 1000);
}

Keep-Alive Support

By default, all connections are persistent. To force the connection/socket closure, set the isKeepAlive flag to False:

using(var socks4ProxyClient = new Socks4ProxyClient("212.86.75.9", 4153))
{
    var response = await socks4ProxyClient.GetAsync("https://www.example.com/", isKeepAlive: False);
}

Contribution

Feel free to open an issue or submit a pull request.

About

The Proxy Client library allows the user to send and receive requests over Http, Socks4/4a/5 proxies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages