Loading...
Searching...
No Matches
websocketpp::http::parser::request Class Reference

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

`#include <request.hpp>`

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

## Public Types

typedef request | type
typedef lib::shared_ptr< type > | ptr

## Public Member Functions

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

## Additional Inherited Members

Protected Member Functions inherited from websocketpp::http::parser::parser
lib::error_code | process_header (std::string::iterator begin, std::string::iterator end)
| Process a header line.
bool | prepare_body (lib::error_code &ec)
| Prepare the parser to begin parsing body data.
size_t | process_body (char const *buf, size_t len, lib::error_code &ec)
| Process body data.
bool | body_ready () const
| Check if the parser is done parsing the body.
std::string | raw_headers () const
| Generate and return the HTTP headers as a string.
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

## ptr

typedef lib::shared_ptr<type> websocketpp::http::parser::request::ptr

Definition at line 53 of file request.hpp.

## type

typedef request websocketpp::http::parser::request::type

Definition at line 52 of file request.hpp.

## Constructor & Destructor Documentation

## request()

websocketpp::http::parser::request::request | ( |  | ) |

inline

Definition at line 55 of file request.hpp.

## Member Function Documentation

## consume()

size_t websocketpp::http::parser::request::consume | ( | char const * | buf,
|  | size_t | len,
|  | lib::error_code & | ec )

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.

Since
  0.9.0 Added ec parameter

Parameters

  [in] | buf | Pointer to byte buffer
  [in] | len | Size of byte buffer
  [out] | ec | A status code describing the outcome of the operation.

Returns
  Number of bytes processed.

Definition at line 41 of file request.hpp.

## get_method()

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

inline

Return the request method.

Definition at line 107 of file request.hpp.

## get_uri()

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

inline

Return the requested URI.

Definition at line 123 of file request.hpp.

## raw()

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

inline

Returns the full raw request (including the body).

Definition at line 195 of file request.hpp.

## raw_head()

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 205 of file request.hpp.

## ready()

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

inline

Returns whether or not the request is ready for reading.

Definition at line 85 of file request.hpp.

## set_method()

lib::error_code websocketpp::http::parser::request::set_method | ( | std::string const & | method | ) |

inline

Set the HTTP method.

Must be a valid HTTP token

Since
  0.9.0 added return value and removed exception

Parameters

  [in] | method | The value to set the method to.

Returns
  A status code describing the outcome of the operation.

Definition at line 215 of file request.hpp.

## set_uri()

lib::error_code websocketpp::http::parser::request::set_uri | ( | std::string const & | uri | ) |

inline

Set the HTTP uri.

Must be a valid HTTP uri

Since
  0.9.0 Return value added

Parameters

  uri | The URI to set

Returns
  A status code describing the outcome of the operation.

Definition at line 225 of file request.hpp.

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

- websocketpp/http/request.hpp
- websocketpp/http/impl/request.hpp