GCC Code Coverage Report


Directory: libs/http_proto/
File: src/detail/impl/filter.hpp
Date: 2025-06-14 21:08:33
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 1 1 100.0%
Branches: 20 28 71.4%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2024 Mohammad Nejati
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // Official repository: https://github.com/cppalliance/http_proto
9 //
10
11 #ifndef BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
12 #define BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
13
14 #include <boost/buffers/range.hpp>
15 #include <boost/buffers/sans_prefix.hpp>
16
17 namespace boost {
18 namespace http_proto {
19 namespace detail {
20
21 template<
22 class MutableBufferSequence,
23 class ConstBufferSequence>
24 auto
25 72395 filter::
26 process_impl(
27 MutableBufferSequence const& out,
28 ConstBufferSequence const& in,
29 bool more) ->
30 results
31 {
32 72395 results rv;
33 72395 auto it_o = buffers::begin(out);
34 72395 auto it_i = buffers::begin(in);
35
36
3/6
✓ Branch 1 taken 52507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 52507 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52507 times.
144790 if( it_o == buffers::end(out) ||
37 72395 it_i == buffers::end(in) )
38 return rv;
39
40 72395 auto ob = *it_o++;
41 72395 auto ib = *it_i++;
42 65719 for(;;)
43 {
44 // empty input buffers may be passed, and
45 // this is intentional and valid.
46
1/2
✓ Branch 1 taken 99310 times.
✗ Branch 2 not taken.
138114 results rs = process_impl(ob, ib, more);
47
48 138114 rv.out_bytes += rs.out_bytes;
49 138114 rv.in_bytes += rs.in_bytes;
50 138114 rv.ec = rs.ec;
51 138114 rv.finished = rs.finished;
52
53
6/6
✓ Branch 0 taken 99182 times.
✓ Branch 1 taken 128 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 99180 times.
✓ Branch 5 taken 130 times.
✓ Branch 6 taken 99180 times.
138114 if( rv.finished || rv.ec )
54 72395 return rv;
55
56
1/2
✓ Branch 1 taken 99180 times.
✗ Branch 2 not taken.
137944 ob = buffers::sans_prefix(ob, rs.out_bytes);
57
1/2
✓ Branch 1 taken 99180 times.
✗ Branch 2 not taken.
137944 ib = buffers::sans_prefix(ib, rs.in_bytes);
58
59
2/2
✓ Branch 1 taken 12124 times.
✓ Branch 2 taken 93118 times.
144006 while( ob.size() == 0 )
60 {
61
2/2
✓ Branch 1 taken 6062 times.
✓ Branch 2 taken 6062 times.
13056 if( it_o == buffers::end(out) )
62 6994 return rv;
63 6062 ob = *it_o++;
64 }
65
66
1/2
✓ Branch 1 taken 93118 times.
✗ Branch 2 not taken.
130950 if( ib.size() == 0 )
67 {
68
2/2
✓ Branch 1 taken 46315 times.
✓ Branch 2 taken 46803 times.
130950 if( it_i == buffers::end(in) )
69 {
70 // if `more == false` we return only
71 // when `out` buffers are full.
72
1/2
✓ Branch 0 taken 46315 times.
✗ Branch 1 not taken.
65231 if( more )
73 65231 return rv;
74 }
75 else
76 {
77 65719 ib = *it_i++;
78 }
79 }
80 }
81 }
82
83 } // detail
84 } // http_proto
85 } // boost
86
87 #endif
88