MCPcopy Create free account
hub / github.com/catboost/catboost / DoTestHttpOutputSize

Function DoTestHttpOutputSize

library/cpp/http/io/stream_ut.cpp:689–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687 }
688
689 size_t DoTestHttpOutputSize(const TString& res, bool enableCompession) {
690 TTestHttpServer serverImpl(res);
691 TPortManager pm;
692
693 const ui16 port = pm.GetPort();
694 THttpServer server(&serverImpl,
695 THttpServer::TOptions(port)
696 .EnableKeepAlive(true)
697 .EnableCompression(enableCompession));
698 UNIT_ASSERT(server.Start());
699
700 TNetworkAddress addr("localhost", port);
701 TSocket s(addr);
702
703 {
704 TSocketOutput so(s);
705 THttpOutput out(&so);
706 out << "GET / HTTP/1.1\r\n"
707 "Host: www.yandex.ru\r\n"
708 "Connection: Keep-Alive\r\n"
709 "Accept-Encoding: gzip\r\n"
710 "\r\n";
711 out.Finish();
712 }
713
714 TSocketInput si(s);
715 THttpInput input(&si);
716
717 unsigned httpCode = ParseHttpRetCode(input.FirstLine());
718 UNIT_ASSERT_VALUES_EQUAL(httpCode, 200u);
719
720 UNIT_ASSERT_VALUES_EQUAL(res, input.ReadAll());
721
722 server.Stop();
723
724 return serverImpl.LastRequestSentSize();
725 }
726
727 Y_UNIT_TEST(TestHttpOutputSize) {
728 TString res = "qqqqqq";

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 10

ParseHttpRetCodeFunction · 0.85
ReadAllMethod · 0.80
LastRequestSentSizeMethod · 0.80
TOptionsClass · 0.50
GetPortMethod · 0.45
EnableCompressionMethod · 0.45
EnableKeepAliveMethod · 0.45
StartMethod · 0.45
FinishMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected