https://github.com/noear/uwp-async-http
noear::Windows.Web.Http 的简化封装(AsyncHttpClient)
https://github.com/noear/uwp-async-http
Last synced: about 1 year ago
JSON representation
noear::Windows.Web.Http 的简化封装(AsyncHttpClient)
- Host: GitHub
- URL: https://github.com/noear/uwp-async-http
- Owner: noear
- License: apache-2.0
- Created: 2015-11-23T04:13:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-12T01:33:07.000Z (over 10 years ago)
- Last Synced: 2025-03-11T11:38:38.085Z (about 1 year ago)
- Language: C#
- Homepage: http://www.noear.org
- Size: 53.7 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uwp-async-http
在使用Windows.Web.Http时,觉得涉及Cookie及编码操作时比较麻烦
所以就封装了AsyncHttpClient
文件结构:
```javascript
Noear.UWP.Http{
AsyncHttpClient
AsyncHttpResponse
}
```
示例代码:
```java
//GET DEMO
var rsp = await new AsyncHttpClient().Url("http://api.xxx.ddd/get")
.Encoding("UTF-8")
.Get();
return rsp.GetString();
//Request HttpHeader,Cookie DEMO
var rsp = await new AsyncHttpClient().Url("http://api.xxx.ddd/get")
.Referer(referer)
.UserAgent("xxxxxxxxxx")
.Cookies("userID=1")
.Get();
return rsp.GetBytes();
//POST DEMO
Dictionary postData = new Dictionary();
postData.Add("OrderID", "1");
var rsp = await new AsyncHttpClient().Url("http://api.xxx.ddd/post")
.Post(postData);
return rsp.GetString();
//Response DEMO
Dictionary postData = new Dictionary();
postData.Add("OrderID", "1");
var rsp = await new AsyncHttpClient().Url("http://api.xxx.ddd/post")
.Post(postData);
if (rsp.StatusCode == HttpStatusCode.Ok) {
string text = rsp.GetString();
string name = rsp.Headers["name"];
string cokie = rsp.Cookies;
}
```