C++ REST SDK??????÷?
???????????? ???????[ 2015/1/8 13:27:48 ] ????????C++ net
????????????????????????http??--C++ REST SDK??http://casablanca.codeplex.com/??????????????????Casablanca???и???????????????????????????????????????ɡ???REST SDK????????????????????rest API?????REST???????Ь??????????????????REST API?????????application/x-www-form-urlencoded??application/json??application/octet-stream???????????REST API??????????json???????????????Casablanca????c++11????????????PPL??asio???????????????web socket?????????????????????????????????????
#include <cppresthttp_client.h>
#include <cpprestfilestream.h>
using namespace utility;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace concurrency;
void TestRequest()
{
auto fileStream = std::make_shared<concurrency::streams::ostream>();
pplx::task<void> requestTask = concurrency::streams::fstream::open_ostream(U("result.html")).then([=](concurrency::streams::ostream
outFile){
*fileStream = outFile;
http_client client(U("http://www.bing.com/"));
uri_builder builder(U("/search"));
builder.append_query(U("q")?? U("Casablanca CodePlex"));
return client.request(methods::GET?? builder.to_string());
})
.then([=](http_response response)
{
return response.body().read_to_end(fileStream->streambuf());
}).then([=](size_t len){
return fileStream->close();
});
try
{
requestTask.wait();
}
catch (const std::exception& e)
{
cout << e.what() << endl;
}
}
|
?????????????bing.com????“Casablanca CodePlex”????????浽??????????result.html?У??????ppl??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????rest sdk????????????????????wchr_t???????????http?????????????http???????ú????????е?С????^_^??????????????????ppl?÷????Ь?????е???????????????????????£????????????????????????
void TestRequest()
{
auto fileStream = std::make_shared<concurrency::streams::ostream>();
concurrency::streams::ostream outFile = concurrency::streams::fstream::open_ostream(U("result11.html")).get();
*fileStream = outFile;
http_client client(L"http://www.bing.com/");
uri_builder builder(L"/search");
builder.append_query(L"q"?? L"Casablanca CodePlex");
http_response response = client.request(methods::GET?? builder.to_string()).get();
response.body().read_to_end(fileStream->streambuf()).get();
fileStream->close().get();
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11