• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

EasyHttp/EasyHttp: Http Library for C#

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

EasyHttp/EasyHttp

开源软件地址:

https://github.com/EasyHttp/EasyHttp

开源编程语言:

C# 100.0%

开源软件介绍:

Project Status

This project is active and maintained by David Alpert.

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 - 2017 Hadi Hariri and Project Contributors

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
elnormous/HTTPRequest: Single-header C++ HTTP request class发布时间:2022-06-17
下一篇:
httperf/httperf: The httperf HTTP load generator发布时间:2022-06-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap