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_SERVER4_REQUEST_PARSER_HPP
12 #define HTTP_SERVER4_REQUEST_PARSER_HPP
13 
14 #include <string>
15 #include <boost/logic/tribool.hpp>
16 #include <boost/tuple/tuple.hpp>
17 #include <asio/coroutine.hpp>
18 
19 namespace http {
20 namespace server4 {
21 
22 struct request;
23 
26 {
27 public:
32  template <typename InputIterator>
33  boost::tuple<boost::tribool, InputIterator> parse(request& req,
34  InputIterator begin, InputIterator end)
35  {
36  while (begin != end)
37  {
38  boost::tribool result = consume(req, *begin++);
39  if (result || !result)
40  return boost::make_tuple(result, begin);
41  }
42  boost::tribool result = boost::indeterminate;
43  return boost::make_tuple(result, begin);
44  }
45 
46 private:
48  static std::string content_length_name_;
49 
51  std::size_t content_length_;
52 
54  boost::tribool consume(request& req, char input);
55 
57  static bool is_char(int c);
58 
60  static bool is_ctl(int c);
61 
63  static bool is_tspecial(int c);
64 
66  static bool is_digit(int c);
67 
69  static bool tolower_compare(char a, char b);
70 
72  bool headers_equal(const std::string& a, const std::string& b);
73 };
74 
75 } // namespace server4
76 } // namespace http
77 
78 #endif // HTTP_SERVER4_REQUEST_PARSER_HPP
SocketService Iterator begin
Definition: connect.hpp:521
Provides support for implementing stackless coroutines.
Definition: coroutine.hpp:241
boost::tuple< boost::tribool, InputIterator > parse(request &req, InputIterator begin, InputIterator end)
A request received from a client.
Definition: request.hpp:22
asio::basic_streambuf< Allocator > & b
Definition: read.hpp:702
Parser for incoming requests.
SocketService Iterator Iterator end
Definition: connect.hpp:592