Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HTTP_SERVER3_REQUEST_PARSER_H
00012 #define HTTP_SERVER3_REQUEST_PARSER_H
00013
00014 #include <boost/logic/tribool.hpp>
00015 #include <boost/tuple/tuple.hpp>
00016
00017 namespace ros_http_video_streamer
00018 {
00019
00020 struct request;
00021
00023 class request_parser
00024 {
00025 public:
00027 request_parser();
00028
00030 void reset();
00031
00036 template <typename InputIterator>
00037 boost::tuple<boost::tribool, InputIterator> parse(request& req,
00038 InputIterator begin, InputIterator end)
00039 {
00040 while (begin != end)
00041 {
00042 boost::tribool result = consume(req, *begin++);
00043 if (result || !result)
00044 return boost::make_tuple(result, begin);
00045 }
00046 boost::tribool result = boost::indeterminate;
00047 return boost::make_tuple(result, begin);
00048 }
00049
00050 private:
00052 boost::tribool consume(request& req, char input);
00053
00055 static bool is_char(int c);
00056
00058 static bool is_ctl(int c);
00059
00061 static bool is_tspecial(int c);
00062
00064 static bool is_digit(int c);
00065
00067 enum state
00068 {
00069 method_start,
00070 method,
00071 uri_start,
00072 uri,
00073 http_version_h,
00074 http_version_t_1,
00075 http_version_t_2,
00076 http_version_p,
00077 http_version_slash,
00078 http_version_major_start,
00079 http_version_major,
00080 http_version_minor_start,
00081 http_version_minor,
00082 expecting_newline_1,
00083 header_line_start,
00084 header_lws,
00085 header_name,
00086 space_before_header_value,
00087 header_value,
00088 expecting_newline_2,
00089 expecting_newline_3
00090 } state_;
00091 };
00092
00093 }
00094
00095 #endif // HTTP_SERVER3_REQUEST_PARSER_HPP