Line data Source code
1 : //
2 : // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
3 : // Copyright (c) 2025 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 : #include <boost/http_proto/source.hpp>
12 :
13 : namespace boost {
14 : namespace http_proto {
15 :
16 : auto
17 992 : source::
18 : on_read(
19 : boost::span<buffers::mutable_buffer const> bs) ->
20 : results
21 : {
22 992 : results rv;
23 992 : auto it = bs.begin();
24 992 : auto const end_ = bs.end();
25 992 : if(it == end_)
26 1 : return rv;
27 : do
28 : {
29 1960 : buffers::mutable_buffer b(*it++);
30 1960 : auto rs = on_read(b);
31 1960 : rv += rs;
32 1960 : if(rs.ec.failed())
33 4 : return rv;
34 1956 : if(rs.finished)
35 23 : break;
36 : // source must fill the entire buffer
37 : // if it is not finished
38 1933 : if(b.size() != rs.bytes)
39 0 : detail::throw_logic_error();
40 : }
41 1933 : while(it != end_);
42 987 : return rv;
43 : }
44 :
45 : } // http_proto
46 : } // boost
|