28 #ifndef HTTP_PARSER_IMPL_HPP 29 #define HTTP_PARSER_IMPL_HPP 41 inline void parser::set_version(std::string
const &
version) {
46 header_list::const_iterator h =
m_headers.find(key);
58 header_list::const_iterator it =
m_headers.find(key);
60 if (it ==
m_headers.end() || it->second.size() == 0) {
92 if (value.size() == 0) {
101 std::stringstream len;
110 if (in.size() == 0) {
114 std::string::const_iterator it;
116 return (it == in.begin());
121 std::string
const & cl_header =
get_header(
"Content-Length");
130 throw exception(
"HTTP message body too large",
136 }
else if (
get_header(
"Transfer-Encoding") ==
"chunked") {
148 m_body.append(buf,processed);
153 throw exception(
"Unexpected body encoding",
156 throw exception(
"Unexpected body encoding",
162 std::string::iterator end)
164 std::string::iterator cursor = std::search(
184 std::stringstream raw;
186 header_list::const_iterator it;
188 raw << it->first <<
": " << it->second <<
"\r\n";
200 #endif // HTTP_PARSER_IMPL_HPP std::string const & get_header(std::string const &key) const
Get the value of an HTTP header.
static std::string const empty_header
Literal value of an empty 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.
void set_body(std::string const &value)
Set body content.
std::vector< std::pair< std::string, attribute_list > > parameter_list
The type of an HTTP parameter list.
size_t m_body_bytes_needed
size_t process_body(char const *buf, size_t len)
Process body data.
bool is_not_token_char(unsigned char c)
Is the character a non-token.
bool prepare_body()
Prepare the parser to begin parsing body data.
std::map< std::string, std::string, utility::ci_less > header_list
void process_header(std::string::iterator begin, std::string::iterator end)
Process a header line.
std::string raw_headers() const
Generate and return the HTTP headers as a string.
static char const header_separator[]
Literal value of the HTTP header separator.
InputIterator extract_parameters(InputIterator begin, InputIterator end, parameter_list ¶meters)
Extract HTTP parameters.
Namespace for the WebSocket++ project.
void append_header(std::string const &key, std::string const &val)
Append a value to an existing HTTP header.
std::string strip_lws(std::string const &input)
void replace_header(std::string const &key, std::string const &val)
Set a value for an HTTP header, replacing an existing value.
body_encoding::value m_body_encoding
bool parse_parameter_list(std::string const &in, parameter_list &out) const
Extract an HTTP parameter list from a string.
void remove_header(std::string const &key)
Remove a header from the parser.