websocketpp
0.4.0
C++/Boost Asio based websocket client/server library
|
Base HTTP parser. More...
#include <parser.hpp>
Public Member Functions | |
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 |
Set HTTP body. More... | |
void | set_body (std::string const &value) |
Set body content. More... | |
bool | parse_parameter_list (std::string const &in, parameter_list &out) const |
Extract an HTTP parameter list from a string. More... | |
Protected Member Functions | |
bool | parse_headers (std::istream &s) |
Parse headers from an istream. More... | |
void | process_header (std::string::iterator begin, std::string::iterator end) |
Process a header line. More... | |
std::string | raw_headers () const |
Generate and return the HTTP headers as a string. More... | |
Protected Attributes | |
std::string | m_version |
header_list | m_headers |
std::string | m_body |
Base HTTP parser.
Includes methods and data elements common to all types of HTTP messages such as headers, versions, bodies, etc.
Definition at line 385 of file parser.hpp.
|
inline |
Append a value to an existing HTTP header.
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 65 of file parser.hpp.
|
inline |
Set HTTP body.
Sets the body of the HTTP object and fills in the appropriate content length header.
[in] | value | The value to set the body to. |
Definition at line 477 of file parser.hpp.
|
inline |
Get the value of an HTTP header.
[in] | key | The name/key of the header to get. |
Definition at line 43 of file parser.hpp.
|
inline |
Extract an HTTP parameter list from a parser header.
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 53 of file parser.hpp.
|
inline |
Get the HTTP version string.
Definition at line 391 of file parser.hpp.
|
inlineprotected |
Parse headers from an istream.
[in] | s | The istream to extract headers from. |
Definition at line 114 of file parser.hpp.
|
inline |
Extract an HTTP parameter list from a string.
[in] | in | The input string. |
[out] | out | The parameter list to store extracted parameters in. |
Definition at line 102 of file parser.hpp.
|
inlineprotected |
Process a header line.
[in] | begin | An iterator to the beginning of the sequence. |
[in] | end | An iterator to the end of the sequence. |
Definition at line 136 of file parser.hpp.
|
inlineprotected |
Generate and return the HTTP headers as a string.
Each headers will be followed by the
sequence including the last one. A second
sequence (blank header) is not appended by this method
Definition at line 154 of file parser.hpp.
|
inline |
Remove a header from the parser.
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 85 of file parser.hpp.
|
inline |
Set a value for an HTTP header, replacing an existing value.
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 79 of file parser.hpp.
|
inline |
Set body content.
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 89 of file parser.hpp.
|
inline |
Set HTTP parser Version.
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 39 of file parser.hpp.