Wire Sysio Wire Sysion 1.0.0
|
#include <parser.hpp>
Public Member Functions | |
parser () | |
std::string const & | get_version () const |
Get the HTTP version string. | |
void | 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. | |
void | append_header (std::string const &key, std::string const &val) |
Append a value to an existing HTTP header. | |
void | replace_header (std::string const &key, std::string const &val) |
Set a value for an HTTP header, replacing an existing value. | |
void | remove_header (std::string const &key) |
Remove a header from the parser. | |
std::string const & | get_body () const |
Get HTTP body. | |
void | 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. | |
Protected Member Functions | |
void | process_header (std::string::iterator begin, std::string::iterator end) |
Process a header line. | |
bool | prepare_body () |
Prepare the parser to begin parsing body data. | |
size_t | process_body (char const *buf, size_t len) |
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 | |
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 |
Includes methods and data elements common to all types of HTTP messages such as headers, versions, bodies, etc.
Definition at line 398 of file parser.hpp.
|
inline |
Definition at line 400 of file parser.hpp.
|
inline |
This method will set the value of the HTTP header key
with the indicated value. If a header with the name key
already exists, val
will be appended to the existing value.
Make this method case insensitive.
Should there be any restrictions on which keys are allowed?
Exception free varient
[in] | key | The name/key of the header to append to. |
[in] | val | The value to append. |
Definition at line 67 of file parser.hpp.
|
inlineprotected |
Behavior before a call to prepare_body
is undefined.
Definition at line 589 of file parser.hpp.
|
inline |
Gets the body of the HTTP object
Definition at line 495 of file parser.hpp.
|
inline |
[in] | key | The name/key of the header to get. |
Definition at line 45 of file parser.hpp.
|
inline |
If the header requested doesn't exist or exists and is empty the parameter list is valid (but empty).
[in] | key | The name/key of the HTTP header to use as input. |
[out] | out | The parameter list to store extracted parameters in. |
Definition at line 55 of file parser.hpp.
|
inline |
Retrieves the maximum number of bytes to parse & buffer before canceling a request.
Definition at line 519 of file parser.hpp.
|
inline |
Definition at line 410 of file parser.hpp.
|
inline |
[in] | in | The input string. |
[out] | out | The parameter list to store extracted parameters in. |
Definition at line 107 of file parser.hpp.
|
inlineprotected |
Inspects headers to determine if the message has a body that needs to be read. If so, sets up the necessary state, otherwise returns false. If this method returns true and loading the message body is desired call process_body
until it returns zero bytes or an error.
Must not be called until after all headers have been processed.
Definition at line 119 of file parser.hpp.
|
inlineprotected |
Parses body data.
[in] | begin | An iterator to the beginning of the sequence. |
[in] | end | An iterator to the end of the sequence. |
Definition at line 145 of file parser.hpp.
|
inlineprotected |
[in] | begin | An iterator to the beginning of the sequence. |
[in] | end | An iterator to the end of the sequence. |
Definition at line 161 of file parser.hpp.
|
inlineprotected |
Each headers will be followed by the \r
sequence including the last one. A second \r
sequence (blank header) is not appended by this method
Definition at line 179 of file parser.hpp.
|
inline |
Removes the header entirely from the parser. This is different than setting the value of the header to blank.
[in] | key | The name/key of the header to remove. |
Definition at line 87 of file parser.hpp.
|
inline |
This method will set the value of the HTTP header key
with the indicated value. If a header with the name key
already exists, val
will replace the existing value.
Make this method case insensitive.
Should there be any restrictions on which keys are allowed?
Exception free varient
[in] | key | The name/key of the header to append to. |
[in] | val | The value to append. |
Definition at line 81 of file parser.hpp.
|
inline |
Set the body content of the HTTP response to the parameter string. Note set_body will also set the Content-Length HTTP header to the appropriate value. If you want the Content-Length header to be something else, do so via replace_header("Content-Length") after calling set_body()
value | String data to include as the body content. |
Definition at line 91 of file parser.hpp.
|
inline |
Set the maximum number of bytes to parse and buffer before canceling a request.
value | The size to set the max body length to. |
Definition at line 532 of file parser.hpp.
|
inline |
Input should be in format: HTTP/x.y where x and y are positive integers.
[in] | version | The value to set the HTTP version to. |
Definition at line 41 of file parser.hpp.
|
protected |
Definition at line 607 of file parser.hpp.
|
protected |
Definition at line 609 of file parser.hpp.
|
protected |
Definition at line 608 of file parser.hpp.
|
protected |
Definition at line 610 of file parser.hpp.
|
protected |
Definition at line 605 of file parser.hpp.
|
protected |
Definition at line 603 of file parser.hpp.
|
protected |
Definition at line 602 of file parser.hpp.