2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_HTTP_TEST_PARSER_HPP
11 #define BOOST_BEAST_HTTP_TEST_PARSER_HPP
13 #include <boost/beast/http/basic_parser.hpp>
14 #include <boost/beast/_experimental/test/fail_count.hpp>
16 #include <unordered_map>
22 template<bool isRequest>
24 : public basic_parser<isRequest>
26 test::fail_count* fc_ = nullptr;
29 using mutable_buffers_type =
40 int got_on_header = 0;
42 int got_content_length = 0;
44 int got_on_complete = 0;
46 std::string, std::string> fields;
48 test_parser() = default;
51 test_parser(test::fail_count& fc)
57 on_request_impl(verb, string_view method_str_,
58 string_view path_, int version_, error_code& ec)
61 method_str_.data(), method_str_.size());
63 path_.data(), path_.size());
71 on_response_impl(int code,
73 int version_, error_code& ec)
77 reason_.data(), reason_.size());
85 on_field_impl(field, string_view name,
86 string_view value, error_code& ec)
91 fields[std::string(name)] = std::string(value);
95 on_header_impl(error_code& ec)
104 boost::optional<std::uint64_t> const& content_length_,
109 static_cast<bool>(content_length_);
115 on_body_impl(string_view s,
118 body.append(s.data(), s.size());
125 on_chunk_header_impl(
141 body.append(s.data(), s.size());
149 on_finish_impl(error_code& ec)