| 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" |
nothing calls this directly
no test coverage detected