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

Method testOutput

test/beast/http/write.cpp:508–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506 }
507
508 void
509 testOutput()
510 {
511 // auto content-length HTTP/1.0
512 {
513 request<string_body> m;
514 m.method(verb::get);
515 m.target("/");
516 m.version(10);
517 m.set(field::user_agent, "test");
518 m.body() = "*";
519 m.prepare_payload();
520 BEAST_EXPECT(str(m) ==
521 "GET / HTTP/1.0\r\n"
522 "User-Agent: test\r\n"
523 "Content-Length: 1\r\n"
524 "\r\n"
525 "*"
526 );
527 }
528 // no content-length HTTP/1.0
529 {
530 request<unsized_body> m;
531 m.method(verb::get);
532 m.target("/");
533 m.version(10);
534 m.set(field::user_agent, "test");
535 m.body() = "*";
536 m.prepare_payload();
537 test::stream ts{ioc_}, tr{ioc_};
538 ts.connect(tr);
539 error_code ec;
540 write(ts, m, ec);
541 BEAST_EXPECT(! m.keep_alive());
542 BEAST_EXPECTS(! ec, ec.message());
543 BEAST_EXPECT(tr.str() ==
544 "GET / HTTP/1.0\r\n"
545 "User-Agent: test\r\n"
546 "\r\n"
547 "*"
548 );
549 }
550 // auto content-length HTTP/1.1
551 {
552 request<string_body> m;
553 m.method(verb::get);
554 m.target("/");
555 m.version(11);
556 m.set(field::user_agent, "test");
557 m.body() = "*";
558 m.prepare_payload();
559 BEAST_EXPECT(str(m) ==
560 "GET / HTTP/1.1\r\n"
561 "User-Agent: test\r\n"
562 "Content-Length: 1\r\n"
563 "\r\n"
564 "*"
565 );

Callers

nothing calls this directly

Calls 8

methodMethod · 0.80
targetMethod · 0.80
bodyMethod · 0.80
messageMethod · 0.80
writeFunction · 0.50
versionMethod · 0.45
keep_aliveMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected