pion-net  4.0.9
Public Member Functions | Protected Member Functions | List of all members
pion::net::HTTPReader Class Reference

#include <HTTPReader.hpp>

Inherits pion::net::HTTPParser.

Inherited by pion::net::HTTPRequestReader, and pion::net::HTTPResponseReader.

Public Member Functions

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
- Public Member Functions inherited from pion::net::HTTPParser
 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

Protected Member Functions

 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.
virtual void readBytes (void)=0
 Reads more bytes from the TCP connection.
virtual void finishedReading (const boost::system::error_code &ec)=0
 Called after we have finished reading/parsing the HTTP message.
virtual HTTPMessagegetMessage (void)=0
 Returns a reference to the HTTP message being parsed.
- Protected Member Functions inherited from pion::net::HTTPParser
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)

Additional Inherited Members

- Public Types inherited from pion::net::HTTPParser
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 inherited from pion::net::HTTPParser
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 ErrorCategorygetErrorCategory (void)
 returns an instance of HTTPParser::ErrorCategory
- Static Public Attributes inherited from pion::net::HTTPParser
static const std::size_t DEFAULT_CONTENT_MAX = 1024 * 1024
 maximum length for HTTP payload content
- Static Protected Member Functions inherited from pion::net::HTTPParser
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)
- Protected Attributes inherited from pion::net::HTTPParser
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)
- Static Protected Attributes inherited from pion::net::HTTPParser
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

HTTPReader: asynchronously reads and parses HTTP messages

Definition at line 28 of file HTTPReader.hpp.

Constructor & Destructor Documentation

pion::net::HTTPReader::HTTPReader ( const bool  is_request,
TCPConnectionPtr &  tcp_conn 
)
inlineprotected

protected constructor: only derived classes may create objects

Parameters
is_requestif true, the message is parsed as an HTTP request; if false, the message is parsed as an HTTP response
tcp_connTCP connection containing a new message to parse

Definition at line 55 of file HTTPReader.hpp.

Member Function Documentation

void pion::net::HTTPReader::consumeBytes ( const boost::system::error_code &  read_error,
std::size_t  bytes_read 
)
protected

Consumes bytes that have been read using an HTTP parser

Parameters
read_errorerror status from the last read operation
bytes_readnumber of bytes consumed by the last read operation

Definition at line 41 of file HTTPReader.cpp.

References consumeBytes(), pion::net::HTTPParser::isParsingRequest(), pion::net::HTTPParser::m_logger, and pion::net::HTTPParser::setReadBuffer().


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