forked from pt209223/librs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_http.cpp
39 lines (31 loc) · 1.04 KB
/
test_http.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
#include "Http.h"
#include "iostream"
using namespace std;
int main(int argc, char **argv)
{
Http http;
char *page = NULL;
size_t size = 0;
for (int i = 1; i < argc; ++i) {
cerr << "== GET '" << argv[i] << "' ==" << endl;
try {
//http.set_verbose(true);
int code = http.get(page, size, argv[i]);
if (page) delete[] page;
const Http::Headers &hdrs = http.get_headers();
Http::Headers::const_iterator it;
const char *loc = http.get_recv_header("location");
const char *coo = http.get_recv_header("set-cookie");
const char *len = http.get_recv_header("content-length");
cerr << "== code = " << code << endl;
cerr << "== headers size = " << hdrs.size() << endl;
cerr << "== location = " << (loc?loc:"?") << endl;
cerr << "== set-cookie = " << (coo?coo:"?") << endl;
cerr << "== content-length = " << (len?len:"?") << " (strona: " << size << ")"<< endl;
}
catch (Exception &e) {
cerr << "== exception: " << e.what() << endl;
}
}
return 0;
}