Git Product home page Git Product logo

mvnet_old's Introduction

New Version

This library uses Rebex, because Rebex did not support cookies before this project was created. To use the new MVNet library, click here.

MVNet

Supports TLS/SSL

  • tls 1.0
  • tls 1.1
  • tls 1.2
  • tls 1.3
  • SSL 3.0

Supports a variety of proxies

  • Http/s
  • Socks4
  • Socks4a
  • Socks5

Supports Proxy Authentication

  • Basic Authentication
  • Digest Authentication
  • Windows NT Challenge/Response authentication (ntlm)

HTTP Methods

  • GET
  • HEAD
  • OPTIONS
  • DELETE
  • POST
  • PUT
  • PATCH

Features

Using

using MVNet;

try
{
    var hr = new HttpRequest();
    var res = hr.Get("https://api.ipify.org?format=json");
    if (res.IsOk)
    {
        Console.WriteLine(res.Content);
    }
    else
    {
        Console.WriteLine(res.StatusCode);
    }
}
catch (HttpException ex)
{
    Console.WriteLine(ex.Message);
}

How to use StringContent

StringContent content = new StringContent();
content.ContentType = "contenttype"; //Default is application/x-www-form-urlencoded
content["name1"] = "value1";
content["name2"] = "value2";

//Or

StringContent content = new StringContent("queryparams", "contenttype", encode);

How to use MultipartContent

MultipartContent content = new MultipartContent(); //Generate random boundary
//Or
MultipartContent content = new MultipartContent("boundary");

content.AddParam("name", "value");
content.AddParam("name", "filename", "contenttype");

How to use StreamContent

StreamContent content = new StreamContent(stream); //Default ContentType is application/x-www-form-urlencoded
//Or
StreamContent content = new StreamContent(stream, contentType);
//Or
StreamContent content = new StreamContent(stream, contentType, size);

Ssl Accept All Certificates(ON/OFF)

//ON
var hr = new HttpRequest()
{
    AcceptAllCert = true
};

//OFF
var hr = new HttpRequest()
{
    AcceptAllCert = false
};

Set Proxy

ProxyClient pc = new ProxyClient(type, "host:port");
//Or
ProxyClient pc = new ProxyClient(type, "host", port);
//Or
ProxyClient pc = new ProxyClient(type, "host", port, "user", "pass");

var hr = new HttpRequest()
{
    Proxy = pc
};

//Or

var hr = new HttpRequest()
{
    Proxy = ProxyClient.Parse(type, "host:port");
};

Set Proxy Authentication

ProxyClient pc = new ProxyClient(type, "host:port");

pc.ProxyAuthentication = ProxyAuthentication.Basic;
//Or
pc.ProxyAuthentication = ProxyAuthentication.Digest;
//Or
pc.ProxyAuthentication = ProxyAuthentication.Ntlm;

Set Cookie

CookieDictionary cookie = new CookieDictionary();
cookie.Add("name1", "value1");
cookie.Add("name2", "value2");

var hr = new HttpRequest()
{
    Cookies = cookie
};

//Or

var hr = new HttpRequest();
hr.Cookies.Add("name1", "value1");
hr.Cookies.Add("name2", "value2");

Set Header

HeaderDictionary header = new HeaderDictionary();
header.Add("name1", "value1");
header.Add("name2", "value2");

var hr = new HttpRequest()
{
    Headers = header
};

//Or

var hr = new HttpRequest();
hr.Headers.Add("name1", "value1");
hr.Headers.Add("name2", "value2");

Get Cookies

string cookie = res.GetCookie("name");

Get Header

string header = res.GetHeader("name");

Donate

Bitcoin : 124NBhKiPTvunTwbYk47w8Zfi47UDrc6hM

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.