GCC Code Coverage Report


Directory: libs/http_proto/
File: src/detail/impl/filter.hpp
Date: 2025-06-18 09:40:27
Exec Total Coverage
Lines: 30 31 96.8%
Functions: 0 0 -%
Branches: 2 4 50.0%

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 70593 filter::
26 process_impl(
27 MutableBufferSequence const& out,
28 ConstBufferSequence const& in,
29 bool more) ->
30 results
31 {
32 70593 results rv;
33
34 70593 auto it_o = buffers::begin(out);
35 70593 auto it_i = buffers::begin(in);
36
37 211779 auto ob = [&]() -> buffers::mutable_buffer
38 {
39
2/4
✓ Branch 1 taken 49338 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21255 times.
✗ Branch 5 not taken.
70593 if( it_o != buffers::end(out) )
40 70593 return *it_o++;
41 return {};
42 70593 }();
43
44 70593 buffers::const_buffer ib;
45
46 63990 for(;;)
47 {
48 268887 while( ib.size() == 0 )
49 {
50 197961 if( it_i == buffers::end(in) )
51 {
52 63657 if( more )
53 70593 return rv;
54
55 // if more == false we return only
56 // when output buffers are full.
57 129 break;
58 }
59 else
60 {
61 134304 ib = *it_i++;
62 }
63 }
64
65 // empty input buffers may be passed, and
66 // this is intentional and valid.
67 71055 results rs = process_impl(
68 ob,
69 ib,
70 71055 more || it_i != buffers::end(in));
71
72 71055 rv.out_bytes += rs.out_bytes;
73 71055 rv.in_bytes += rs.in_bytes;
74 71055 rv.ec = rs.ec;
75 71055 rv.finished = rs.finished;
76
77 71055 if( rv.finished || rv.ec )
78 194 return rv;
79
80 70861 ob = buffers::sans_prefix(ob, rs.out_bytes);
81 70861 ib = buffers::sans_prefix(ib, rs.in_bytes);
82
83 76801 while( ob.size() == 0 )
84 {
85 12811 if( it_o == buffers::end(out) )
86 6871 return rv;
87 5940 ob = *it_o++;
88 }
89 }
90 }
91
92 } // detail
93 } // http_proto
94 } // boost
95
96 #endif
97