http_request_parser.hpp
Go to the documentation of this file.
1 //
2 // http_request_parser.hpp
3 // ~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef CPP_WEB_SERVER_HTTP_REQUEST_PARSER_HPP
12 #define CPP_WEB_SERVER_HTTP_REQUEST_PARSER_HPP
13 
15 
16 #include <boost/logic/tribool.hpp>
17 #include <boost/tuple/tuple.hpp>
18 
19 namespace async_web_server_cpp
20 {
21 
23 {
24 public:
27 
29  void reset();
30 
35  template<typename InputIterator>
36  boost::tuple<boost::tribool, InputIterator>
37  parse(HttpRequest& req, InputIterator begin, InputIterator end)
38  {
39  while (begin != end)
40  {
41  boost::tribool result = consume(req, *begin++);
42  if (result || !result)
43  return boost::make_tuple(result, begin);
44  }
45  boost::tribool result = boost::indeterminate;
46  return boost::make_tuple(result, begin);
47  }
48 
49 private:
51  boost::tribool consume(HttpRequest& req, char input);
52 
54  static bool is_char(int c);
55 
57  static bool is_ctl(int c);
58 
60  static bool is_tspecial(int c);
61 
63  static bool is_digit(int c);
64 
66  enum state
67  {
70  uri,
88  } state_;
89 };
90 
91 } // namespace async_web_server_cpp
92 
93 #endif
async_web_server_cpp::HttpRequestParser::http_version_slash
@ http_version_slash
Definition: http_request_parser.hpp:75
async_web_server_cpp::HttpRequestParser
Definition: http_request_parser.hpp:22
async_web_server_cpp::HttpRequestParser::is_tspecial
static bool is_tspecial(int c)
Check if a byte is defined as an HTTP tspecial character.
Definition: http_request_parser.cpp:294
async_web_server_cpp::HttpRequestParser::reset
void reset()
Reset to initial parser state.
Definition: http_request_parser.cpp:17
async_web_server_cpp::HttpRequestParser::method
@ method
Definition: http_request_parser.hpp:69
async_web_server_cpp::HttpRequestParser::state_
enum async_web_server_cpp::HttpRequestParser::state state_
async_web_server_cpp::HttpRequestParser::header_line_start
@ header_line_start
Definition: http_request_parser.hpp:81
async_web_server_cpp::HttpRequestParser::header_lws
@ header_lws
Definition: http_request_parser.hpp:82
async_web_server_cpp::HttpRequestParser::header_value
@ header_value
Definition: http_request_parser.hpp:85
async_web_server_cpp::HttpRequestParser::expecting_newline_1
@ expecting_newline_1
Definition: http_request_parser.hpp:80
async_web_server_cpp::HttpRequestParser::header_name
@ header_name
Definition: http_request_parser.hpp:83
async_web_server_cpp::HttpRequestParser::expecting_newline_2
@ expecting_newline_2
Definition: http_request_parser.hpp:86
async_web_server_cpp
Definition: http_connection.hpp:14
async_web_server_cpp::HttpRequestParser::is_digit
static bool is_digit(int c)
Check if a byte is a digit.
Definition: http_request_parser.cpp:323
async_web_server_cpp::HttpRequestParser::is_ctl
static bool is_ctl(int c)
Check if a byte is an HTTP control character.
Definition: http_request_parser.cpp:289
async_web_server_cpp::HttpRequestParser::method_start
@ method_start
Definition: http_request_parser.hpp:68
async_web_server_cpp::HttpRequest
Definition: http_request.hpp:18
async_web_server_cpp::HttpRequestParser::is_char
static bool is_char(int c)
Check if a byte is an HTTP character.
Definition: http_request_parser.cpp:284
async_web_server_cpp::HttpRequestParser::state
state
The current state of the parser.
Definition: http_request_parser.hpp:66
async_web_server_cpp::HttpRequestParser::consume
boost::tribool consume(HttpRequest &req, char input)
Handle the next character of input.
Definition: http_request_parser.cpp:22
async_web_server_cpp::HttpRequestParser::parse
boost::tuple< boost::tribool, InputIterator > parse(HttpRequest &req, InputIterator begin, InputIterator end)
Definition: http_request_parser.hpp:37
async_web_server_cpp::HttpRequestParser::space_before_header_value
@ space_before_header_value
Definition: http_request_parser.hpp:84
async_web_server_cpp::HttpRequestParser::http_version_t_1
@ http_version_t_1
Definition: http_request_parser.hpp:72
async_web_server_cpp::HttpRequestParser::http_version_h
@ http_version_h
Definition: http_request_parser.hpp:71
async_web_server_cpp::HttpRequestParser::http_version_p
@ http_version_p
Definition: http_request_parser.hpp:74
async_web_server_cpp::HttpRequestParser::http_version_minor_start
@ http_version_minor_start
Definition: http_request_parser.hpp:78
async_web_server_cpp::HttpRequestParser::http_version_major_start
@ http_version_major_start
Definition: http_request_parser.hpp:76
async_web_server_cpp::HttpRequestParser::http_version_minor
@ http_version_minor
Definition: http_request_parser.hpp:79
async_web_server_cpp::HttpRequestParser::expecting_newline_3
@ expecting_newline_3
Definition: http_request_parser.hpp:87
async_web_server_cpp::HttpRequestParser::http_version_t_2
@ http_version_t_2
Definition: http_request_parser.hpp:73
async_web_server_cpp::HttpRequestParser::HttpRequestParser
HttpRequestParser()
Construct ready to parse the request method.
Definition: http_request_parser.cpp:15
async_web_server_cpp::HttpRequestParser::uri
@ uri
Definition: http_request_parser.hpp:70
http_request.hpp
async_web_server_cpp::HttpRequestParser::http_version_major
@ http_version_major
Definition: http_request_parser.hpp:77


async_web_server_cpp
Author(s): Mitchell Wills , Russel Toris
autogenerated on Tue Mar 1 2022 23:49:06