MCPcopy Create free account
hub / github.com/boostorg/beast / testAsyncWrite

Method testAsyncWrite

test/beast/http/write.cpp:309–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307 }
308
309 void
310 testAsyncWrite(yield_context do_yield)
311 {
312 {
313 response<string_body> m;
314 m.version(10);
315 m.result(status::ok);
316 m.set(field::server, "test");
317 m.set(field::content_length, "5");
318 m.body() = "*****";
319 error_code ec;
320 test::stream ts{ioc_}, tr{ioc_};
321 ts.connect(tr);
322 async_write(ts, m, do_yield[ec]);
323 BEAST_EXPECT(! m.keep_alive());
324 if(BEAST_EXPECTS(! ec, ec.message()))
325 BEAST_EXPECT(tr.str() ==
326 "HTTP/1.0 200 OK\r\n"
327 "Server: test\r\n"
328 "Content-Length: 5\r\n"
329 "\r\n"
330 "*****");
331 }
332 {
333 response<string_body> m;
334 m.version(11);
335 m.result(status::ok);
336 m.set(field::server, "test");
337 m.set(field::transfer_encoding, "chunked");
338 m.body() = "*****";
339 error_code ec;
340 test::stream ts{ioc_}, tr{ioc_};
341 ts.connect(tr);
342 async_write(ts, m, do_yield[ec]);
343 if(BEAST_EXPECTS(! ec, ec.message()))
344 BEAST_EXPECT(tr.str() ==
345 "HTTP/1.1 200 OK\r\n"
346 "Server: test\r\n"
347 "Transfer-Encoding: chunked\r\n"
348 "\r\n"
349 "5\r\n"
350 "*****\r\n"
351 "0\r\n\r\n");
352 }
353 }
354
355 void
356 testFailures(yield_context do_yield)

Callers

nothing calls this directly

Calls 6

bodyMethod · 0.80
messageMethod · 0.80
async_writeFunction · 0.50
versionMethod · 0.45
keep_aliveMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected