Realistic 3D camera system
3D camera system components
request_parser.hpp
Go to the documentation of this file.
1 //
2 // request_parser.hpp
3 // ~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 HTTP_REQUEST_PARSER_HPP
12 #define HTTP_REQUEST_PARSER_HPP
13 
14 #include <tuple>
15 
16 namespace http {
17 namespace server {
18 
19 struct request;
20 
22 class request_parser
23 {
24 public:
27 
29  void reset();
30 
33 
38  template <typename InputIterator>
39  std::tuple<result_type, InputIterator> parse(request& req,
40  InputIterator begin, InputIterator end)
41  {
42  while (begin != end)
43  {
44  result_type result = consume(req, *begin++);
45  if (result == good || result == bad)
46  return std::make_tuple(result, begin);
47  }
48  return std::make_tuple(indeterminate, begin);
49  }
50 
51 private:
53  result_type consume(request& req, char input);
54 
56  static bool is_char(int c);
57 
59  static bool is_ctl(int c);
60 
62  static bool is_tspecial(int c);
63 
65  static bool is_digit(int c);
66 
68  enum state
69  {
70  method_start,
71  method,
72  uri,
73  http_version_h,
74  http_version_t_1,
75  http_version_t_2,
76  http_version_p,
77  http_version_slash,
78  http_version_major_start,
79  http_version_major,
80  http_version_minor_start,
81  http_version_minor,
82  expecting_newline_1,
83  header_line_start,
84  header_lws,
85  header_name,
86  space_before_header_value,
87  header_value,
88  expecting_newline_2,
89  expecting_newline_3
90  } state_;
91 };
92 
93 } // namespace server
94 } // namespace http
95 
96 #endif // HTTP_REQUEST_PARSER_HPP
SocketService Iterator begin
Definition: connect.hpp:521
request_parser()
Construct ready to parse the request method.
void reset()
Reset to initial parser state.
std::tuple< result_type, InputIterator > parse(request &req, InputIterator begin, InputIterator end)
SocketService Iterator Iterator end
Definition: connect.hpp:592
A request received from a client.
Definition: request.hpp:22