pion-net
4.0.9
|
#include <HTTPResponseReader.hpp>
Inherits pion::net::HTTPReader, and enable_shared_from_this< HTTPResponseReader >.
Public Types | |
typedef boost::function3< void, HTTPResponsePtr, TCPConnectionPtr, const boost::system::error_code & > | FinishedHandler |
function called after the HTTP message has been parsed | |
![]() | |
enum | ErrorValue { 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 | |
Static Public Member Functions | |
static boost::shared_ptr < HTTPResponseReader > | create (TCPConnectionPtr &tcp_conn, const HTTPRequest &http_request, FinishedHandler handler) |
![]() | |
static bool | parseURLEncoded (HTTPTypes::QueryParams &dict, const char *ptr, const std::size_t len) |
static bool | parseCookieHeader (HTTPTypes::CookieParams &dict, const char *ptr, const std::size_t len, bool set_cookie_header) |
static bool | parseCookieHeader (HTTPTypes::CookieParams &dict, const std::string &cookie_header, bool set_cookie_header) |
static bool | parseURLEncoded (HTTPTypes::QueryParams &dict, const std::string &query) |
static bool | parseForwardedFor (const std::string &header, std::string &public_ip) |
static ErrorCategory & | getErrorCategory (void) |
returns an instance of HTTPParser::ErrorCategory | |
Protected Member Functions | |
HTTPResponseReader (TCPConnectionPtr &tcp_conn, const HTTPRequest &http_request, FinishedHandler handler) | |
virtual void | readBytes (void) |
Reads more bytes from the TCP connection. | |
virtual void | finishedReading (const boost::system::error_code &ec) |
Called after we have finished reading/parsing the HTTP message. | |
virtual HTTPMessage & | getMessage (void) |
Returns a reference to the HTTP message being parsed. | |
![]() | |
HTTPReader (const bool is_request, TCPConnectionPtr &tcp_conn) | |
void | consumeBytes (const boost::system::error_code &read_error, std::size_t bytes_read) |
void | consumeBytes (void) |
Consumes bytes that have been read using an HTTP parser. | |
![]() | |
boost::tribool | parseHeaders (HTTPMessage &http_msg, boost::system::error_code &ec) |
void | updateMessageWithHeaderData (HTTPMessage &http_msg) const |
boost::tribool | finishHeaderParsing (HTTPMessage &http_msg, boost::system::error_code &ec) |
boost::tribool | parseChunks (HTTPMessage::ChunkCache &chunk_buffers, boost::system::error_code &ec) |
boost::tribool | consumeContent (HTTPMessage &http_msg, boost::system::error_code &ec) |
std::size_t | consumeContentAsNextChunk (HTTPMessage::ChunkCache &chunk_buffers) |
Protected Attributes | |
HTTPResponsePtr | m_http_msg |
The new HTTP message container being created. | |
FinishedHandler | m_finished |
function called after the HTTP message has been parsed | |
![]() | |
PionLogger | 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 | |
![]() | |
void | receive (void) |
Incrementally reads & parses the HTTP message. | |
TCPConnectionPtr & | getTCPConnection (void) |
returns a shared pointer to the TCP connection | |
void | setTimeout (boost::uint32_t seconds) |
sets the maximum number of seconds for read operations | |
![]() | |
HTTPParser (const bool is_request, std::size_t max_content_length=DEFAULT_CONTENT_MAX) | |
virtual | ~HTTPParser () |
default destructor | |
boost::tribool | parse (HTTPMessage &http_msg, boost::system::error_code &ec) |
boost::tribool | parseMissingData (HTTPMessage &http_msg, std::size_t len, boost::system::error_code &ec) |
void | finish (HTTPMessage &http_msg) const |
void | setReadBuffer (const char *ptr, size_t len) |
void | loadReadPosition (const char *&read_ptr, const char *&read_end_ptr) const |
bool | checkPrematureEOF (HTTPMessage &http_msg) |
void | parseHeadersOnly (bool b=true) |
void | skipHeaderParsing (HTTPMessage &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 | getTotalBytesRead (void) const |
returns the total number of bytes read while parsing the HTTP message | |
std::size_t | getContentBytesRead (void) const |
returns the total number of bytes read while parsing the payload content | |
std::size_t | getMaxContentLength (void) const |
returns the maximum length for HTTP payload content | |
const std::string & | getRawHeaders (void) const |
returns the raw HTTP headers saved by the parser | |
bool | getSaveRawHeaders (void) const |
returns true if the parser is saving raw HTTP header contents | |
bool | isParsingRequest (void) const |
returns true if the parser is being used to parse an HTTP request | |
bool | isParsingResponse (void) const |
returns true if the parser is being used to parse an HTTP response | |
void | setMaxContentLength (std::size_t n) |
sets the maximum length for HTTP payload content | |
void | resetMaxContentLength (void) |
resets the maximum length for HTTP payload content to the default value | |
void | setSaveRawHeaders (bool b) |
sets parameter for saving raw HTTP header content | |
void | setLogger (PionLogger log_ptr) |
sets the logger to be used | |
PionLogger | getLogger (void) |
returns the logger currently in use | |
![]() | |
static const std::size_t | DEFAULT_CONTENT_MAX = 1024 * 1024 |
maximum length for HTTP payload content | |
![]() | |
static void | computeMsgStatus (HTTPMessage &http_msg, bool msg_parsed_ok) |
static void | setError (boost::system::error_code &ec, ErrorValue ev) |
static void | createErrorCategory (void) |
creates the unique HTTPParser ErrorCategory | |
static bool | isChar (int c) |
static bool | isControl (int c) |
static bool | isSpecial (int c) |
static bool | isDigit (int c) |
static bool | isHexDigit (int c) |
static bool | isCookieAttribute (const std::string &name, bool set_cookie_header) |
![]() | |
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 | |
HTTPResponseReader: asynchronously reads and parses HTTP responses
Definition at line 31 of file HTTPResponseReader.hpp.
|
inlineprotected |
protected constructor restricts creation of objects (use create())
tcp_conn | TCP connection containing a new message to parse |
http_request | the request we are responding to |
handler | function called after the message has been parsed |
Definition at line 71 of file HTTPResponseReader.hpp.
References m_http_msg, and pion::net::HTTPParser::setLogger().
Referenced by create().
|
inlinestatic |
creates new HTTPResponseReader objects
tcp_conn | TCP connection containing a new message to parse |
http_request | the request we are responding to |
handler | function called after the message has been parsed |
Definition at line 54 of file HTTPResponseReader.hpp.
References HTTPResponseReader().