http_request_parser.hpp
Go to the documentation of this file.
00001 //
00002 // http_request_parser.hpp
00003 // ~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef CPP_WEB_SERVER_HTTP_REQUEST_PARSER_HPP
00012 #define CPP_WEB_SERVER_HTTP_REQUEST_PARSER_HPP
00013 
00014 #include <boost/logic/tribool.hpp>
00015 #include <boost/tuple/tuple.hpp>
00016 #include "async_web_server_cpp/http_request.hpp"
00017 
00018 namespace async_web_server_cpp
00019 {
00020 
00021 class HttpRequestParser
00022 {
00023 public:
00025   HttpRequestParser();
00026 
00028   void reset();
00029 
00034   template<typename InputIterator>
00035   boost::tuple<boost::tribool, InputIterator> parse(HttpRequest &req,
00036       InputIterator begin, InputIterator end)
00037   {
00038     while (begin != end)
00039     {
00040       boost::tribool result = consume(req, *begin++);
00041       if (result || !result)
00042         return boost::make_tuple(result, begin);
00043     }
00044     boost::tribool result = boost::indeterminate;
00045     return boost::make_tuple(result, begin);
00046   }
00047 
00048 private:
00050   boost::tribool consume(HttpRequest &req, char input);
00051 
00053   static bool is_char(int c);
00054 
00056   static bool is_ctl(int c);
00057 
00059   static bool is_tspecial(int c);
00060 
00062   static bool is_digit(int c);
00063 
00065   enum state
00066   {
00067     method_start,
00068     method,
00069     uri,
00070     http_version_h,
00071     http_version_t_1,
00072     http_version_t_2,
00073     http_version_p,
00074     http_version_slash,
00075     http_version_major_start,
00076     http_version_major,
00077     http_version_minor_start,
00078     http_version_minor,
00079     expecting_newline_1,
00080     header_line_start,
00081     header_lws,
00082     header_name,
00083     space_before_header_value,
00084     header_value,
00085     expecting_newline_2,
00086     expecting_newline_3
00087   } state_;
00088 };
00089 
00090 }
00091 
00092 #endif


async_web_server_cpp
Author(s): Mitchell Wills
autogenerated on Sat Jun 8 2019 18:56:50