| 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 | 72399 | filter:: | |
| 26 | process_impl( | ||
| 27 | MutableBufferSequence const& out, | ||
| 28 | ConstBufferSequence const& in, | ||
| 29 | bool more) -> | ||
| 30 | results | ||
| 31 | { | ||
| 32 | 72399 | results rv; | |
| 33 | 72399 | auto it_o = buffers::begin(out); | |
| 34 | 72399 | auto it_i = buffers::begin(in); | |
| 35 | |||
| 36 |
3/6✓ Branch 1 taken 52510 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 52510 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52510 times.
|
144798 | if( it_o == buffers::end(out) || |
| 37 | 72399 | it_i == buffers::end(in) ) | |
| 38 | ✗ | return rv; | |
| 39 | |||
| 40 | 72399 | auto ob = *it_o++; | |
| 41 | 72399 | auto ib = *it_i++; | |
| 42 | 65729 | for(;;) | |
| 43 | { | ||
| 44 | // empty input buffers may be passed, and | ||
| 45 | // this is intentional and valid. | ||
| 46 |
1/2✓ Branch 1 taken 99325 times.
✗ Branch 2 not taken.
|
138128 | results rs = process_impl(ob, ib, more); |
| 47 | |||
| 48 | 138128 | rv.out_bytes += rs.out_bytes; | |
| 49 | 138128 | rv.in_bytes += rs.in_bytes; | |
| 50 | 138128 | rv.ec = rs.ec; | |
| 51 | 138128 | rv.finished = rs.finished; | |
| 52 | |||
| 53 |
6/6✓ Branch 0 taken 99197 times.
✓ Branch 1 taken 128 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 99195 times.
✓ Branch 5 taken 130 times.
✓ Branch 6 taken 99195 times.
|
138128 | if( rv.finished || rv.ec ) |
| 54 | 72399 | return rv; | |
| 55 | |||
| 56 |
1/2✓ Branch 1 taken 99195 times.
✗ Branch 2 not taken.
|
137958 | ob = buffers::sans_prefix(ob, rs.out_bytes); |
| 57 |
1/2✓ Branch 1 taken 99195 times.
✗ Branch 2 not taken.
|
137958 | ib = buffers::sans_prefix(ib, rs.in_bytes); |
| 58 | |||
| 59 |
2/2✓ Branch 1 taken 12110 times.
✓ Branch 2 taken 93140 times.
|
144013 | while( ob.size() == 0 ) |
| 60 | { | ||
| 61 |
2/2✓ Branch 1 taken 6055 times.
✓ Branch 2 taken 6055 times.
|
13045 | if( it_o == buffers::end(out) ) |
| 62 | 6990 | return rv; | |
| 63 | 6055 | ob = *it_o++; | |
| 64 | } | ||
| 65 | |||
| 66 |
1/2✓ Branch 1 taken 93140 times.
✗ Branch 2 not taken.
|
130968 | if( ib.size() == 0 ) |
| 67 | { | ||
| 68 |
2/2✓ Branch 1 taken 46325 times.
✓ Branch 2 taken 46815 times.
|
130968 | 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 46325 times.
✗ Branch 1 not taken.
|
65239 | if( more ) |
| 73 | 65239 | return rv; | |
| 74 | } | ||
| 75 | else | ||
| 76 | { | ||
| 77 | 65729 | ib = *it_i++; | |
| 78 | } | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | } // detail | ||
| 84 | } // http_proto | ||
| 85 | } // boost | ||
| 86 | |||
| 87 | #endif | ||
| 88 |