GCC Code Coverage Report


Directory: libs/http_proto/
File: src/detail/impl/filter.hpp
Date: 2025-06-04 09:40:31
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 0 0 -%
Branches: 0 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 60086 filter::
26 process_impl(
27 MutableBufferSequence const& out,
28 ConstBufferSequence const& in,
29 bool more) ->
30 results
31 {
32 60086 results rv;
33 60086 auto it_o = buffers::begin(out);
34 60086 auto it_i = buffers::begin(in);
35
36 120172 if( it_o == buffers::end(out) ||
37 60086 it_i == buffers::end(in) )
38 return rv;
39
40 60086 auto ob = *it_o++;
41 60086 auto ib = *it_i++;
42 59336 for(;;)
43 {
44 // empty buffers may be passed, and this is
45 // intentional and valid.
46 119422 results rs = process_impl(ob, ib, more);
47
48 119422 rv.out_bytes += rs.out_bytes;
49 119422 rv.in_bytes += rs.in_bytes;
50 119422 rv.ec = rs.ec;
51 119422 rv.finished = rs.finished;
52
53 119422 if( rv.finished || rv.ec )
54 60086 return rv;
55
56 119301 ob = buffers::sans_prefix(ob, rs.out_bytes);
57 119301 ib = buffers::sans_prefix(ib, rs.in_bytes);
58
59 119301 if( ob.size() == 0 )
60 {
61 6011 if( it_o == buffers::end(out) )
62 3472 return rv;
63 2539 ob = *it_o++;
64 }
65
66 115829 if( ib.size() == 0 )
67 {
68 113300 if( it_i == buffers::end(in) )
69 {
70 // if `more == false` we return only
71 // when `out` buffers are full.
72 56493 if( more )
73 56493 return rv;
74 }
75 else
76 {
77 56807 ib = *it_i++;
78 }
79 }
80 }
81 }
82
83 } // detail
84 } // http_proto
85 } // boost
86
87 #endif
88