-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.cpp
37 lines (31 loc) · 954 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <sstream>
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
using namespace std;
int main() {
try
{
string url = "http://localhost/cache/Hello";
// RAII cleanup
curlpp::Cleanup cURLppStartStop;
curlpp::Easy post;
post.setOpt(curlpp::options::Url(url));
post.setOpt(new curlpp::options::CustomRequest{"PUT"});
post.setOpt(new curlpp::options::PostFields ("World"));
post.setOpt(curlpp::options::Port(8080));
post.perform();
curlpp::Easy get;
get.setOpt(curlpp::options::Url(url§));
std::stringstream response;
get.setOpt(new curlpp::options::WriteStream(&response));
get.setOpt(curlpp::options::Port(8080));
get.perform();
cout << "Hello = " << response.str() << endl;
}
catch(exception& e)
{
cerr << e.what() << endl;
}
}