src/detail/can_reuse_conn.cpp

100.0% Lines (15/15) 100.0% List of functions (1/1) 100.0% Branches (11/11)
can_reuse_conn.cpp
f(x) Functions (1)
Line Branch 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 #include "can_reuse_conn.hpp"
11
12 namespace boost
13 {
14 namespace burl
15 {
16 namespace detail
17 {
18
19 bool
20 39x can_reuse_conn(http::response_parser& parser) noexcept
21 {
22
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 38 times.
39x if(!parser.got_header())
23 1x return false;
24
25
2/2
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 27 times.
38x if(!parser.get().keep_alive())
26 11x return false;
27
28
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21 times.
27x if(!parser.is_complete())
29 {
30 // The rest of the message may already sit in the
31 // parser's buffer; parsing it needs no I/O and makes
32 // the connection reusable.
33 try
34 {
35 6x system::error_code ec;
36
1/1
✓ Branch 1 taken 5 times.
6x parser.parse(ec);
37 }
38 1x catch(...)
39 {
40 1x }
41 }
42
43
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24 times.
27x if(!parser.is_complete())
44 3x return false;
45
46
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
24x if(parser.has_buffered_data())
47 4x return false;
48
49 20x return true;
50 }
51
52 } // namespace detail
53 } // namespace burl
54 } // namespace boost
55