]> git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/include/beast/http/chunk_encode.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / include / beast / http / chunk_encode.hpp
1 //
2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7
8 #ifndef BEAST_HTTP_CHUNK_ENCODE_HPP
9 #define BEAST_HTTP_CHUNK_ENCODE_HPP
10
11 #include <beast/config.hpp>
12 #include <beast/core/buffer_cat.hpp>
13 #include <beast/http/detail/chunk_encode.hpp>
14 #include <boost/asio/buffer.hpp>
15 #include <boost/assert.hpp>
16 #include <algorithm>
17 #include <array>
18 #include <cstddef>
19 #include <iterator>
20 #include <type_traits>
21
22 namespace beast {
23 namespace http {
24
25 /** Returns a chunk-encoded ConstBufferSequence.
26
27 This returns a buffer sequence representing the
28 first chunk of a chunked transfer coded body.
29
30 @param fin `true` if this is the last chunk.
31
32 @param buffers The input buffer sequence.
33
34 @return A chunk-encoded ConstBufferSequence representing the input.
35
36 @see <a href=https://tools.ietf.org/html/rfc7230#section-4.1.3>rfc7230 section 4.1.3</a>
37 */
38 template<class ConstBufferSequence>
39 #if BEAST_DOXYGEN
40 implementation_defined
41 #else
42 beast::detail::buffer_cat_helper<
43 detail::chunk_encode_delim,
44 ConstBufferSequence,
45 boost::asio::const_buffers_1>
46 #endif
47 chunk_encode(bool fin, ConstBufferSequence const& buffers)
48 {
49 using boost::asio::buffer_size;
50 return buffer_cat(
51 detail::chunk_encode_delim{buffer_size(buffers)},
52 buffers,
53 fin ? boost::asio::const_buffers_1{"\r\n0\r\n\r\n", 7}
54 : boost::asio::const_buffers_1{"\r\n", 2});
55 }
56
57 /** Returns a chunked encoding final chunk.
58
59 @see <a href=https://tools.ietf.org/html/rfc7230#section-4.1.3>rfc7230 section 4.1.3</a>
60 */
61 inline
62 #if BEAST_DOXYGEN
63 implementation_defined
64 #else
65 boost::asio::const_buffers_1
66 #endif
67 chunk_encode_final()
68 {
69 return boost::asio::const_buffers_1{"0\r\n\r\n", 5};
70 }
71
72 } // http
73 } // beast
74
75 #endif