include/boost/burl/response_parser.hpp
100.0% Lines (11/11)
100.0% List of functions (6/6)
-% Branches (0/0)
Functions (6)
Function
Calls
Lines
Blocks
boost::burl::response_parser::response_parser()
:35
3x
100.0%
100.0%
boost::burl::response_parser::response_parser(boost::burl::parser::config const&)
:43
124x
100.0%
100.0%
boost::burl::response_parser::response_parser(boost::burl::response_parser&&)
:49
334x
100.0%
100.0%
boost::burl::response_parser::operator=(boost::burl::response_parser&&)
:53
2x
100.0%
100.0%
boost::burl::response_parser::start(bool)
:75
136x
100.0%
100.0%
boost::burl::response_parser::get() const
:86
276x
100.0%
100.0%
| 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_RESPONSE_PARSER_HPP | ||
| 11 | #define BOOST_BURL_RESPONSE_PARSER_HPP | ||
| 12 | |||
| 13 | #include <boost/burl/parser.hpp> | ||
| 14 | #include <boost/burl/response_head_base.hpp> | ||
| 15 | |||
| 16 | namespace boost | ||
| 17 | { | ||
| 18 | namespace burl | ||
| 19 | { | ||
| 20 | |||
| 21 | /** A parser for HTTP/1 responses. | ||
| 22 | |||
| 23 | @see @ref parser, @ref message_reader. | ||
| 24 | */ | ||
| 25 | class response_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 | 3x | response_parser() = default; | |
| 36 | |||
| 37 | /** Constructor. | ||
| 38 | |||
| 39 | @param cfg The settings to apply for the | ||
| 40 | life of the parser. | ||
| 41 | */ | ||
| 42 | explicit | ||
| 43 | 124x | response_parser(config const& cfg) | |
| 44 | 124x | : parser(cfg, false) | |
| 45 | { | ||
| 46 | 124x | } | |
| 47 | |||
| 48 | /// Move constructor. | ||
| 49 | 334x | response_parser(response_parser&&) noexcept = default; | |
| 50 | |||
| 51 | /// Move assignment. | ||
| 52 | response_parser& | ||
| 53 | 2x | operator=(response_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 | @param head True if the response answers a | ||
| 71 | HEAD request, which states the size of a | ||
| 72 | representation without sending one. | ||
| 73 | */ | ||
| 74 | void | ||
| 75 | 136x | start(bool head = false) | |
| 76 | { | ||
| 77 | 136x | parser::start(head); | |
| 78 | 136x | } | |
| 79 | |||
| 80 | /** Return the parsed header. | ||
| 81 | |||
| 82 | The header is empty until @ref parse_header | ||
| 83 | succeeds. | ||
| 84 | */ | ||
| 85 | burl::response_head_base const& | ||
| 86 | 276x | get() const | |
| 87 | { | ||
| 88 | 276x | return get_response(); | |
| 89 | } | ||
| 90 | }; | ||
| 91 | |||
| 92 | } // namespace burl | ||
| 93 | } // namespace boost | ||
| 94 | |||
| 95 | #endif | ||
| 96 |