28 #ifndef HTTP_PARSER_HPP    29 #define HTTP_PARSER_HPP    52 namespace body_encoding {
    60 typedef std::map<std::string, std::string, utility::ci_less > 
header_list;
    72 template <
typename InputIterator>
    77     return std::make_pair(std::string(begin,it),it);
    91 template <
typename InputIterator>
    98         return std::make_pair(s,begin);
   102         return std::make_pair(s,begin);
   105     InputIterator cursor = begin+1;
   106     InputIterator marker = cursor;
   108     cursor = std::find(cursor,end,
'"');
   110     while (cursor != end) {
   112         if (*(cursor-1) == 
'\\') {
   113             s.append(marker,cursor-1);
   118             s.append(marker,cursor);
   120             return std::make_pair(s,cursor);
   123         cursor = std::find(cursor,end,
'"');
   126     return std::make_pair(
"",begin);
   138 template <
typename InputIterator>
   139 InputIterator 
extract_lws(InputIterator begin, InputIterator end) {
   140     InputIterator it = begin;
   143     if (end-begin > 2 && *begin == 
'\r' && *(begin+1) == 
'\n' &&
   163 template <
typename InputIterator>
   165     InputIterator old_it;
   166     InputIterator new_it = begin;
   174     } 
while (new_it != end && old_it != new_it);
   194 template <
typename InputIterator>
   198     InputIterator cursor;
   206     std::pair<std::string,InputIterator> ret;
   208     while (cursor != end) {
   220             if (*cursor == 
';') {
   233         if (ret.first.empty()) {
   242         if (cursor == end || *cursor != 
'=') {
   245             attributes[name].clear();
   259         if (ret.second != cursor) {
   260             attributes[name] = ret.first;
   266         if (ret.first.empty()) {
   270             attributes[name] = ret.first;
   292 template <
typename InputIterator>
   296     InputIterator cursor;
   304     std::pair<std::string,InputIterator> ret;
   314     while (cursor != end) {
   315         std::string parameter_name;
   320         if (cursor == end) {
break;}
   324         if (ret.first.empty()) {
   328             parameter_name = ret.first;
   336             parameters.push_back(std::make_pair(parameter_name,attributes));
   341         if (*cursor == 
';') {
   342             InputIterator acursor;
   347             if (acursor == cursor) {
   357         parameters.push_back(std::make_pair(parameter_name,attributes));
   360         if (cursor == end) {
break;}
   363         if (*cursor != 
',') {
   379 inline std::string 
strip_lws(std::string 
const & input) {
   380     std::string::const_iterator begin = 
extract_all_lws(input.begin(),input.end());
   381     if (begin == input.end()) {
   382         return std::string();
   385     std::string::const_reverse_iterator rbegin = 
extract_all_lws(input.rbegin(),input.rend());
   386     if (rbegin == input.rend()) {
   387         return std::string();
   390     return std::string(begin,rbegin.base());
   402       , m_body_bytes_needed(0)
   404       , m_body_encoding(body_encoding::
unknown) {}
   421     void set_version(std::string 
const & 
version);
   430     std::string 
const & get_header(std::string 
const & key) 
const;
   441     bool get_header_as_plist(std::string 
const & key, 
parameter_list & out)
   459     void append_header(std::string 
const & key, std::string 
const & val);
   476     void replace_header(std::string 
const & key, std::string 
const & val);
   487     void remove_header(std::string 
const & key);
   508     void set_body(std::string 
const & 
value);
   520         return m_body_bytes_max;
   533         m_body_bytes_max = 
value;
   542     bool parse_parameter_list(std::string 
const & in, 
parameter_list & out)
   579     size_t process_body(
char const * buf, 
size_t len);
   590         return (m_body_bytes_needed == 0);
   600     std::string raw_headers() 
const;
   619 #endif // HTTP_PARSER_HPP size_t get_max_body_size() const 
Get body size limit. 
 
bool is_not_whitespace_char(unsigned char c)
Is the character non-whitespace. 
 
std::string const & get_body() const 
Get HTTP body. 
 
std::vector< std::pair< std::string, attribute_list > > parameter_list
The type of an HTTP parameter list. 
 
size_t m_body_bytes_needed
 
InputIterator extract_lws(InputIterator begin, InputIterator end)
Read and discard one unit of linear whitespace. 
 
bool is_not_token_char(unsigned char c)
Is the character a non-token. 
 
std::map< std::string, std::string, utility::ci_less > header_list
 
Table::const_iterator iterator
 
std::string const & get_version() const 
Get the HTTP version string. 
 
InputIterator extract_parameters(InputIterator begin, InputIterator end, parameter_list ¶meters)
Extract HTTP parameters. 
 
InputIterator extract_attributes(InputIterator begin, InputIterator end, attribute_list &attributes)
Extract HTTP attributes. 
 
std::pair< std::string, InputIterator > extract_quoted_string(InputIterator begin, InputIterator end)
Read and return the next quoted string in the stream. 
 
Namespace for the WebSocket++ project. 
 
std::map< std::string, std::string > attribute_list
The type of an HTTP attribute list. 
 
std::string strip_lws(std::string const &input)
 
bool body_ready() const 
Check if the parser is done parsing the body. 
 
body_encoding::value m_body_encoding
 
InputIterator extract_all_lws(InputIterator begin, InputIterator end)
Read and discard linear whitespace. 
 
std::pair< std::string, InputIterator > extract_token(InputIterator begin, InputIterator end)
Read and return the next token in the stream. 
 
bool is_whitespace_char(unsigned char c)
Is the character whitespace. 
 
size_t const max_body_size
Default Maximum size in bytes for HTTP message bodies. 
 
void set_max_body_size(size_t value)
Set body size limit.