• Stars
    star
    174
  • Rank 218,092 (Top 5 %)
  • Language
    C#
  • License
    BSD 3-Clause "New...
  • Created almost 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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();
}

HTTP/2.0 download:

using (var easy = new CurlEasy())
{
    easy.Url = "https://google.com/";
    easy.WriteFunction = OnWriteData;

    // HTTP/2 please
    easy.HttpVersion = CurlHttpVersion.Http2_0;

    // skip SSL verification during debugging
    easy.SslVerifyPeer = false;
    easy.SslVerifyhost = false;

    easy.Perform();
}

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-17 Dr. Masroor Ehsan

More Repositories

1

opentracker

opentracker is a open and free bittorrent tracker project
C
114
star
2

pg_simple

A simple wrapper over psycopg2 with support for common SQL functions and connection pooling
Python
29
star
3

libowfat

Git clone of libowfat (reimplementation of libdjb). Compatible with Mac OS X (clang)
C
6
star
4

py-cyclone

py-cyclone: tornado, twisted python, smtpd, smtp server
Python
4
star
5

nitroServer

Graveyard for old, deprecated projects... R.I.P. :(
Pascal
4
star
6

slimonade

stripped down version of limonade php framework
PHP
2
star
7

tinybb

tiny bulletin board system based on the Yii framework
PHP
2
star
8

laravel-repository

Laravel - Repositories to the database layer
PHP
1
star
9

feedafever

PHP
1
star
10

pydanga

danga, socket, async, reactor, python
Python
1
star
11

php-stopwords

Stopwords for PHP
PHP
1
star
12

tinytweets

laravel 4 microblog
PHP
1
star
13

pydsnap

Python tool to capture stock price snapshot of the Dhaka & Chittagong Stock Exchanges
Python
1
star
14

nsoftware-keygen

Reverse engineering of nsoftware.com products (work-in-progress)
C#
1
star
15

github-treasure-trove

Blade
1
star
16

modesy

Modesy - Marketplace & Classified Ads Script
PHP
1
star
17

verifyemail

Verify e-mail addresses for correct syntax and, optionally, for existence.
PHP
1
star
18

codecourse-projects

CSS
1
star
19

pylorix

Python
1
star
20

Firebird-NETProvider

Fork of the Firebird .net provider
C#
1
star
21

reactjs-fastapi-url-shortener

Simple URL shortener built using FastAPI, SQLAlchemy and ReactJS
Python
1
star
22

jetstrap

A Laravel 10+ package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 5.
Vue
1
star
23

php-html2text

A PHP package to convert HTML into a plain text format
PHP
1
star