mirror of
https://github.com/boostorg/asio.git
synced 2026-01-28 06:42:08 +00:00
Fix compile error in regex overload of async_read_until.hpp. Fixes #5688 Explicitly specify the signal() function from the global namespace. Fixes #5722 Don't read the clock unless the heap is non-empty. Change the SSL buffers sizes so that they're large enough to hold a complete TLS record. Fixes #5854 Make sure the synchronous null_buffers operations obey the user's non_blocking setting. Fixes #5756 Set size of select fd_set at runtime when using Windows. Disable warning due to const qualifier being applied to function type. Fix crash due to gcc_x86_fenced_block that shows up when using the Intel C++ compiler. Fixes #5763 Specialise operations for buffer sequences that are arrays of exactly two buffers. Initialise all OpenSSL algorithms. Fix error mapping when session is gracefully shut down. Various performance improvements: * Split the task_io_service's run and poll code. * Use thread-local operation queues in single-threaded use cases (i.e. concurrency_hint is 1) to eliminate a lock/unlock pair. * Only fence block exit when a handler is being run directly out of the io_service. * Prefer x86 mfence-based fenced block when available. * Use a plain ol' long for the atomic_count when all thread support is disabled. * Allow some epoll_reactor speculative operations to be performed without holding the lock. * Improve locality of reference by performing an epoll_reactor's I/O operation immediately before the corresponding handler is called. This also improves scalability across CPUs when multiple threads are running the io_service. * Pass same error_code variable through to each operation's complete() function. * Optimise creation of and access to the io_service implementation. Remove unused state in HTTP server examples. Add latency test programs. [SVN r74863]
96 lines
2.3 KiB
C++
96 lines
2.3 KiB
C++
//
|
|
// request_parser.hpp
|
|
// ~~~~~~~~~~~~~~~~~~
|
|
//
|
|
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
#ifndef HTTP_SERVER2_REQUEST_PARSER_HPP
|
|
#define HTTP_SERVER2_REQUEST_PARSER_HPP
|
|
|
|
#include <boost/logic/tribool.hpp>
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
namespace http {
|
|
namespace server2 {
|
|
|
|
struct request;
|
|
|
|
/// Parser for incoming requests.
|
|
class request_parser
|
|
{
|
|
public:
|
|
/// Construct ready to parse the request method.
|
|
request_parser();
|
|
|
|
/// Reset to initial parser state.
|
|
void reset();
|
|
|
|
/// Parse some data. The tribool return value is true when a complete request
|
|
/// has been parsed, false if the data is invalid, indeterminate when more
|
|
/// data is required. The InputIterator return value indicates how much of the
|
|
/// input has been consumed.
|
|
template <typename InputIterator>
|
|
boost::tuple<boost::tribool, InputIterator> parse(request& req,
|
|
InputIterator begin, InputIterator end)
|
|
{
|
|
while (begin != end)
|
|
{
|
|
boost::tribool result = consume(req, *begin++);
|
|
if (result || !result)
|
|
return boost::make_tuple(result, begin);
|
|
}
|
|
boost::tribool result = boost::indeterminate;
|
|
return boost::make_tuple(result, begin);
|
|
}
|
|
|
|
private:
|
|
/// Handle the next character of input.
|
|
boost::tribool consume(request& req, char input);
|
|
|
|
/// Check if a byte is an HTTP character.
|
|
static bool is_char(int c);
|
|
|
|
/// Check if a byte is an HTTP control character.
|
|
static bool is_ctl(int c);
|
|
|
|
/// Check if a byte is defined as an HTTP tspecial character.
|
|
static bool is_tspecial(int c);
|
|
|
|
/// Check if a byte is a digit.
|
|
static bool is_digit(int c);
|
|
|
|
/// The current state of the parser.
|
|
enum state
|
|
{
|
|
method_start,
|
|
method,
|
|
uri,
|
|
http_version_h,
|
|
http_version_t_1,
|
|
http_version_t_2,
|
|
http_version_p,
|
|
http_version_slash,
|
|
http_version_major_start,
|
|
http_version_major,
|
|
http_version_minor_start,
|
|
http_version_minor,
|
|
expecting_newline_1,
|
|
header_line_start,
|
|
header_lws,
|
|
header_name,
|
|
space_before_header_value,
|
|
header_value,
|
|
expecting_newline_2,
|
|
expecting_newline_3
|
|
} state_;
|
|
};
|
|
|
|
} // namespace server2
|
|
} // namespace http
|
|
|
|
#endif // HTTP_SERVER2_REQUEST_PARSER_HPP
|