The common handler for all incoming requests.
| 21 | |
| 22 | /// The common handler for all incoming requests. |
| 23 | class file_handler |
| 24 | { |
| 25 | public: |
| 26 | /// Construct with a directory containing files to be served. |
| 27 | explicit file_handler(const std::string& doc_root); |
| 28 | |
| 29 | /// Handle a request and produce a reply. |
| 30 | void operator()(const request& req, reply& rep); |
| 31 | |
| 32 | private: |
| 33 | /// The directory containing the files to be served. |
| 34 | std::string doc_root_; |
| 35 | |
| 36 | /// Perform URL-decoding on a string. Returns false if the encoding was |
| 37 | /// invalid. |
| 38 | static bool url_decode(const std::string& in, std::string& out); |
| 39 | }; |
| 40 | |
| 41 | } // namespace server4 |
| 42 | } // namespace http |