/work/stage/include/boost/beast/http/impl/serializer.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Copyright (c) 2016-2019 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 | | // Official repository: https://github.com/boostorg/beast |
8 | | // |
9 | | |
10 | | #ifndef BOOST_BEAST_HTTP_IMPL_SERIALIZER_HPP |
11 | | #define BOOST_BEAST_HTTP_IMPL_SERIALIZER_HPP |
12 | | |
13 | | #include <boost/beast/core/buffer_traits.hpp> |
14 | | #include <boost/beast/core/detail/buffers_ref.hpp> |
15 | | #include <boost/beast/http/error.hpp> |
16 | | #include <boost/beast/http/status.hpp> |
17 | | #include <boost/beast/core/detail/config.hpp> |
18 | | #include <boost/assert.hpp> |
19 | | #include <ostream> |
20 | | |
21 | | namespace boost { |
22 | | namespace beast { |
23 | | namespace http { |
24 | | |
25 | | template< |
26 | | bool isRequest, class Body, class Fields> |
27 | | void |
28 | | serializer<isRequest, Body, Fields>:: |
29 | | fwrinit(std::true_type) |
30 | | { |
31 | | fwr_.emplace(m_, m_.version(), m_.method()); |
32 | | } |
33 | | |
34 | | template< |
35 | | bool isRequest, class Body, class Fields> |
36 | | void |
37 | | serializer<isRequest, Body, Fields>:: |
38 | | fwrinit(std::false_type) |
39 | 4.47k | { |
40 | 4.47k | fwr_.emplace(m_, m_.version(), m_.result_int()); |
41 | 4.47k | } Unexecuted instantiation: boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::fwrinit(std::__1::integral_constant<bool, false>) boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::fwrinit(std::__1::integral_constant<bool, false>) Line | Count | Source | 39 | 4.47k | { | 40 | 4.47k | fwr_.emplace(m_, m_.version(), m_.result_int()); | 41 | 4.47k | } |
|
42 | | |
43 | | template< |
44 | | bool isRequest, class Body, class Fields> |
45 | | template<std::size_t I, class Visit> |
46 | | inline |
47 | | void |
48 | | serializer<isRequest, Body, Fields>:: |
49 | | do_visit(error_code& ec, Visit& visit) |
50 | 4.47k | { |
51 | 4.47k | pv_.template emplace<I>(limit_, v_.template get<I>()); |
52 | 4.47k | visit(ec, beast::detail::make_buffers_ref( |
53 | 4.47k | pv_.template get<I>())); |
54 | 4.47k | } Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<2ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<1ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<3ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<4ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<5ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<6ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<7ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<8ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<2ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Line | Count | Source | 50 | 4.47k | { | 51 | 4.47k | pv_.template emplace<I>(limit_, v_.template get<I>()); | 52 | 4.47k | visit(ec, beast::detail::make_buffers_ref( | 53 | 4.47k | pv_.template get<I>())); | 54 | 4.47k | } |
Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<1ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<3ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<4ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<5ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<6ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<7ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::do_visit<8ul, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> > >(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) |
55 | | |
56 | | //------------------------------------------------------------------------------ |
57 | | |
58 | | template< |
59 | | bool isRequest, class Body, class Fields> |
60 | | serializer<isRequest, Body, Fields>:: |
61 | | serializer(value_type& m) |
62 | 4.47k | : m_(m) |
63 | 4.47k | , wr_(m_.base(), m_.body()) |
64 | 4.47k | { |
65 | 4.47k | } Unexecuted instantiation: boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::serializer(boost::beast::http::message<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > > const&) boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::serializer(boost::beast::http::message<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > > const&) Line | Count | Source | 62 | 4.47k | : m_(m) | 63 | 4.47k | , wr_(m_.base(), m_.body()) | 64 | 4.47k | { | 65 | 4.47k | } |
|
66 | | |
67 | | template< |
68 | | bool isRequest, class Body, class Fields> |
69 | | template<class Visit> |
70 | | void |
71 | | serializer<isRequest, Body, Fields>:: |
72 | | next(error_code& ec, Visit&& visit) |
73 | 4.47k | { |
74 | 4.47k | switch(s_) |
75 | 4.47k | { |
76 | 4.47k | case do_construct: |
77 | 4.47k | { |
78 | 4.47k | fwrinit(std::integral_constant<bool, |
79 | 4.47k | isRequest>{}); |
80 | 4.47k | if(m_.chunked()) |
81 | 0 | goto go_init_c; |
82 | 4.47k | s_ = do_init; |
83 | 4.47k | BOOST_FALLTHROUGH; |
84 | 4.47k | } |
85 | | |
86 | 4.47k | case do_init: |
87 | 4.47k | { |
88 | 4.47k | wr_.init(ec); |
89 | 4.47k | if(ec) |
90 | 0 | return; |
91 | 4.47k | if(split_) |
92 | 0 | goto go_header_only; |
93 | 4.47k | auto result = wr_.get(ec); |
94 | 4.47k | if(ec == error::need_more) |
95 | 0 | goto go_header_only; |
96 | 4.47k | if(ec) |
97 | 0 | return; |
98 | 4.47k | if(! result) |
99 | 0 | goto go_header_only; |
100 | 4.47k | more_ = result->second; |
101 | 4.47k | v_.template emplace<2>( |
102 | 4.47k | boost::in_place_init, |
103 | 4.47k | fwr_->get(), |
104 | 4.47k | result->first); |
105 | 4.47k | s_ = do_header; |
106 | 4.47k | BOOST_FALLTHROUGH; |
107 | 4.47k | } |
108 | | |
109 | 4.47k | case do_header: |
110 | 4.47k | do_visit<2>(ec, visit); |
111 | 4.47k | break; |
112 | | |
113 | 0 | go_header_only: |
114 | 0 | v_.template emplace<1>(fwr_->get()); |
115 | 0 | s_ = do_header_only; |
116 | 0 | BOOST_FALLTHROUGH; |
117 | 0 | case do_header_only: |
118 | 0 | do_visit<1>(ec, visit); |
119 | 0 | break; |
120 | | |
121 | 0 | case do_body: |
122 | 0 | s_ = do_body + 1; |
123 | 0 | BOOST_FALLTHROUGH; |
124 | |
|
125 | 0 | case do_body + 1: |
126 | 0 | { |
127 | 0 | auto result = wr_.get(ec); |
128 | 0 | if(ec) |
129 | 0 | return; |
130 | 0 | if(! result) |
131 | 0 | goto go_complete; |
132 | 0 | more_ = result->second; |
133 | 0 | v_.template emplace<3>(result->first); |
134 | 0 | s_ = do_body + 2; |
135 | 0 | BOOST_FALLTHROUGH; |
136 | 0 | } |
137 | | |
138 | 0 | case do_body + 2: |
139 | 0 | do_visit<3>(ec, visit); |
140 | 0 | break; |
141 | | |
142 | | //---------------------------------------------------------------------- |
143 | | |
144 | 0 | go_init_c: |
145 | 0 | s_ = do_init_c; |
146 | 0 | BOOST_FALLTHROUGH; |
147 | 0 | case do_init_c: |
148 | 0 | { |
149 | 0 | wr_.init(ec); |
150 | 0 | if(ec) |
151 | 0 | return; |
152 | 0 | if(split_) |
153 | 0 | goto go_header_only_c; |
154 | 0 | auto result = wr_.get(ec); |
155 | 0 | if(ec == error::need_more) |
156 | 0 | goto go_header_only_c; |
157 | 0 | if(ec) |
158 | 0 | return; |
159 | 0 | if(! result) |
160 | 0 | goto go_header_only_c; |
161 | 0 | more_ = result->second; |
162 | 0 | if(! more_) |
163 | 0 | { |
164 | | // do it all in one buffer |
165 | 0 | v_.template emplace<7>( |
166 | 0 | boost::in_place_init, |
167 | 0 | fwr_->get(), |
168 | 0 | buffer_bytes(result->first), |
169 | 0 | net::const_buffer{nullptr, 0}, |
170 | 0 | chunk_crlf{}, |
171 | 0 | result->first, |
172 | 0 | chunk_crlf{}, |
173 | 0 | detail::chunk_last(), |
174 | 0 | net::const_buffer{nullptr, 0}, |
175 | 0 | chunk_crlf{}); |
176 | 0 | goto go_all_c; |
177 | 0 | } |
178 | 0 | v_.template emplace<4>( |
179 | 0 | boost::in_place_init, |
180 | 0 | fwr_->get(), |
181 | 0 | buffer_bytes(result->first), |
182 | 0 | net::const_buffer{nullptr, 0}, |
183 | 0 | chunk_crlf{}, |
184 | 0 | result->first, |
185 | 0 | chunk_crlf{}); |
186 | 0 | s_ = do_header_c; |
187 | 0 | BOOST_FALLTHROUGH; |
188 | 0 | } |
189 | | |
190 | 0 | case do_header_c: |
191 | 0 | do_visit<4>(ec, visit); |
192 | 0 | break; |
193 | | |
194 | 0 | go_header_only_c: |
195 | 0 | v_.template emplace<1>(fwr_->get()); |
196 | 0 | s_ = do_header_only_c; |
197 | 0 | BOOST_FALLTHROUGH; |
198 | |
|
199 | 0 | case do_header_only_c: |
200 | 0 | do_visit<1>(ec, visit); |
201 | 0 | break; |
202 | | |
203 | 0 | case do_body_c: |
204 | 0 | s_ = do_body_c + 1; |
205 | 0 | BOOST_FALLTHROUGH; |
206 | |
|
207 | 0 | case do_body_c + 1: |
208 | 0 | { |
209 | 0 | auto result = wr_.get(ec); |
210 | 0 | if(ec) |
211 | 0 | return; |
212 | 0 | if(! result) |
213 | 0 | goto go_final_c; |
214 | 0 | more_ = result->second; |
215 | 0 | if(! more_) |
216 | 0 | { |
217 | | // do it all in one buffer |
218 | 0 | v_.template emplace<6>( |
219 | 0 | boost::in_place_init, |
220 | 0 | buffer_bytes(result->first), |
221 | 0 | net::const_buffer{nullptr, 0}, |
222 | 0 | chunk_crlf{}, |
223 | 0 | result->first, |
224 | 0 | chunk_crlf{}, |
225 | 0 | detail::chunk_last(), |
226 | 0 | net::const_buffer{nullptr, 0}, |
227 | 0 | chunk_crlf{}); |
228 | 0 | goto go_body_final_c; |
229 | 0 | } |
230 | 0 | v_.template emplace<5>( |
231 | 0 | boost::in_place_init, |
232 | 0 | buffer_bytes(result->first), |
233 | 0 | net::const_buffer{nullptr, 0}, |
234 | 0 | chunk_crlf{}, |
235 | 0 | result->first, |
236 | 0 | chunk_crlf{}); |
237 | 0 | s_ = do_body_c + 2; |
238 | 0 | BOOST_FALLTHROUGH; |
239 | 0 | } |
240 | | |
241 | 0 | case do_body_c + 2: |
242 | 0 | do_visit<5>(ec, visit); |
243 | 0 | break; |
244 | | |
245 | 0 | go_body_final_c: |
246 | 0 | s_ = do_body_final_c; |
247 | 0 | BOOST_FALLTHROUGH; |
248 | 0 | case do_body_final_c: |
249 | 0 | do_visit<6>(ec, visit); |
250 | 0 | break; |
251 | | |
252 | 0 | go_all_c: |
253 | 0 | s_ = do_all_c; |
254 | 0 | BOOST_FALLTHROUGH; |
255 | 0 | case do_all_c: |
256 | 0 | do_visit<7>(ec, visit); |
257 | 0 | break; |
258 | | |
259 | 0 | go_final_c: |
260 | 0 | case do_final_c: |
261 | 0 | v_.template emplace<8>( |
262 | 0 | boost::in_place_init, |
263 | 0 | detail::chunk_last(), |
264 | 0 | net::const_buffer{nullptr, 0}, |
265 | 0 | chunk_crlf{}); |
266 | 0 | s_ = do_final_c + 1; |
267 | 0 | BOOST_FALLTHROUGH; |
268 | |
|
269 | 0 | case do_final_c + 1: |
270 | 0 | do_visit<8>(ec, visit); |
271 | 0 | break; |
272 | | |
273 | | //---------------------------------------------------------------------- |
274 | | |
275 | 0 | default: |
276 | 0 | case do_complete: |
277 | 0 | BOOST_ASSERT(false); |
278 | 0 | break; |
279 | | |
280 | 0 | go_complete: |
281 | 0 | s_ = do_complete; |
282 | 0 | break; |
283 | 4.47k | } |
284 | 4.47k | } Unexecuted instantiation: void boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::next<boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&>(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) void boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::next<boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&>(boost::system::error_code&, boost::beast::http::detail::write_some_lambda<boost::beast::test::basic_stream<boost::asio::any_io_executor> >&) Line | Count | Source | 73 | 4.47k | { | 74 | 4.47k | switch(s_) | 75 | 4.47k | { | 76 | 4.47k | case do_construct: | 77 | 4.47k | { | 78 | 4.47k | fwrinit(std::integral_constant<bool, | 79 | 4.47k | isRequest>{}); | 80 | 4.47k | if(m_.chunked()) | 81 | 0 | goto go_init_c; | 82 | 4.47k | s_ = do_init; | 83 | 4.47k | BOOST_FALLTHROUGH; | 84 | 4.47k | } | 85 | | | 86 | 4.47k | case do_init: | 87 | 4.47k | { | 88 | 4.47k | wr_.init(ec); | 89 | 4.47k | if(ec) | 90 | 0 | return; | 91 | 4.47k | if(split_) | 92 | 0 | goto go_header_only; | 93 | 4.47k | auto result = wr_.get(ec); | 94 | 4.47k | if(ec == error::need_more) | 95 | 0 | goto go_header_only; | 96 | 4.47k | if(ec) | 97 | 0 | return; | 98 | 4.47k | if(! result) | 99 | 0 | goto go_header_only; | 100 | 4.47k | more_ = result->second; | 101 | 4.47k | v_.template emplace<2>( | 102 | 4.47k | boost::in_place_init, | 103 | 4.47k | fwr_->get(), | 104 | 4.47k | result->first); | 105 | 4.47k | s_ = do_header; | 106 | 4.47k | BOOST_FALLTHROUGH; | 107 | 4.47k | } | 108 | | | 109 | 4.47k | case do_header: | 110 | 4.47k | do_visit<2>(ec, visit); | 111 | 4.47k | break; | 112 | | | 113 | 0 | go_header_only: | 114 | 0 | v_.template emplace<1>(fwr_->get()); | 115 | 0 | s_ = do_header_only; | 116 | 0 | BOOST_FALLTHROUGH; | 117 | 0 | case do_header_only: | 118 | 0 | do_visit<1>(ec, visit); | 119 | 0 | break; | 120 | | | 121 | 0 | case do_body: | 122 | 0 | s_ = do_body + 1; | 123 | 0 | BOOST_FALLTHROUGH; | 124 | |
| 125 | 0 | case do_body + 1: | 126 | 0 | { | 127 | 0 | auto result = wr_.get(ec); | 128 | 0 | if(ec) | 129 | 0 | return; | 130 | 0 | if(! result) | 131 | 0 | goto go_complete; | 132 | 0 | more_ = result->second; | 133 | 0 | v_.template emplace<3>(result->first); | 134 | 0 | s_ = do_body + 2; | 135 | 0 | BOOST_FALLTHROUGH; | 136 | 0 | } | 137 | | | 138 | 0 | case do_body + 2: | 139 | 0 | do_visit<3>(ec, visit); | 140 | 0 | break; | 141 | | | 142 | | //---------------------------------------------------------------------- | 143 | | | 144 | 0 | go_init_c: | 145 | 0 | s_ = do_init_c; | 146 | 0 | BOOST_FALLTHROUGH; | 147 | 0 | case do_init_c: | 148 | 0 | { | 149 | 0 | wr_.init(ec); | 150 | 0 | if(ec) | 151 | 0 | return; | 152 | 0 | if(split_) | 153 | 0 | goto go_header_only_c; | 154 | 0 | auto result = wr_.get(ec); | 155 | 0 | if(ec == error::need_more) | 156 | 0 | goto go_header_only_c; | 157 | 0 | if(ec) | 158 | 0 | return; | 159 | 0 | if(! result) | 160 | 0 | goto go_header_only_c; | 161 | 0 | more_ = result->second; | 162 | 0 | if(! more_) | 163 | 0 | { | 164 | | // do it all in one buffer | 165 | 0 | v_.template emplace<7>( | 166 | 0 | boost::in_place_init, | 167 | 0 | fwr_->get(), | 168 | 0 | buffer_bytes(result->first), | 169 | 0 | net::const_buffer{nullptr, 0}, | 170 | 0 | chunk_crlf{}, | 171 | 0 | result->first, | 172 | 0 | chunk_crlf{}, | 173 | 0 | detail::chunk_last(), | 174 | 0 | net::const_buffer{nullptr, 0}, | 175 | 0 | chunk_crlf{}); | 176 | 0 | goto go_all_c; | 177 | 0 | } | 178 | 0 | v_.template emplace<4>( | 179 | 0 | boost::in_place_init, | 180 | 0 | fwr_->get(), | 181 | 0 | buffer_bytes(result->first), | 182 | 0 | net::const_buffer{nullptr, 0}, | 183 | 0 | chunk_crlf{}, | 184 | 0 | result->first, | 185 | 0 | chunk_crlf{}); | 186 | 0 | s_ = do_header_c; | 187 | 0 | BOOST_FALLTHROUGH; | 188 | 0 | } | 189 | | | 190 | 0 | case do_header_c: | 191 | 0 | do_visit<4>(ec, visit); | 192 | 0 | break; | 193 | | | 194 | 0 | go_header_only_c: | 195 | 0 | v_.template emplace<1>(fwr_->get()); | 196 | 0 | s_ = do_header_only_c; | 197 | 0 | BOOST_FALLTHROUGH; | 198 | |
| 199 | 0 | case do_header_only_c: | 200 | 0 | do_visit<1>(ec, visit); | 201 | 0 | break; | 202 | | | 203 | 0 | case do_body_c: | 204 | 0 | s_ = do_body_c + 1; | 205 | 0 | BOOST_FALLTHROUGH; | 206 | |
| 207 | 0 | case do_body_c + 1: | 208 | 0 | { | 209 | 0 | auto result = wr_.get(ec); | 210 | 0 | if(ec) | 211 | 0 | return; | 212 | 0 | if(! result) | 213 | 0 | goto go_final_c; | 214 | 0 | more_ = result->second; | 215 | 0 | if(! more_) | 216 | 0 | { | 217 | | // do it all in one buffer | 218 | 0 | v_.template emplace<6>( | 219 | 0 | boost::in_place_init, | 220 | 0 | buffer_bytes(result->first), | 221 | 0 | net::const_buffer{nullptr, 0}, | 222 | 0 | chunk_crlf{}, | 223 | 0 | result->first, | 224 | 0 | chunk_crlf{}, | 225 | 0 | detail::chunk_last(), | 226 | 0 | net::const_buffer{nullptr, 0}, | 227 | 0 | chunk_crlf{}); | 228 | 0 | goto go_body_final_c; | 229 | 0 | } | 230 | 0 | v_.template emplace<5>( | 231 | 0 | boost::in_place_init, | 232 | 0 | buffer_bytes(result->first), | 233 | 0 | net::const_buffer{nullptr, 0}, | 234 | 0 | chunk_crlf{}, | 235 | 0 | result->first, | 236 | 0 | chunk_crlf{}); | 237 | 0 | s_ = do_body_c + 2; | 238 | 0 | BOOST_FALLTHROUGH; | 239 | 0 | } | 240 | | | 241 | 0 | case do_body_c + 2: | 242 | 0 | do_visit<5>(ec, visit); | 243 | 0 | break; | 244 | | | 245 | 0 | go_body_final_c: | 246 | 0 | s_ = do_body_final_c; | 247 | 0 | BOOST_FALLTHROUGH; | 248 | 0 | case do_body_final_c: | 249 | 0 | do_visit<6>(ec, visit); | 250 | 0 | break; | 251 | | | 252 | 0 | go_all_c: | 253 | 0 | s_ = do_all_c; | 254 | 0 | BOOST_FALLTHROUGH; | 255 | 0 | case do_all_c: | 256 | 0 | do_visit<7>(ec, visit); | 257 | 0 | break; | 258 | | | 259 | 0 | go_final_c: | 260 | 0 | case do_final_c: | 261 | 0 | v_.template emplace<8>( | 262 | 0 | boost::in_place_init, | 263 | 0 | detail::chunk_last(), | 264 | 0 | net::const_buffer{nullptr, 0}, | 265 | 0 | chunk_crlf{}); | 266 | 0 | s_ = do_final_c + 1; | 267 | 0 | BOOST_FALLTHROUGH; | 268 | |
| 269 | 0 | case do_final_c + 1: | 270 | 0 | do_visit<8>(ec, visit); | 271 | 0 | break; | 272 | | | 273 | | //---------------------------------------------------------------------- | 274 | | | 275 | 0 | default: | 276 | 0 | case do_complete: | 277 | 0 | BOOST_ASSERT(false); | 278 | 0 | break; | 279 | | | 280 | 0 | go_complete: | 281 | 0 | s_ = do_complete; | 282 | 0 | break; | 283 | 4.47k | } | 284 | 4.47k | } |
|
285 | | |
286 | | template< |
287 | | bool isRequest, class Body, class Fields> |
288 | | void |
289 | | serializer<isRequest, Body, Fields>:: |
290 | | consume(std::size_t n) |
291 | 4.47k | { |
292 | 4.47k | switch(s_) |
293 | 4.47k | { |
294 | 4.47k | case do_header: |
295 | 4.47k | BOOST_ASSERT( |
296 | 4.47k | n <= buffer_bytes(v_.template get<2>())); |
297 | 4.47k | v_.template get<2>().consume(n); |
298 | 4.47k | if(buffer_bytes(v_.template get<2>()) > 0) |
299 | 0 | break; |
300 | 4.47k | header_done_ = true; |
301 | 4.47k | v_.reset(); |
302 | 4.47k | if(! more_) |
303 | 4.47k | goto go_complete; |
304 | 0 | s_ = do_body + 1; |
305 | 0 | break; |
306 | | |
307 | 0 | case do_header_only: |
308 | 0 | BOOST_ASSERT( |
309 | 0 | n <= buffer_bytes(v_.template get<1>())); |
310 | 0 | v_.template get<1>().consume(n); |
311 | 0 | if(buffer_bytes(v_.template get<1>()) > 0) |
312 | 0 | break; |
313 | 0 | fwr_ = boost::none; |
314 | 0 | header_done_ = true; |
315 | 0 | if(! split_) |
316 | 0 | goto go_complete; |
317 | 0 | s_ = do_body; |
318 | 0 | break; |
319 | | |
320 | 0 | case do_body + 2: |
321 | 0 | { |
322 | 0 | BOOST_ASSERT( |
323 | 0 | n <= buffer_bytes(v_.template get<3>())); |
324 | 0 | v_.template get<3>().consume(n); |
325 | 0 | if(buffer_bytes(v_.template get<3>()) > 0) |
326 | 0 | break; |
327 | 0 | v_.reset(); |
328 | 0 | if(! more_) |
329 | 0 | goto go_complete; |
330 | 0 | s_ = do_body + 1; |
331 | 0 | break; |
332 | 0 | } |
333 | | |
334 | | //---------------------------------------------------------------------- |
335 | | |
336 | 0 | case do_header_c: |
337 | 0 | BOOST_ASSERT( |
338 | 0 | n <= buffer_bytes(v_.template get<4>())); |
339 | 0 | v_.template get<4>().consume(n); |
340 | 0 | if(buffer_bytes(v_.template get<4>()) > 0) |
341 | 0 | break; |
342 | 0 | header_done_ = true; |
343 | 0 | v_.reset(); |
344 | 0 | if(more_) |
345 | 0 | s_ = do_body_c + 1; |
346 | 0 | else |
347 | 0 | s_ = do_final_c; |
348 | 0 | break; |
349 | | |
350 | 0 | case do_header_only_c: |
351 | 0 | { |
352 | 0 | BOOST_ASSERT( |
353 | 0 | n <= buffer_bytes(v_.template get<1>())); |
354 | 0 | v_.template get<1>().consume(n); |
355 | 0 | if(buffer_bytes(v_.template get<1>()) > 0) |
356 | 0 | break; |
357 | 0 | fwr_ = boost::none; |
358 | 0 | header_done_ = true; |
359 | 0 | if(! split_) |
360 | 0 | { |
361 | 0 | s_ = do_final_c; |
362 | 0 | break; |
363 | 0 | } |
364 | 0 | s_ = do_body_c; |
365 | 0 | break; |
366 | 0 | } |
367 | | |
368 | 0 | case do_body_c + 2: |
369 | 0 | BOOST_ASSERT( |
370 | 0 | n <= buffer_bytes(v_.template get<5>())); |
371 | 0 | v_.template get<5>().consume(n); |
372 | 0 | if(buffer_bytes(v_.template get<5>()) > 0) |
373 | 0 | break; |
374 | 0 | v_.reset(); |
375 | 0 | if(more_) |
376 | 0 | s_ = do_body_c + 1; |
377 | 0 | else |
378 | 0 | s_ = do_final_c; |
379 | 0 | break; |
380 | | |
381 | 0 | case do_body_final_c: |
382 | 0 | { |
383 | 0 | BOOST_ASSERT( |
384 | 0 | n <= buffer_bytes(v_.template get<6>())); |
385 | 0 | v_.template get<6>().consume(n); |
386 | 0 | if(buffer_bytes(v_.template get<6>()) > 0) |
387 | 0 | break; |
388 | 0 | v_.reset(); |
389 | 0 | s_ = do_complete; |
390 | 0 | break; |
391 | 0 | } |
392 | | |
393 | 0 | case do_all_c: |
394 | 0 | { |
395 | 0 | BOOST_ASSERT( |
396 | 0 | n <= buffer_bytes(v_.template get<7>())); |
397 | 0 | v_.template get<7>().consume(n); |
398 | 0 | if(buffer_bytes(v_.template get<7>()) > 0) |
399 | 0 | break; |
400 | 0 | header_done_ = true; |
401 | 0 | v_.reset(); |
402 | 0 | s_ = do_complete; |
403 | 0 | break; |
404 | 0 | } |
405 | | |
406 | 0 | case do_final_c + 1: |
407 | 0 | BOOST_ASSERT(buffer_bytes(v_.template get<8>())); |
408 | 0 | v_.template get<8>().consume(n); |
409 | 0 | if(buffer_bytes(v_.template get<8>()) > 0) |
410 | 0 | break; |
411 | 0 | v_.reset(); |
412 | 0 | goto go_complete; |
413 | | |
414 | | //---------------------------------------------------------------------- |
415 | | |
416 | 0 | default: |
417 | 0 | BOOST_ASSERT(false); |
418 | 0 | case do_complete: |
419 | 0 | break; |
420 | | |
421 | 4.47k | go_complete: |
422 | 4.47k | s_ = do_complete; |
423 | 4.47k | break; |
424 | 4.47k | } |
425 | 4.47k | } Unexecuted instantiation: boost::beast::http::serializer<false, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::__1::allocator<char> > >::consume(unsigned long) boost::beast::http::serializer<false, boost::beast::http::basic_string_body<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::beast::http::basic_fields<std::__1::allocator<char> > >::consume(unsigned long) Line | Count | Source | 291 | 4.47k | { | 292 | 4.47k | switch(s_) | 293 | 4.47k | { | 294 | 4.47k | case do_header: | 295 | 4.47k | BOOST_ASSERT( | 296 | 4.47k | n <= buffer_bytes(v_.template get<2>())); | 297 | 4.47k | v_.template get<2>().consume(n); | 298 | 4.47k | if(buffer_bytes(v_.template get<2>()) > 0) | 299 | 0 | break; | 300 | 4.47k | header_done_ = true; | 301 | 4.47k | v_.reset(); | 302 | 4.47k | if(! more_) | 303 | 4.47k | goto go_complete; | 304 | 0 | s_ = do_body + 1; | 305 | 0 | break; | 306 | | | 307 | 0 | case do_header_only: | 308 | 0 | BOOST_ASSERT( | 309 | 0 | n <= buffer_bytes(v_.template get<1>())); | 310 | 0 | v_.template get<1>().consume(n); | 311 | 0 | if(buffer_bytes(v_.template get<1>()) > 0) | 312 | 0 | break; | 313 | 0 | fwr_ = boost::none; | 314 | 0 | header_done_ = true; | 315 | 0 | if(! split_) | 316 | 0 | goto go_complete; | 317 | 0 | s_ = do_body; | 318 | 0 | break; | 319 | | | 320 | 0 | case do_body + 2: | 321 | 0 | { | 322 | 0 | BOOST_ASSERT( | 323 | 0 | n <= buffer_bytes(v_.template get<3>())); | 324 | 0 | v_.template get<3>().consume(n); | 325 | 0 | if(buffer_bytes(v_.template get<3>()) > 0) | 326 | 0 | break; | 327 | 0 | v_.reset(); | 328 | 0 | if(! more_) | 329 | 0 | goto go_complete; | 330 | 0 | s_ = do_body + 1; | 331 | 0 | break; | 332 | 0 | } | 333 | | | 334 | | //---------------------------------------------------------------------- | 335 | | | 336 | 0 | case do_header_c: | 337 | 0 | BOOST_ASSERT( | 338 | 0 | n <= buffer_bytes(v_.template get<4>())); | 339 | 0 | v_.template get<4>().consume(n); | 340 | 0 | if(buffer_bytes(v_.template get<4>()) > 0) | 341 | 0 | break; | 342 | 0 | header_done_ = true; | 343 | 0 | v_.reset(); | 344 | 0 | if(more_) | 345 | 0 | s_ = do_body_c + 1; | 346 | 0 | else | 347 | 0 | s_ = do_final_c; | 348 | 0 | break; | 349 | | | 350 | 0 | case do_header_only_c: | 351 | 0 | { | 352 | 0 | BOOST_ASSERT( | 353 | 0 | n <= buffer_bytes(v_.template get<1>())); | 354 | 0 | v_.template get<1>().consume(n); | 355 | 0 | if(buffer_bytes(v_.template get<1>()) > 0) | 356 | 0 | break; | 357 | 0 | fwr_ = boost::none; | 358 | 0 | header_done_ = true; | 359 | 0 | if(! split_) | 360 | 0 | { | 361 | 0 | s_ = do_final_c; | 362 | 0 | break; | 363 | 0 | } | 364 | 0 | s_ = do_body_c; | 365 | 0 | break; | 366 | 0 | } | 367 | | | 368 | 0 | case do_body_c + 2: | 369 | 0 | BOOST_ASSERT( | 370 | 0 | n <= buffer_bytes(v_.template get<5>())); | 371 | 0 | v_.template get<5>().consume(n); | 372 | 0 | if(buffer_bytes(v_.template get<5>()) > 0) | 373 | 0 | break; | 374 | 0 | v_.reset(); | 375 | 0 | if(more_) | 376 | 0 | s_ = do_body_c + 1; | 377 | 0 | else | 378 | 0 | s_ = do_final_c; | 379 | 0 | break; | 380 | | | 381 | 0 | case do_body_final_c: | 382 | 0 | { | 383 | 0 | BOOST_ASSERT( | 384 | 0 | n <= buffer_bytes(v_.template get<6>())); | 385 | 0 | v_.template get<6>().consume(n); | 386 | 0 | if(buffer_bytes(v_.template get<6>()) > 0) | 387 | 0 | break; | 388 | 0 | v_.reset(); | 389 | 0 | s_ = do_complete; | 390 | 0 | break; | 391 | 0 | } | 392 | | | 393 | 0 | case do_all_c: | 394 | 0 | { | 395 | 0 | BOOST_ASSERT( | 396 | 0 | n <= buffer_bytes(v_.template get<7>())); | 397 | 0 | v_.template get<7>().consume(n); | 398 | 0 | if(buffer_bytes(v_.template get<7>()) > 0) | 399 | 0 | break; | 400 | 0 | header_done_ = true; | 401 | 0 | v_.reset(); | 402 | 0 | s_ = do_complete; | 403 | 0 | break; | 404 | 0 | } | 405 | | | 406 | 0 | case do_final_c + 1: | 407 | 0 | BOOST_ASSERT(buffer_bytes(v_.template get<8>())); | 408 | 0 | v_.template get<8>().consume(n); | 409 | 0 | if(buffer_bytes(v_.template get<8>()) > 0) | 410 | 0 | break; | 411 | 0 | v_.reset(); | 412 | 0 | goto go_complete; | 413 | | | 414 | | //---------------------------------------------------------------------- | 415 | | | 416 | 0 | default: | 417 | 0 | BOOST_ASSERT(false); | 418 | 0 | case do_complete: | 419 | 0 | break; | 420 | | | 421 | 4.47k | go_complete: | 422 | 4.47k | s_ = do_complete; | 423 | 4.47k | break; | 424 | 4.47k | } | 425 | 4.47k | } |
|
426 | | |
427 | | } // http |
428 | | } // beast |
429 | | } // boost |
430 | | |
431 | | #endif |