Giter Club home page Giter Club logo

easyhttp's Introduction

EasyHttp

An easy to use HTTP client that supports:

  • HEAD, PUT, DELETE, GET, POST
  • Cookies
  • Authentication
  • Dynamic and Static Typing
  • XML, JSON and WWW-Url form encoded encoding/decoding
  • File upload both via PUT and POST (multipart/formdata)
  • Some other neat little features....

License

Licensed under Modified BSD (i.e. pretty much MIT).

For full License and included software licenses please see LICENSE.TXT

Please log all issues here: http://youtrack.codebetter.com/issues/EHTTP

Installation

You can either download the source and compile or use nuget at http://nuget.org. To install with nuget:

Install-Package EasyHttp

Documentation

The documentation can be found on the wiki.

Usage

Using static types

To post/put a customer to some service:

	var customer = new Customer(); 
	customer.Name = "Joe"; 
	customer.Email = "[email protected]";
	var http = new HttpClient();
	http.Post("url", customer, HttpContentTypes.ApplicationJson);

To get some data in JSON format:

	var http = new HttpClient();
	http.Request.Accept = HttpContentTypes.ApplicationJson;
	var response = http.Get("url");
	var customer = response.StaticBody<Customer>();
	Console.WriteLine("Name: {0}", customer.Name);

Using dynamic types

To post/put a customer to some service:

	var customer = new ExpandoObject(); // Or any dynamic type
	customer.Name = "Joe";
	customer.Email = "[email protected]";
	var http = new HttpClient();
	http.Post("url", customer, HttpContentTypes.ApplicationJson);

To get some data in JSON format:

	var http = new HttpClient();
	http.Request.Accept = HttpContentTypes.ApplicationJson;
	var response = http.Get("url");
	var customer = response.DynamicBody;
	Console.WriteLine("Name {0}", customer.Name);

Both in Static and Dynamic versions, hierarchies are supported.

Perform a get with parameters

To get some data from a service

   var http = new HttpClient();
   http.Get("url", new {Name = "test"});

Should translate to the following url being passed. url?Name=test the value will be urlencoded.

To get some data in JSon format.

   var http = new HttpClient();
   http.Request.Accept = HttpContentTypes.ApplicationJson;
   http.Get("url", new {Name = "test"});

Serialization / Deserialization Conventions

For serialization / deserialization, you can use pretty much any type of naming convention, be it Propercase, CamelCase, lowerCamelCase, with_underscores, etc. If for some reason, your convention is not picked up, you can always decorate the property with an attribute:

 
   [JsonName("mycustomname")] 
   public string SomeWeirdCombination { get; set; }

Credits

Copyright (c) 2010 - 2011 Hadi Hariri and Project Contributors

JsonFX: Licensed under MIT. EasyHttp uses the awesome JsonFX library at http://github.com/jsonfx

easyhttp's People

Contributors

hhariri avatar chrismckee avatar davidwalker avatar jole78 avatar graemebradbury avatar minglei84 avatar borismod avatar nocfed avatar mikeedwardseduserv avatar

Watchers

James Cloos avatar nbboy avatar

Forkers

windygu

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.