GithubHelp home page GithubHelp logo

dexterwoo / curlsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from masroore/curlsharp

0.0 2.0 0.0 8.06 MB

CurlSharp - .Net binding and object-oriented wrapper for libcurl.

License: BSD 3-Clause "New" or "Revised" License

C# 85.02% C 14.61% C++ 0.37%

curlsharp's Introduction

CurlSharp

CurlSharp is a .Net binding and object-oriented wrapper for libcurl.

libcurl is a web-client library that can provide cross-platform .Net applications with an easy way to implement such things as:

  • HTTP ( GET / HEAD / PUT / POST / multi-part / form-data )
  • FTP ( upload / download / list / 3rd-party )
  • HTTPS, FTPS, SSL, TLS ( via OpenSSL or GnuTLS )
  • Proxies, proxy tunneling, cookies, user+password authentication.
  • File transfer resume, byte ranges, multiple asynchronous transfers.
  • and much more...

CurlSharp provides simple get/set properties for libcurl's options and information functions, event-based hooks to libcurl's I/O, status, and progress callbacks, and wraps the c-style file I/O behind simple filename properties. The CurlEasy class contains has more than 100 different properties and methods to handle a wide variety of URL transfer requirements. While this may seem overwhelming at first glance, the good news is you will probably need only a tiny subset of these for most situations.

The CurlSharp library consists of these parts:

  • Pure C# P/Invoke bindings to the libcurl API.
  • Optional libcurlshim helper DLL [WIN32].
  • The CurlEasy class which provides a wrapper around a curl_easy session.
  • The CurlMulti class, which serves as a container for multiple CurlEasy objects, and provides a wrapper around a curl_multi session.
  • The CurlShare class which provides an infrastructure for serializing access to data shared by multiple CurlEasy objects, including cookie data and DNS hosts. It implements the curl_share_xxx API.
  • The CurlHttpMultiPartForm to easily construct multi-part forms.
  • The CurlSlist class which wraps a linked list of strings used in cURL.

CurlSharp is available for these platforms:

  • [Stable] Windows 32-bit
  • [Experimental] Win64 port
  • [Experimental] Mono Linux & OS X support

Examples

A simple HTTP download program...

using System;
using CurlSharp;

internal class EasyGet
{
  public static void Main(String[] args)
  {
    Curl.GlobalInit(CurlInitFlag.All);

    try
    {
      using (var easy = new CurlEasy())
      {
        easy.Url = "http://www.google.com/";
        easy.WriteFunction = OnWriteData;
        easy.Perform();
      }
    }
    finally
    {
      Curl.GlobalCleanup();
    }	
  }

  public static Int32 OnWriteData(byte[] buf, Int32 size, Int32 nmemb, object data)
  {
      Console.Write(Encoding.UTF8.GetString(buf));
      return size*nmemb;
  }
}

Simple HTTP Post example:

using (var easy = new CurlEasy())
{
    easy.Url = "http://hostname/testpost.php";
    easy.Post = true;
    var postData = "parm1=12345&parm2=Hello+world%21";
    easy.PostFields = postData;
    easy.PostFieldSize = postData.Length;
    easy.Perform();
}

Several more samples are included in the Samples folder.

Credits

CurlSharp Written by Dr. Masroor Ehsan.

CurlSharp is based on original code by Jeff Phillips libcurl.NET. Original code has been modified and greatly enhanced.


CurlSharp Copyright © 2013-16 Dr. Masroor Ehsan

curlsharp's People

Contributors

masroore avatar lailongwei avatar cyberscooby avatar pjf avatar

Watchers

James Cloos avatar  avatar

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.