2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-28 06:42:08 +00:00
Files
asio/example/http/server4/file_handler.hpp
Christopher Kohlhoff 28ab37a23e Merge from trunk:
* Update copyright notice.

* Version bump.

* Fix out-of-bounds address_v4::broadcast() return value on 64-bit systems.

* Use correct interrupt method when timerfd is not available. Fixes #5045


[SVN r68200]
2011-01-17 04:28:16 +00:00

45 lines
1.1 KiB
C++

//
// file_handler.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef HTTP_SERVER4_FILE_HANDLER_HPP
#define HTTP_SERVER4_FILE_HANDLER_HPP
#include <string>
namespace http {
namespace server4 {
struct reply;
struct request;
/// The common handler for all incoming requests.
class file_handler
{
public:
/// Construct with a directory containing files to be served.
explicit file_handler(const std::string& doc_root);
/// Handle a request and produce a reply.
void operator()(const request& req, reply& rep);
private:
/// The directory containing the files to be served.
std::string doc_root_;
/// Perform URL-decoding on a string. Returns false if the encoding was
/// invalid.
static bool url_decode(const std::string& in, std::string& out);
};
} // namespace server4
} // namespace http
#endif // HTTP_SERVER4_FILE_HANDLER_HPP