![]() |
staticlib_pion
2.0.2
|
Asynchronously reads and parses HTTP requests. More...
#include <staticlib/pion/http_request_reader.hpp>
Public Member Functions | |
| http_request_reader (http_server &srv, tcp_connection_ptr &tcp_conn, uint32_t read_timeout) | |
Constructor to be used with std::make_unique | |
| http_request_reader (const http_request_reader &) | |
| Deleted copy-constructor. | |
| http_request_reader & | operator= (const http_request_reader &) |
| Deleted copy-assignment operator. | |
Public Member Functions inherited from staticlib::pion::http_parser | |
| http_parser (size_t max_content_length=DEFAULT_CONTENT_MAX) | |
| Creates new parser objects. | |
| http_parser (const http_parser &) | |
| Deleted copy constructor. | |
| http_parser & | operator= (const http_parser &) |
| Deleted copy assignment operator. | |
| virtual | ~http_parser () STATICLIB_NOEXCEPT |
| Default destructor. | |
| sl::support::tribool | parse (http_message &http_msg, std::error_code &ec) |
| Parses an HTTP message including all payload content it might contain. | |
| void | finish (http_message &http_msg) const |
| Finishes parsing an HTTP response message. | |
| void | set_read_buffer (const char *ptr, size_t len) |
| Resets the location and size of the read buffer. | |
| void | load_read_pos (const char *&read_ptr, const char *&read_end_ptr) const |
| Loads a read position bookmark. | |
| bool | check_premature_eof (http_message &http_msg) |
| Checks to see if a premature EOF was encountered while parsing. | |
| void | parse_headers_only (bool b=true) |
| Controls headers-only parsing (default is disabled; content parsed also) | |
| void | skip_header_parsing (http_message &http_msg) |
| Skip parsing all headers and parse payload content only. | |
| void | reset () |
| Resets the parser to its initial state. | |
| bool | eof () const |
| Returns true if there are no more bytes available in the read buffer. | |
| size_t | bytes_available () const |
| Returns the number of bytes available in the read buffer. | |
| size_t | gcount () const |
| Returns the number of bytes read during the last parse operation. | |
| size_t | get_total_bytes_read () const |
| Returns the total number of bytes read while parsing the HTTP message. | |
| size_t | get_content_bytes_read () const |
| Returns the total number of bytes read while parsing the payload content. | |
| size_t | get_max_content_length () const |
| Returns the maximum length for HTTP payload content. | |
| const std::string & | get_raw_headers () const |
| Returns the raw HTTP headers saved by the parser. | |
| bool | get_save_raw_headers () const |
| Returns true if the parser is saving raw HTTP header contents. | |
| bool | get_parse_headers_only () |
| Returns true if parsing headers only. | |
| bool | is_parsing_request () const |
| Returns true if the parser is being used to parse an HTTP request. | |
| bool | is_parsing_response () const |
| Returns true if the parser is being used to parse an HTTP response. | |
| void | set_payload_handler (payload_handler_type &h) |
| Defines a callback function to be used for consuming payload content. | |
| void | set_max_content_length (size_t n) |
| Sets the maximum length for HTTP payload content. | |
| void | reset_max_content_length () |
| 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. | |
| sl::support::tribool | finish_header_parsing (http_message &http_msg, std::error_code &ec) |
| Should be called after parsing HTTP headers, to prepare for payload content parsing available in the read buffer. | |
Static Public Member Functions | |
| static void | receive (std::unique_ptr< http_request_reader > self) |
| Incrementally reads & parses the HTTP message. | |
Static Public Member Functions inherited from staticlib::pion::http_parser | |
| static bool | parse_uri (const std::string &uri, std::string &proto, std::string &host, uint16_t &port, std::string &path, std::string &query) |
| Parses a URI string. | |
| static bool | parse_url_encoded (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const char *ptr, const size_t len) |
| Parse key-value pairs out of a url-encoded string (i.e. | |
| static bool | parse_multipart_form_data (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const std::string &content_type, const char *ptr, const size_t len) |
| Parse key-value pairs out of a multipart/form-data payload content (http://www.ietf.org/rfc/rfc2388.txt) | |
| static bool | parse_cookie_header (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const char *ptr, const size_t len, bool set_cookie_header) |
| Parse key-value pairs out of a "Cookie" request header (i.e. | |
| static bool | parse_cookie_header (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const std::string &cookie_header, bool set_cookie_header) |
| Parse key-value pairs out of a "Cookie" request header (i.e. | |
| static bool | parse_url_encoded (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const std::string &query) |
| Parse key-value pairs out of a url-encoded string (i.e. | |
| static bool | parse_multipart_form_data (std::unordered_multimap< std::string, std::string, algorithm::ihash, algorithm::iequal_to > &dict, const std::string &content_type, const std::string &form_data) |
| Parse key-value pairs out of a multipart/form-data payload content (http://www.ietf.org/rfc/rfc2388.txt) | |
| static error_category_t & | get_error_category () |
| Returns an instance of parser::error_category_t. | |
Additional Inherited Members | |
Public Types inherited from staticlib::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. More... | |
Static Public Attributes inherited from staticlib::pion::http_parser | |
| static const size_t | DEFAULT_CONTENT_MAX |
| Maximum length for HTTP payload content (for non-streaming server) | |
Protected Member Functions inherited from staticlib::pion::http_parser | |
| virtual void | finished_parsing_headers (const std::error_code &, sl::support::tribool &) |
| Called after we have finished parsing the HTTP message headers. | |
| sl::support::tribool | parse_headers (http_message &http_msg, std::error_code &ec) |
| Parses an HTTP message up to the end of the headers using bytes available in the read buffer. | |
| void | update_message_with_header_data (http_message &http_msg) const |
| Updates an http::message object with data obtained from parsing headers. | |
| sl::support::tribool | parse_chunks (std::vector< char > &chunk_buffers, std::error_code &ec) |
| Parses a chunked HTTP message-body using bytes available in the read buffer. | |
| sl::support::tribool | consume_content (http_message &http_msg, std::error_code &ec) |
| Consumes payload content in the parser's read buffer. | |
| size_t | consume_content_as_next_chunk (std::vector< char > &chunk_buffers) |
| Consume the bytes available in the read buffer, converting them into the next chunk for the HTTP message. | |
Static Protected Member Functions inherited from staticlib::pion::http_parser | |
| static void | compute_msg_status (http_message &http_msg, bool msg_parsed_ok) |
| Compute and sets a HTTP Message data integrity status. | |
| static void | set_error (std::error_code &ec, error_value_t ev) |
| Sets an error code. | |
| static void | create_error_category () |
| Creates the unique parser error_category_t. | |
| 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) |
Protected Attributes inherited from staticlib::pion::http_parser | |
| 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 staticlib::pion::http_parser | |
| static const uint32_t | STATUS_MESSAGE_MAX |
| Maximum length for response status message. | |
| static const uint32_t | METHOD_MAX |
| Maximum length for the request method. | |
| static const uint32_t | RESOURCE_MAX |
| Maximum length for the resource requested. | |
| static const uint32_t | QUERY_STRING_MAX |
| Maximum length for the query string. | |
| static const uint32_t | HEADER_NAME_MAX |
| Maximum length for an HTTP header name. | |
| static const uint32_t | HEADER_VALUE_MAX |
| Maximum length for an HTTP header value. | |
| static const uint32_t | QUERY_NAME_MAX |
| Maximum length for the name of a query string variable. | |
| static const uint32_t | QUERY_VALUE_MAX |
| Maximum length for the value of a query string variable. | |
| static const uint32_t | COOKIE_NAME_MAX |
| Maximum length for the name of a cookie name. | |
| static const uint32_t | COOKIE_VALUE_MAX |
| Maximum length for the value of a cookie; also used for path and domain. | |
Asynchronously reads and parses HTTP requests.
|
inline |
Constructor to be used with std::make_unique
| server | reference to server |
| tcp_conn | TCP connection containing a new message to parse |
| staticlib::pion::http_request_reader::http_request_reader | ( | const http_request_reader & | ) |
Deleted copy-constructor.
| other | instance |
| http_request_reader& staticlib::pion::http_request_reader::operator= | ( | const http_request_reader & | ) |
Deleted copy-assignment operator.
| other | instance |
|
static |
Incrementally reads & parses the HTTP message.
1.8.1.2