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