| 268 | //-------------------------------------------------------------------------- |
| 269 | |
| 270 | void |
| 271 | doExplicitChunkSerialize() |
| 272 | { |
| 273 | auto const buf = |
| 274 | [](string_view s) |
| 275 | { |
| 276 | return net::const_buffer{ |
| 277 | s.data(), s.size()}; |
| 278 | }; |
| 279 | test::stream ts{ioc_}, tr{ioc_}; |
| 280 | ts.connect(tr); |
| 281 | |
| 282 | response<empty_body> res{status::ok, 11}; |
| 283 | res.set(field::server, "test"); |
| 284 | res.set(field::trailer, "Content-Digest"); |
| 285 | res.chunked(true); |
| 286 | |
| 287 | error_code ec; |
| 288 | response_serializer<empty_body> sr{res}; |
| 289 | write_header(ts, sr, ec); |
| 290 | |
| 291 | chunk_extensions exts; |
| 292 | |
| 293 | net::write(ts, |
| 294 | make_chunk(buf("First")), ec); |
| 295 | |
| 296 | exts.insert("quality", "1.0"); |
| 297 | net::write(ts, |
| 298 | make_chunk(buf("Hello, world!"), exts), ec); |
| 299 | |
| 300 | exts.clear(); |
| 301 | exts.insert("file", "abc.txt"); |
| 302 | exts.insert("quality", "0.7"); |
| 303 | net::write(ts, |
| 304 | make_chunk(buf("The Next Chunk"), std::move(exts)), ec); |
| 305 | |
| 306 | exts.clear(); |
| 307 | exts.insert("last"); |
| 308 | net::write(ts, |
| 309 | make_chunk(buf("Last one"), std::move(exts), |
| 310 | std::allocator<double>{}), ec); |
| 311 | |
| 312 | fields trailers; |
| 313 | trailers.set(field::content_digest, "f4a5c16584f03d90"); |
| 314 | |
| 315 | net::write(ts, |
| 316 | make_chunk_last( |
| 317 | trailers, |
| 318 | std::allocator<double>{} |
| 319 | ), ec); |
| 320 | BEAST_EXPECT( |
| 321 | buffers_to_string(tr.buffer().data()) == |
| 322 | "HTTP/1.1 200 OK\r\n" |
| 323 | "Server: test\r\n" |
| 324 | "Trailer: Content-Digest\r\n" |
| 325 | "Transfer-Encoding: chunked\r\n" |
| 326 | "\r\n" |
| 327 | "5\r\n" |
nothing calls this directly
no test coverage detected