NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::http::parser::request Class Reference

Stores, parses, and manipulates HTTP requests. More...

#include <request.hpp>

Inheritance diagram for websocketpp::http::parser::request:
Collaboration diagram for websocketpp::http::parser::request:

Public Types

typedef request type
 
typedef lib::shared_ptr< typeptr
 

Public Member Functions

 request ()
 
size_t consume (char const *buf, size_t len)
 Process bytes in the input buffer. More...
 
bool ready () const
 Returns whether or not the request is ready for reading. More...
 
std::string raw () const
 Returns the full raw request (including the body) More...
 
std::string raw_head () const
 Returns the raw request headers only (similar to an HTTP HEAD request) More...
 
void set_method (std::string const &method)
 Set the HTTP method. Must be a valid HTTP token. More...
 
std::string const & get_method () const
 Return the request method. More...
 
void set_uri (std::string const &uri)
 Set the HTTP uri. Must be a valid HTTP uri. More...
 
std::string const & get_uri () const
 Return the requested URI. More...
 
- Public Member Functions inherited from websocketpp::http::parser::parser
 parser ()
 
std::string const & get_version () const
 Get the HTTP version string. More...
 
void set_version (std::string const &version)
 Set HTTP parser Version. More...
 
std::string const & get_header (std::string const &key) const
 Get the value of an HTTP header. More...
 
bool get_header_as_plist (std::string const &key, parameter_list &out) const
 Extract an HTTP parameter list from a parser header. More...
 
void append_header (std::string const &key, std::string const &val)
 Append a value to an existing HTTP header. More...
 
void replace_header (std::string const &key, std::string const &val)
 Set a value for an HTTP header, replacing an existing value. More...
 
void remove_header (std::string const &key)
 Remove a header from the parser. More...
 
std::string const & get_body () const
 Get HTTP body. More...
 
void set_body (std::string const &value)
 Set body content. More...
 
size_t get_max_body_size () const
 Get body size limit. More...
 
void set_max_body_size (size_t value)
 Set body size limit. More...
 
bool parse_parameter_list (std::string const &in, parameter_list &out) const
 Extract an HTTP parameter list from a string. More...
 

Additional Inherited Members

- Protected Member Functions inherited from websocketpp::http::parser::parser
void process_header (std::string::iterator begin, std::string::iterator end)
 Process a header line. More...
 
bool prepare_body ()
 Prepare the parser to begin parsing body data. More...
 
size_t process_body (char const *buf, size_t len)
 Process body data. More...
 
bool body_ready () const
 Check if the parser is done parsing the body. More...
 
std::string raw_headers () const
 Generate and return the HTTP headers as a string. More...
 
- Protected Attributes inherited from websocketpp::http::parser::parser
std::string m_version
 
header_list m_headers
 
size_t m_header_bytes
 
std::string m_body
 
size_t m_body_bytes_needed
 
size_t m_body_bytes_max
 
body_encoding::value m_body_encoding
 

Detailed Description

Stores, parses, and manipulates HTTP requests.

http::request provides the following functionality for working with HTTP requests.

  • Initialize request via manually setting each element
  • Initialize request via reading raw bytes and parsing
  • Once initialized, access individual parsed elements
  • Once initialized, read entire request as raw bytes

Definition at line 50 of file request.hpp.

Member Typedef Documentation

Definition at line 52 of file request.hpp.

Definition at line 53 of file request.hpp.

Constructor & Destructor Documentation

websocketpp::http::parser::request::request ( )
inline

Definition at line 55 of file request.hpp.

References consume().

Member Function Documentation

size_t websocketpp::http::parser::request::consume ( char const *  buf,
size_t  len 
)
inline

Process bytes in the input buffer.

Process up to len bytes from input buffer buf. Returns the number of bytes processed. Bytes left unprocessed means bytes left over after the final header delimiters.

Consume is a streaming processor. It may be called multiple times on one request and the full headers need not be available before processing can begin. If the end of the request was reached during this call to consume the ready flag will be set. Further calls to consume once ready will be ignored.

Consume will throw an http::exception in the case of an error. Typical error reasons include malformed requests, incomplete requests, and max header size being reached.

Parameters
bufPointer to byte buffer
lenSize of byte buffer
Returns
Number of bytes processed.

Definition at line 41 of file request.hpp.

References websocketpp::http::status_code::bad_request, websocketpp::http::parser::parser::body_ready(), websocketpp::http::parser::parser::get_header(), websocketpp::http::header_delimiter, websocketpp::http::parser::parser::m_body_bytes_needed, websocketpp::http::parser::parser::m_header_bytes, websocketpp::http::max_header_size, websocketpp::http::parser::parser::prepare_body(), websocketpp::http::parser::parser::process_body(), websocketpp::http::parser::parser::process_header(), and websocketpp::http::status_code::request_header_fields_too_large.

Referenced by BOOST_AUTO_TEST_CASE(), main(), and request().

bool websocketpp::http::parser::request::ready ( ) const
inline

Returns whether or not the request is ready for reading.

Definition at line 82 of file request.hpp.

References websocketpp::http::parser::state::method, raw(), raw_head(), and set_method().

Referenced by BOOST_AUTO_TEST_CASE(), and main().

std::string websocketpp::http::parser::request::raw ( ) const
inline

Returns the full raw request (including the body)

Definition at line 131 of file request.hpp.

References websocketpp::http::parser::parser::get_version(), websocketpp::http::parser::parser::m_body, and websocketpp::http::parser::parser::raw_headers().

Referenced by BOOST_AUTO_TEST_CASE(), and ready().

std::string websocketpp::http::parser::request::raw_head ( ) const
inline

Returns the raw request headers only (similar to an HTTP HEAD request)

Definition at line 141 of file request.hpp.

References websocketpp::http::parser::parser::get_version(), and websocketpp::http::parser::parser::raw_headers().

Referenced by ready().

void websocketpp::http::parser::request::set_method ( std::string const &  method)
inline

Set the HTTP method. Must be a valid HTTP token.

Definition at line 151 of file request.hpp.

References websocketpp::http::status_code::bad_request, websocketpp::http::is_not_token_char(), and websocketpp::http::parser::state::method.

Referenced by BOOST_AUTO_TEST_CASE(), ready(), and set_uri().

std::string const& websocketpp::http::parser::request::get_method ( ) const
inline

Return the request method.

Definition at line 96 of file request.hpp.

References set_uri().

Referenced by BOOST_AUTO_TEST_CASE().

void websocketpp::http::parser::request::set_uri ( std::string const &  uri)
inline

Set the HTTP uri. Must be a valid HTTP uri.

Definition at line 159 of file request.hpp.

References websocketpp::http::status_code::bad_request, set_method(), and websocketpp::http::parser::parser::set_version().

Referenced by BOOST_AUTO_TEST_CASE(), and get_method().

std::string const& websocketpp::http::parser::request::get_uri ( ) const
inline

Return the requested URI.

Definition at line 104 of file request.hpp.

Referenced by BOOST_AUTO_TEST_CASE().


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