Advertisement
bueddl

Untitled

Aug 15th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1.  
  2.  
  3. bool http_parser::parse_http_version(header::version &version)
  4. {
  5.     // HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
  6.     save();
  7.  
  8.     if (parse_static_string("HTTP/")
  9.             && parse_decimal_number_unsigned(version.major)
  10.             && parse_static_string(".")
  11.             && parse_decimal_number_unsigned(version.minor))
  12.         return commit();
  13.  
  14.     return restore();
  15. }
  16.  
  17. bool http_parser::parse_decimal_number_unsigned(uint &number)
  18. {
  19.     save();
  20.  
  21.     next_char();
  22.     if (!is_digit_nonzero())
  23.         return restore();
  24.  
  25.     number = 0;
  26.     do {
  27.         number *= 10;
  28.         number += current_seek_next() - '0';
  29.     } while (is_digit());
  30.  
  31.     return commit();
  32. }
  33.  
  34. bool http_parser::parse_comment(std::string &comment)
  35. {
  36.   // comment        = "(" *( ctext | quoted-pair | comment ) ")"
  37.   save();
  38.  
  39.   current_seek_next();
  40.   if (current() != '(')
  41.     return restore();
  42.  
  43.   std::string text;
  44.   while (parse_ctext(text) || parse_quoted_pair(text) || parse_comment(text))
  45.     comment += text;
  46.  
  47.   if (current() != '(')
  48.     return restore();
  49.  
  50.   return commit();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement