/src/boost/libs/beast/test/fuzz/http_response.cpp
Line | Count | Source |
1 | | // |
2 | | // Copyright (c) 2024 Mikhail Khachayants |
3 | | // |
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) |
6 | | // |
7 | | |
8 | | #include <boost/beast/http.hpp> |
9 | | #include <boost/beast/_experimental/test/stream.hpp> |
10 | | |
11 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
12 | 8.74k | { |
13 | 8.74k | using namespace boost::beast; |
14 | | |
15 | 8.74k | error_code ec; |
16 | 8.74k | flat_buffer buffer; |
17 | 8.74k | net::io_context ioc; |
18 | 8.74k | test::stream stream{ioc, {reinterpret_cast<const char*>(data), size}}; |
19 | 8.74k | stream.close_remote(); |
20 | | |
21 | 8.74k | http::chunk_extensions ce; |
22 | 8.74k | http::response_parser<http::dynamic_body> parser; |
23 | | |
24 | 8.74k | auto chunk_header_cb = [&ce](std::uint64_t, string_view extensions, error_code& ev) |
25 | 69.7k | { |
26 | 69.7k | ce.parse(extensions, ev); |
27 | 69.7k | }; |
28 | | |
29 | 8.74k | parser.on_chunk_header(chunk_header_cb); |
30 | 8.74k | http::read(stream, buffer, parser, ec); |
31 | | |
32 | 8.74k | return 0; |
33 | 8.74k | } |