Giter Site home page Giter Site logo

proxykingdom / proxy-client Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 232 KB

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

License: MIT License

C# 100.00%
http socks4 socks4a socks5 sockets socket-programming proxy proxy-client

proxy-client's Introduction

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.

proxy-client's People

Contributors

bokklu avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cuteofdragon

proxy-client's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.