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

Method testFailures

test/beast/http/write.cpp:355–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353 }
354
355 void
356 testFailures(yield_context do_yield)
357 {
358 static std::size_t constexpr limit = 100;
359 std::size_t n;
360
361 for(n = 0; n < limit; ++n)
362 {
363 test::fail_count fc(n);
364 test::stream ts{ioc_, fc}, tr{ioc_};
365 ts.connect(tr);
366 request<fail_body> m(verb::get, "/", 10, fc);
367 m.set(field::user_agent, "test");
368 m.set(field::connection, "keep-alive");
369 m.set(field::content_length, "5");
370 m.body() = "*****";
371 try
372 {
373 write(ts, m);
374 BEAST_EXPECT(tr.str() ==
375 "GET / HTTP/1.0\r\n"
376 "User-Agent: test\r\n"
377 "Connection: keep-alive\r\n"
378 "Content-Length: 5\r\n"
379 "\r\n"
380 "*****"
381 );
382 pass();
383 break;
384 }
385 catch(std::exception const&)
386 {
387 }
388 }
389 BEAST_EXPECT(n < limit);
390
391 for(n = 0; n < limit; ++n)
392 {
393 test::fail_count fc(n);
394 test::stream ts{ioc_, fc}, tr{ioc_};
395 ts.connect(tr);
396 request<fail_body> m{verb::get, "/", 10, fc};
397 m.set(field::user_agent, "test");
398 m.set(field::transfer_encoding, "chunked");
399 m.body() = "*****";
400 error_code ec = test::error::test_failure;
401 write(ts, m, ec);
402 if(! ec)
403 {
404 BEAST_EXPECT(! m.keep_alive());
405 BEAST_EXPECT(tr.str() ==
406 "GET / HTTP/1.0\r\n"
407 "User-Agent: test\r\n"
408 "Transfer-Encoding: chunked\r\n"
409 "\r\n"
410 "1\r\n*\r\n"
411 "1\r\n*\r\n"
412 "1\r\n*\r\n"

Callers

nothing calls this directly

Calls 5

bodyMethod · 0.80
writeFunction · 0.50
async_writeFunction · 0.50
strMethod · 0.45
keep_aliveMethod · 0.45

Tested by

no test coverage detected