Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 119 lines (76 sloc) 2.906 kb
59207fd Added a documentation section to the readme file
Christiaan baes authored
1 # EasyHttp
2
3
4
5 An easy to use HTTP client that supports:
6
7 * HEAD, PUT, DELETE, GET, POST
8 * Cookies
9 * Authentication
10 * Dynamic and Static Typing
11 * XML, JSON and WWW-Url form encoded encoding/decoding
12 * File upload both via PUT and POST (multipart/formdata)
13 * Some other neat little features....
14
15 ## License
16
17 Licensed under Modified BSD (i.e. pretty much MIT).
18
19 For full License and included software licenses please see LICENSE.TXT
20
21
22 Please log all issues here: http://youtrack.codebetter.com/issues/EHTTP
23
24 ## Installation
25
26 You can either download the source and compile or use nuget at http://nuget.org. To install with nuget:
27
28 Install-Package EasyHttp
29
30 ## Documentation
31
32 The documentation can be found on the [wiki](https://github.com/hhariri/EasyHttp/wiki).
33
34 ## Usage
35
36 ### Using static types
37
38 To post/put a customer to some service:
39
40
41 ```
42 var customer = new Customer();
43 customer.Name = "Joe";
44 customer.Email = "joe@smith.com";
45 var http = new HttpClient();
46 http.Post("url", customer, HttpContentTypes.ApplicationJson);
47 ```
48
49 To get some data in JSON format:
50
51 ```
52 var http = new HttpClient();
53 http.Request.Accept = HttpContentTypes.ApplicationJson;
54 var response = http.Get("url");
55 var customer = response.StaticBody<Customer>();
56 Console.WriteLine("Name: {0}", customer.Name);
57 ```
58
59 ### Using dynamic types
60
61 To post/put a customer to some service:
62
63 ```
64 var customer = new ExpandoObject(); // Or any dynamic type
65 customer.Name = "Joe";
66 customer.Email = "joe@smith.com";
67 var http = new HttpClient();
68 http.Post("url", customer, HttpContentTypes.ApplicationJson);
69 ```
70
71 To get some data in JSON format:
72
73
74 ```
75 var http = new HttpClient();
76 http.Request.Accept = HttpContentTypes.ApplicationJson;
77 var response = http.Get("url");
78 var customer = response.DynamicBody;
79 Console.WriteLine("Name {0}", customer.Name);
80 ```
81
82 Both in Static and Dynamic versions, hierarchies are supported.
83
84 ## Perform a get with parameters
85
86 To get some data from a service
87
88 ```
89 var http = new HttpClient();
90 http.Get("url", new {Name = "test"});
91 ```
92
93 Should translate to the following url being passed. url?Name=test the value will be urlencoded.
94
95 To get some data in JSon format.
96
97 ```
98 var http = new HttpClient();
99 http.Request.Accept = HttpContentTypes.ApplicationJson;
100 http.Get("url", new {Name = "test"});
101 ```
102
103
104 ## Serialization / Deserialization Conventions
105
106 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:
107
108 ```
109
110 [JsonName("mycustomname")]
111 public string SomeWeirdCombination { get; set; }
112 ```
113
114 ## Credits
115
116 Copyright (c) 2010 - 2011 Hadi Hariri and Project Contributors
117
118 JsonFX: Licensed under MIT. EasyHttp uses the awesome JsonFX library at http://github.com/jsonfx
Something went wrong with that request. Please try again.