reader.hpp
// ---------------------------------------------------------------------
// pion: a Boost C++ framework for building lightweight HTTP interfaces
// ---------------------------------------------------------------------
// Copyright (C) 2007-2014 Splunk Inc. (https://github.com/splunk/pion)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//
#ifndef __PION_HTTP_READER_HEADER__
#define __PION_HTTP_READER_HEADER__
#include <boost/asio.hpp>
#include <pion/config.hpp>
#include <pion/http/parser.hpp>
#include <pion/http/message.hpp>
#include <pion/tcp/connection.hpp>
#include <pion/tcp/timer.hpp>
namespace pion { // begin namespace pion
namespace http { // begin namespace http
class PION_API reader :
public http::parser
{
public:
// default destructor
virtual ~reader() {}
void receive(void);
inline tcp::connection_ptr& get_connection(void) { return m_tcp_conn; }
inline void set_timeout(boost::uint32_t seconds) { m_read_timeout = seconds; }
protected:
reader(const bool is_request, const tcp::connection_ptr& tcp_conn)
: http::parser(is_request), m_tcp_conn(tcp_conn),
m_read_timeout(DEFAULT_READ_TIMEOUT)
{}
void consume_bytes(const boost::system::error_code& read_error,
std::size_t bytes_read);
void consume_bytes(void);
virtual void read_bytes(void) = 0;
virtual void finished_reading(const boost::system::error_code& ec) = 0;
virtual http::message& get_message(void) = 0;
private:
void read_bytes_with_timeout(void);
void handle_read_error(const boost::system::error_code& read_error);
static const boost::uint32_t DEFAULT_READ_TIMEOUT;
tcp::connection_ptr m_tcp_conn;
tcp::timer_ptr m_timer_ptr;
boost::uint32_t m_read_timeout;
};
} // end namespace http
} // end namespace pion
#endif
pion::http::reader
Definition: reader.hpp:28
pion::http::reader::reader
reader(const bool is_request, const tcp::connection_ptr &tcp_conn)
Definition: reader.hpp:55
pion::http::reader::get_connection
tcp::connection_ptr & get_connection(void)
returns a shared pointer to the TCP connection
Definition: reader.hpp:40
pion::http::message
Definition: message.hpp:55
pion
Definition: admin_rights.hpp:19
pion::http::parser
Definition: parser.hpp:39
pion::http::reader::set_timeout
void set_timeout(boost::uint32_t seconds)
sets the maximum number of seconds for read operations
Definition: reader.hpp:43