-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler-test.cpp
52 lines (48 loc) · 1.33 KB
/
handler-test.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
#include "server.hpp"
namespace http {
bool
handler_test_type::get (http::connection_type& r)
{
html_builder_type html;
html <<
"<!DOCTYPE html>\n"
"<html>\n"
"<head>\n"
"<title>test</title>\n"
"</head>\n"
"<body>\n"
"<h1>test</h1>\n"
"<p>method " << r.request.method <<
" URI " << r.request.uri << ".</p>\n"
"</body>\n"
"</html>\n";
r.response.body = html.string ();
r.response.code = 200;
r.response.header["content-type"] = "text/html; charset=UTF-8";
r.response.header["content-length"] = std::to_string (r.response.body.size ());
return true;
}
bool
handler_test_type::post (http::connection_type& r)
{
html_builder_type html;
html <<
"<!DOCTYPE html>\n"
"<html>\n"
"<head>\n"
"<title>test</title>\n"
"</head>\n"
"<body>\n"
"<h1>test</h1>\n"
"<p>method " << r.request.method <<
" URI " << r.request.uri << ".</p>\n"
"<pre>" << r.request.body << "</pre>\n"
"</body>\n"
"</html>\n";
r.response.body = html.string ();
r.response.code = 200;
r.response.header["content-type"] = "text/html; charset=UTF-8";
r.response.header["content-length"] = std::to_string (r.response.body.size ());
return true;
}
}//namespace http