include/boost/burl/request_parser.hpp

100.0% Lines (8/8) 100.0% List of functions (3/3) -% Branches (0/0)
request_parser.hpp
f(x) Functions (3)
Line TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Mohammad Nejati
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 // Official repository: https://github.com/cppalliance/burl
8 //
9
10 #ifndef BOOST_BURL_REQUEST_PARSER_HPP
11 #define BOOST_BURL_REQUEST_PARSER_HPP
12
13 #include <boost/burl/parser.hpp>
14 #include <boost/burl/request_head_base.hpp>
15
16 namespace boost
17 {
18 namespace burl
19 {
20
21 /** A parser for HTTP/1 requests.
22
23 @see @ref parser, @ref message_reader.
24 */
25 class request_parser
26 : public parser
27 {
28 public:
29 /** Constructor.
30
31 A default-constructed parser behaves as if
32 constructed with a zero-size buffer, and is
33 intended only as a target for assignment.
34 */
35 request_parser() = default;
36
37 /** Constructor.
38
39 @param cfg The settings to apply for the
40 life of the parser.
41 */
42 explicit
43 1x request_parser(config const& cfg)
44 1x : parser(cfg, true)
45 {
46 1x }
47
48 /// Move constructor.
49 request_parser(request_parser&&) noexcept = default;
50
51 /// Move assignment.
52 request_parser&
53 operator=(request_parser&&) noexcept = default;
54
55 /** Prepare for a new message.
56
57 Any octets already received which belong to
58 the new message are retained.
59
60 This does not drain: octets of a previous
61 body which have not been received are not
62 skipped. Reaching @ref got_body is the
63 caller's responsibility.
64
65 @par Preconditions
66 Either this is the first message in the
67 stream, or the previous message has arrived
68 in full.
69 */
70 void
71 1x start()
72 {
73 1x parser::start(false);
74 1x }
75
76 /** Return the parsed header.
77
78 The header is empty until @ref parse_header
79 succeeds.
80 */
81 burl::request_head_base const&
82 2x get() const
83 {
84 2x return get_request();
85 }
86 };
87
88 } // namespace burl
89 } // namespace boost
90
91 #endif
92