src/​examples/​cpp03/​http/​server/​request_handler.​hppsrc/​examples/​cpp11/​http/​server/​request_handler.​hpp
1 /​/​1 /​/​
2 /​/​·​request_handler.​hpp2 /​/​·​request_handler.​hpp
3 /​/​·​~~~~~~~~~~~~~~~~~~~3 /​/​·​~~~~~~~~~~~~~~~~~~~
4 /​/​4 /​/​
5 /​/​·​Copyright·​(c)​·​2003-​2018·​Christopher·​M.​·​Kohlhoff·​(chris·​at·​kohlhoff·​dot·​com)​5 /​/​·​Copyright·​(c)​·​2003-​2018·​Christopher·​M.​·​Kohlhoff·​(chris·​at·​kohlhoff·​dot·​com)​
6 /​/​6 /​/​
7 /​/​·​Distributed·​under·​the·​Boost·​Software·​License,​·​Version·​1.​0.​·​(See·​accompanying7 /​/​·​Distributed·​under·​the·​Boost·​Software·​License,​·​Version·​1.​0.​·​(See·​accompanying
8 /​/​·​file·​LICENSE_1_0.​txt·​or·​copy·​at·​http:​/​/​www.​boost.​org/​LICENSE_1_0.​txt)​8 /​/​·​file·​LICENSE_1_0.​txt·​or·​copy·​at·​http:​/​/​www.​boost.​org/​LICENSE_1_0.​txt)​
9 /​/​9 /​/​
10 10
11 #ifndef·​HTTP_REQUEST_HANDLER_​HPP11 #ifndef·​HTTP_REQUEST_HANDLER_​HPP
12 #define·​HTTP_REQUEST_HANDLER_​HPP12 #define·​HTTP_REQUEST_HANDLER_​HPP
13 13
14 #include·​<string>14 #include·​<string>
15 #include·​<boost/​noncopyable.​hpp>
16 15
17 namespace·​http·​{16 namespace·​http·​{
18 namespace·​server·​{17 namespace·​server·​{
19 18
20 struct·​reply;​19 struct·​reply;​
21 struct·​request;​20 struct·​request;​
22 21
23 /​/​/​·​The·​common·​handler·​for·​all·​incoming·​requests.​22 /​/​/​·​The·​common·​handler·​for·​all·​incoming·​requests.​
24 class·​request_handler23 class·​request_handler
25 ··​:​·​private·​boost:​:​noncopyable
26 {24 {
27 public:​25 public:​
26 ··​request_handler(const​·​request_handler&)​·​=·​delete;​
27 ··​request_handler&·​operator=(const·​request_handler&)​·​=·​delete;​
28
28 ··​/​/​/​·​Construct·​with·​a·​directory·​containing·​files·​to·​be·​served.​29 ··​/​/​/​·​Construct·​with·​a·​directory·​containing·​files·​to·​be·​served.​
29 ··​explicit·​request_handler(const​·​std:​:​string&·​doc_root)​;​30 ··​explicit·​request_handler(const​·​std:​:​string&·​doc_root)​;​
30 31
31 ··​/​/​/​·​Handle·​a·​request·​and·​produce·​a·​reply.​32 ··​/​/​/​·​Handle·​a·​request·​and·​produce·​a·​reply.​
32 ··​void·​handle_request(const·​request&·​req,​·​reply&·​rep)​;​33 ··​void·​handle_request(const·​request&·​req,​·​reply&·​rep)​;​
33 34
34 private:​35 private:​
35 ··​/​/​/​·​The·​directory·​containing·​the·​files·​to·​be·​served.​36 ··​/​/​/​·​The·​directory·​containing·​the·​files·​to·​be·​served.​
36 ··​std:​:​string·​doc_root_;​37 ··​std:​:​string·​doc_root_;​
37 38
38 ··​/​/​/​·​Perform·​URL-​decoding·​on·​a·​string.​·​Returns·​false·​if·​the·​encoding·​was39 ··​/​/​/​·​Perform·​URL-​decoding·​on·​a·​string.​·​Returns·​false·​if·​the·​encoding·​was
39 ··​/​/​/​·​invalid.​40 ··​/​/​/​·​invalid.​
40 ··​static·​bool·​url_decode(const·​std:​:​string&·​in,​·​std:​:​string&·​out)​;​41 ··​static·​bool·​url_decode(const·​std:​:​string&·​in,​·​std:​:​string&·​out)​;​
41 };​42 };​
42 43
43 }·​/​/​·​namespace·​server44 }·​/​/​·​namespace·​server
44 }·​/​/​·​namespace·​http45 }·​/​/​·​namespace·​http
45 46
46 #endif·​/​/​·​HTTP_REQUEST_HANDLER_​HPP47 #endif·​/​/​·​HTTP_REQUEST_HANDLER_​HPP