Project Description

HttpLib makes it easier to asynchronously consume data from web services in C#. The library contains methods to upload files to server and get pages.

This project is designed for consuming existing web services. If you plan on writing a new http client/server application, it is recommended that you use WCF.

This project is now licensed under the Apache 2.0 license.

Source is now hosted on GitHub https://github.com/j6mes/httplib/

Supported Methods

  • GET
  • POST
  • PUT
  • PATCH
  • HEAD
  • DELETE
  • Upload - PUT or POST

Samples

using Redslide.HttpLib

Get data from web service

Request.Get("http://jthorne.co.uk/", 
result=>
{
    Console.Write(result);
});

Download file from server

Request.Get("http://cachefly.cachefly.net/100mb.test", 
(headers, result) =>
{
        FileStream fs = new FileStream(@"C:\100mb.test", FileMode.OpenOrCreate);
        result.CopyTo(fs);
        fs.Close();
});

Post data to web service

Request.Post("http://testing.local/post.php", new {name="james",username="Redslide"}, 
result=>
{
    Console.Write(result);
});


Post data to web service and catch error

Request.Post("http://testing.local/post.php", new { name = "value"}, 
result=>
{
    Console.Write(result);
}, 
e=>
{
    Console.Write(e.ToString());
});


Upload file to server

Request.Upload("http://testing.local/post.php", new {name = "value"}, new[] {
    new NamedFileStream("file", "photo.jpg", "image/jpeg", new FileStream(@"C:\photo.jpg",FileMode.Open))
}, 
result=>
{
    Console.Write(result);
});

Changelog

Release 1.1.9 (planned)

  • Add custom headers to request

Release 1.0.8

Release 1.0.7

Release 1.0.6

  • Compatible with Windows 8 Store Applications

Release 1.0.5

Release 1.0.4

  • Minor bug fixes
  • Fixed function naming/nomenclature

Last edited May 31 at 10:21 PM by JumpKick, version 25