Line data Source code
1 : //
2 : // Copyright (c) 2022 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/file_sink.hpp>
12 :
13 : namespace boost {
14 : namespace http_proto {
15 :
16 2 : file_sink::
17 2 : file_sink(file&& f) noexcept
18 2 : : f_(std::move(f))
19 : {
20 2 : }
21 :
22 0 : file_sink::
23 : file_sink(file_sink&&) noexcept = default;
24 :
25 2 : file_sink::
26 : ~file_sink() = default;
27 :
28 : auto
29 5 : file_sink::
30 : on_write(
31 : buffers::const_buffer b,
32 : bool more) -> results
33 : {
34 5 : results rv;
35 5 : rv.bytes = f_.write(
36 : b.data(), b.size(), rv.ec);
37 5 : if(!more && !rv.ec)
38 1 : f_.close(rv.ec);
39 5 : return rv;
40 : }
41 :
42 : } // http_proto
43 : } // boost
|