/usr/include/pion/http/request_reader.hpp is in libpion-dev 5.0.4+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | // ---------------------------------------------------------------------
// pion: a Boost C++ framework for building lightweight HTTP interfaces
// ---------------------------------------------------------------------
// Copyright (C) 2007-2012 Cloudmeter, Inc. (http://www.cloudmeter.com)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//
#ifndef __PION_HTTP_REQUEST_READER_HEADER__
#define __PION_HTTP_REQUEST_READER_HEADER__
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/function/function2.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <pion/config.hpp>
#include <pion/http/request.hpp>
#include <pion/http/reader.hpp>
namespace pion { // begin namespace pion
namespace http { // begin namespace http
///
/// request_reader: asynchronously reads and parses HTTP requests
///
class request_reader :
public http::reader,
public boost::enable_shared_from_this<request_reader>
{
public:
/// function called after the HTTP message has been parsed
typedef boost::function3<void, http::request_ptr, tcp::connection_ptr,
const boost::system::error_code&> finished_handler_t;
// default destructor
virtual ~request_reader() {}
/**
* creates new request_reader objects
*
* @param tcp_conn TCP connection containing a new message to parse
* @param handler function called after the message has been parsed
*/
static inline boost::shared_ptr<request_reader>
create(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
{
return boost::shared_ptr<request_reader>
(new request_reader(tcp_conn, handler));
}
/// sets a function to be called after HTTP headers have been parsed
inline void set_headers_parsed_callback(finished_handler_t& h) { m_parsed_headers = h; }
protected:
/**
* protected constructor restricts creation of objects (use create())
*
* @param tcp_conn TCP connection containing a new message to parse
* @param handler function called after the message has been parsed
*/
request_reader(tcp::connection_ptr& tcp_conn, finished_handler_t handler)
: http::reader(true, tcp_conn), m_http_msg(new http::request),
m_finished(handler)
{
m_http_msg->set_remote_ip(tcp_conn->get_remote_ip());
set_logger(PION_GET_LOGGER("pion.http.request_reader"));
}
/// Reads more bytes from the TCP connection
virtual void read_bytes(void) {
get_connection()->async_read_some(boost::bind(&request_reader::consume_bytes,
shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
/// Called after we have finished parsing the HTTP message headers
virtual void finished_parsing_headers(const boost::system::error_code& ec) {
// call the finished headers handler with the HTTP message
if (m_parsed_headers) m_parsed_headers(m_http_msg, get_connection(), ec);
}
/// Called after we have finished reading/parsing the HTTP message
virtual void finished_reading(const boost::system::error_code& ec) {
// call the finished handler with the finished HTTP message
if (m_finished) m_finished(m_http_msg, get_connection(), ec);
}
/// Returns a reference to the HTTP message being parsed
virtual http::message& get_message(void) { return *m_http_msg; }
/// The new HTTP message container being created
http::request_ptr m_http_msg;
/// function called after the HTTP message has been parsed
finished_handler_t m_finished;
/// function called after the HTTP message headers have been parsed
finished_handler_t m_parsed_headers;
};
/// data type for a request_reader pointer
typedef boost::shared_ptr<request_reader> request_reader_ptr;
} // end namespace http
} // end namespace pion
#endif
|