pion::http::request_reader Class Reference

`#include <request_reader.hpp>`

Inherits pion::http::reader, and enable_shared_from_this< request_reader >.

## Public Types

typedef boost::function3< void, http::request_ptr, tcp::connection_ptr, const boost::system::error_code & > | finished_handler_t
| function called after the HTTP message has been parsed
Public Types inherited from pion::http::parser

enum

error_value_t {
ERROR_METHOD_CHAR = 1, ERROR_METHOD_SIZE, ERROR_URI_CHAR, ERROR_URI_SIZE,
ERROR_QUERY_CHAR, ERROR_QUERY_SIZE, ERROR_VERSION_EMPTY, ERROR_VERSION_CHAR,
ERROR_STATUS_EMPTY, ERROR_STATUS_CHAR, ERROR_HEADER_CHAR, ERROR_HEADER_NAME_SIZE,
ERROR_HEADER_VALUE_SIZE, ERROR_INVALID_CONTENT_LENGTH, ERROR_CHUNK_CHAR, ERROR_MISSING_CHUNK_DATA,
ERROR_MISSING_HEADER_DATA, ERROR_MISSING_TOO_MUCH_CONTENT
}

| class-specific error code values
typedef boost::function2< void, const char *, std::size_t > | payload_handler_t
| callback type used to consume payload content

## Public Member Functions

void | set_headers_parsed_callback (finished_handler_t &h)
| sets a function to be called after HTTP headers have been parsed
Public Member Functions inherited from pion::http::reader
void | receive (void)
| Incrementally reads & parses the HTTP message.
tcp::connection_ptr & | get_connection (void)
| returns a shared pointer to the TCP connection
void | set_timeout (boost::uint32_t seconds)
| sets the maximum number of seconds for read operations
Public Member Functions inherited from pion::http::parser
| parser (const bool is_request, std::size_t max_content_length=DEFAULT_CONTENT_MAX)
virtual | ~parser ()
| default destructor
boost::tribool | parse (http::message &http_msg, boost::system::error_code &ec)
boost::tribool | parse_missing_data (http::message &http_msg, std::size_t len, boost::system::error_code &ec)
void | finish (http::message &http_msg) const
void | set_read_buffer (const char *ptr, size_t len)
void | load_read_pos (const char *&read_ptr, const char *&read_end_ptr) const
bool | check_premature_eof (http::message &http_msg)
void | parse_headers_only (bool b=true)
void | skip_header_parsing (http::message &http_msg)
void | reset (void)
| resets the parser to its initial state
bool | eof (void) const
| returns true if there are no more bytes available in the read buffer
std::size_t | bytes_available (void) const
| returns the number of bytes available in the read buffer
std::size_t | gcount (void) const
| returns the number of bytes read during the last parse operation
std::size_t | get_total_bytes_read (void) const
| returns the total number of bytes read while parsing the HTTP message
std::size_t | get_content_bytes_read (void) const
| returns the total number of bytes read while parsing the payload content
std::size_t | get_max_content_length (void) const
| returns the maximum length for HTTP payload content
const std::string & | get_raw_headers (void) const
| returns the raw HTTP headers saved by the parser
bool | get_save_raw_headers (void) const
| returns true if the parser is saving raw HTTP header contents
bool | get_parse_headers_only (void)
| returns true if parsing headers only
bool | is_parsing_request (void) const
| returns true if the parser is being used to parse an HTTP request
bool | is_parsing_response (void) const
| returns true if the parser is being used to parse an HTTP response
void | set_payload_handler (payload_handler_t &h)
| defines a callback function to be used for consuming payload content
void | set_max_content_length (std::size_t n)
| sets the maximum length for HTTP payload content
void | reset_max_content_length (void)
| resets the maximum length for HTTP payload content to the default value
void | set_save_raw_headers (bool b)
| sets parameter for saving raw HTTP header content
void | set_logger (logger log_ptr)
| sets the logger to be used
logger | get_logger (void)
| returns the logger currently in use
boost::tribool | finish_header_parsing (http::message &http_msg, boost::system::error_code &ec)

## Static Public Member Functions

static boost::shared_ptr< request_reader > | create (const tcp::connection_ptr &tcp_conn, finished_handler_t handler)
Static Public Member Functions inherited from pion::http::parser
static bool | parse_uri (const std::string &uri, std::string &proto, std::string &host, boost::uint16_t &port, std::string &path, std::string &query)
static bool | parse_url_encoded (ihash_multimap &dict, const char *ptr, const std::size_t len)
static bool | parse_multipart_form_data (ihash_multimap &dict, const std::string &content_type, const char *ptr, const std::size_t len)
static bool | parse_cookie_header (ihash_multimap &dict, const char *ptr, const std::size_t len, bool set_cookie_header)
static bool | parse_cookie_header (ihash_multimap &dict, const std::string &cookie_header, bool set_cookie_header)
static bool | parse_url_encoded (ihash_multimap &dict, const std::string &query)
static bool | parse_multipart_form_data (ihash_multimap &dict, const std::string &content_type, const std::string &form_data)
static bool | parse_forwarded_for (const std::string &header, std::string &public_ip)
static error_category_t & | get_error_category (void)
| returns an instance of parser::error_category_t

## Protected Member Functions

| request_reader (const tcp::connection_ptr &tcp_conn, finished_handler_t handler)
virtual void | read_bytes (void)
| Reads more bytes from the TCP connection.
virtual void | finished_parsing_headers (const boost::system::error_code &ec)
| Called after we have finished parsing the HTTP message headers.
virtual void | finished_reading (const boost::system::error_code &ec)
| Called after we have finished reading/parsing the HTTP message.
virtual http::message & | get_message (void)
| Returns a reference to the HTTP message being parsed.
Protected Member Functions inherited from pion::http::reader
| reader (const bool is_request, const tcp::connection_ptr &tcp_conn)
void | consume_bytes (const boost::system::error_code &read_error, std::size_t bytes_read)
void | consume_bytes (void)
| Consumes bytes that have been read using an HTTP parser.
Protected Member Functions inherited from pion::http::parser
boost::tribool | parse_headers (http::message &http_msg, boost::system::error_code &ec)
void | update_message_with_header_data (http::message &http_msg) const
boost::tribool | parse_chunks (http::message::chunk_cache_t &chunk_buffers, boost::system::error_code &ec)
boost::tribool | consume_content (http::message &http_msg, boost::system::error_code &ec)
std::size_t | consume_content_as_next_chunk (http::message::chunk_cache_t &chunk_buffers)

## Protected Attributes

http::request_ptr | m_http_msg
| The new HTTP message container being created.
finished_handler_t | m_finished
| function called after the HTTP message has been parsed
finished_handler_t | m_parsed_headers
| function called after the HTTP message headers have been parsed
Protected Attributes inherited from pion::http::parser
logger | m_logger
| primary logging interface used by this class
const bool | m_is_request
| true if the message is an HTTP request; false if it is an HTTP response
const char * | m_read_ptr
| points to the next character to be consumed in the read_buffer
const char * | m_read_end_ptr
| points to the end of the read_buffer (last byte + 1)

## Additional Inherited Members

Static Public Attributes inherited from pion::http::parser
static const std::size_t | DEFAULT_CONTENT_MAX = 1024 * 1024
| maximum length for HTTP payload content
Static Protected Member Functions inherited from pion::http::parser
static void | compute_msg_status (http::message &http_msg, bool msg_parsed_ok)
static void | set_error (boost::system::error_code &ec, error_value_t ev)
static void | create_error_category (void)
| creates the unique parser error_category_t
static bool | is_char (int c)
static bool | is_control (int c)
static bool | is_special (int c)
static bool | is_digit (int c)
static bool | is_hex_digit (int c)
static bool | is_cookie_attribute (const std::string &name, bool set_cookie_header)
Static Protected Attributes inherited from pion::http::parser
static const boost::uint32_t | STATUS_MESSAGE_MAX = 1024
| maximum length for response status message
static const boost::uint32_t | METHOD_MAX = 1024
| maximum length for the request method
static const boost::uint32_t | RESOURCE_MAX = 256 * 1024
| maximum length for the resource requested
static const boost::uint32_t | QUERY_STRING_MAX = 1024 * 1024
| maximum length for the query string
static const boost::uint32_t | HEADER_NAME_MAX = 1024
| maximum length for an HTTP header name
static const boost::uint32_t | HEADER_VALUE_MAX = 1024 * 1024
| maximum length for an HTTP header value
static const boost::uint32_t | QUERY_NAME_MAX = 1024
| maximum length for the name of a query string variable
static const boost::uint32_t | QUERY_VALUE_MAX = 1024 * 1024
| maximum length for the value of a query string variable
static const boost::uint32_t | COOKIE_NAME_MAX = 1024
| maximum length for the name of a cookie name
static const boost::uint32_t | COOKIE_VALUE_MAX = 1024 * 1024
| maximum length for the value of a cookie; also used for path and domain

## Detailed Description

request_reader: asynchronously reads and parses HTTP requests

Definition at line 31 of file request_reader.hpp.

## Constructor & Destructor Documentation

## request_reader()

pion::http::request_reader::request_reader | ( | const tcp::connection_ptr & | tcp_conn,
|  | finished_handler_t | handler
| ) |  |

inline protected

protected constructor restricts creation of objects (use create())

Parameters

  tcp_conn | TCP connection containing a new message to parse
  handler | function called after the message has been parsed

Definition at line 71 of file request_reader.hpp.

References m_http_msg, and pion::http::parser::set_logger().

Referenced by create().

## Member Function Documentation

## create()

static boost::shared_ptr<request_reader> pion::http::request_reader::create | ( | const tcp::connection_ptr & | tcp_conn,
|  | finished_handler_t | handler
| ) |  |

inline static

creates new request_reader objects

Parameters

  tcp_conn | TCP connection containing a new message to parse
  handler | function called after the message has been parsed

Definition at line 53 of file request_reader.hpp.

References request_reader().

Referenced by pion::http::server::handle_connection().

The documentation for this class was generated from the following file:

- include/pion/http/request_reader.hpp