-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
41 lines (31 loc) · 1.03 KB
/
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
38
39
40
41
#include <iostream>
#include "hxxp.h"
#include "xttp_struct.h"
int main(int argc, char *argv[])
{
curlpp::hxxp().globalInit();
curlpp::net_default_data default_data;
default_data.download_path(".");
default_data.timeout(10);
curlpp::result get_rs = curlpp::hxxp().url("http://www.baidu.com").get();
if (get_rs.state()){
std::cout << "get success" << std::endl;
}else{
std::cout << "get fail," << get_rs.value() << std::endl;
}
curlpp::result post_rs = curlpp::hxxp().url("http://www.baidu.com").add_header("").add_header("").add_post_params("", "").post();
if (get_rs.state()){
std::cout << "post success" << std::endl;
}else{
std::cout << "post fail," << get_rs.value() << std::endl;
}
curlpp::result download_rs = curlpp::hxxp().url("http://www.baidu.com/img/bd_logo1.png").download_path(".").outfile_name("").download();
if (download_rs.state()){
std::cout << "download success" << std::endl;
}
else{
std::cout << "download fail," << download_rs.value() << std::endl;
}
curlpp::hxxp().globalClean();
return 1;
}