-
Notifications
You must be signed in to change notification settings - Fork 9
/
example.cpp
75 lines (60 loc) · 2.24 KB
/
example.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include "wnetwrap.h"
using namespace wrap;
using namespace std;
int main()
{
/*
cout << "status code: " + r.status_code << endl;
cout << r.text << endl;
cout << "received header:" << endl;
cout << r.header["content-type"] << endl;
cout << "sent headers map:" << endl;
for (auto elem : r.sent_headers)
{
cout << elem.first + " : " + elem.second + "\r\n";
}
*/
//HttpsRequest(Url{ "https://archive-4.kali.org/kali-images/kali-2021.1/kali-linux-2021.1-live-amd64.iso" }, Download{});
Response r;
//r = HttpsRequest(Url{ "www.postman-echo.com/get" }, Header{ {"Referer","www.bla.com"},{"Content-Type","*/*"} }, Parameters{ {"fruit","mango"},{"price","£3"} });
//cout << endl << r.text << endl;
//posting raw data - does not get url encoded
//r = HttpsRequest(Url{ "www.postman-echo.com/post" }, Body{ "£" }, Method{ "POST" });
//cout << endl << r.text << endl;
//url form encode - key value pairs
r = HttpsRequest(Url{ "www.httpbin.org/post" }, Payload{ {"name","习近平"} }, Method{ "POST" }, Timeout{1000});
cout << endl << r.text << endl;
//note: to upload to file.io do not use www in url, and always use filename file
//r = HttpsRequest(Url{ "file.io" }, Multipart{ {"file:file","sample.txt"} }, Method{ "POST" });
//cout << endl << r.text << endl;
r = HttpsRequest(Url{ "https://www.httpbin.org/basic-auth/user/passwd" }, Authentication{ "user","passwd" });
cout << endl << r.text << endl;
//receiving a cookie
/*r = HttpsRequest(Url{ "https://www.httpbin.org/cookies/set?cookie=yummy" });
cout << endl << r.text << endl;
cout << "status code: " + r.status_code << endl;
cout << "redirect count: " << r.redirect_count << endl;
cout << "rcd byte count: " << r.downloaded_bytes << endl;
cout << "recd cookies map:" << endl;
for (auto elem : r.cookies)
{
cout << elem.first + " : " + elem.second + "\r\n";
}
*/
//sending a cookie with request
/*
cout << "sent headers map:" << endl;
for (auto elem : r.sent_headers)
{
cout << elem.first + " : " + elem.second + "\r\n";
}
cout << "recd headers map:" << endl;
for (auto elem : r.header)
{
cout << elem.first + " : " + elem.second + "\r\n";
}
*/
system("PAUSE");
return 0;
}