-
Notifications
You must be signed in to change notification settings - Fork 1
/
RequestTest.cpp
45 lines (34 loc) · 890 Bytes
/
RequestTest.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
#include <Headers.h>
#include <Request.h>
#include <Response.h>
using HTTP::Headers;
using HTTP::Request;
using HTTP::Response;
void loadTest(const std::string & url)
{
Request request;
Response response;
for (int i=0; i <= 1000; ++i) {
response = request.get(url);
if (! response.ok || response.code != 200) {
break;
}
if (i && i % 100 == 0) {
printf("Processed %d requests\n", i);
}
}
}
int main() {
Headers headers;
Request request;
Response response;
response = request.get("http://httpbin.org/get");
puts(response.toString());
headers.set("Content-Type", "text/plain");
response = request.post("http://httpbin.org/post",
headers,
"i has post data");
puts(response.toString());
//loadTest("http://127.0.0.1:8000/");
return 0;
}