forked from cppalliance/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.cpp
More file actions
46 lines (42 loc) · 1.02 KB
/
source.cpp
File metadata and controls
46 lines (42 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2025 Mohammad Nejati
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/http_proto
//
#include <boost/http_proto/source.hpp>
namespace boost {
namespace http_proto {
auto
source::
on_read(
boost::span<buffers::mutable_buffer const> bs) ->
results
{
results rv;
auto it = bs.begin();
auto const end_ = bs.end();
if(it == end_)
return rv;
do
{
buffers::mutable_buffer b(*it++);
auto rs = on_read(b);
rv += rs;
if(rs.ec.failed())
return rv;
if(rs.finished)
break;
// source must fill the entire buffer
// if it is not finished
if(b.size() != rs.bytes)
detail::throw_logic_error();
}
while(it != end_);
return rv;
}
} // http_proto
} // boost