blob: 384907c8fb3f6b962f43266cb38c377a69113c88 [file] [log] [blame]
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -08001//
2// request_handler.hpp
3// ~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// 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)
9//
10
11#ifndef HTTP_REQUEST_HANDLER_HPP
12#define HTTP_REQUEST_HANDLER_HPP
13
14#include <string>
15#include <boost/noncopyable.hpp>
Zhenkai Zhud9429222013-02-25 22:34:09 -080016#include <QDir>
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -080017
18namespace http {
19namespace server {
20
21struct reply;
22struct request;
23
24/// The common handler for all incoming requests.
25class request_handler
26 : private boost::noncopyable
27{
28public:
29 /// Construct with a directory containing files to be served.
30 explicit request_handler(const std::string& doc_root);
31
32 /// Handle a request and produce a reply.
33 void handle_request(const request& req, reply& rep);
34
35private:
36 /// The directory containing the files to be served.
Zhenkai Zhud9429222013-02-25 22:34:09 -080037 QDir doc_root_;
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -080038
39 /// Perform URL-decoding on a string. Returns false if the encoding was
40 /// invalid.
41 static bool url_decode(const std::string& in, std::string& out);
42};
43
44} // namespace server
45} // namespace http
46
47#endif // HTTP_REQUEST_HANDLER_HPP