aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/server
diff options
context:
space:
mode:
authorAlexey Salmin <alexey.salmin@gmail.com>2022-02-10 16:49:37 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:37 +0300
commit71af077a5dfe7e9f932a508422c2dac81a57ebc0 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/http/server
parent3c5b1607b38f637d2f3313791ed25c2e080d2647 (diff)
downloadydb-71af077a5dfe7e9f932a508422c2dac81a57ebc0.tar.gz
Restoring authorship annotation for Alexey Salmin <alexey.salmin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/server')
-rw-r--r--library/cpp/http/server/http_ut.cpp104
-rw-r--r--library/cpp/http/server/options.h12
2 files changed, 58 insertions, 58 deletions
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index dae9a2f36d..cc62bb988e 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -4,10 +4,10 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/tests_data.h>
-#include <util/generic/cast.h>
+#include <util/generic/cast.h>
#include <util/stream/output.h>
#include <util/stream/zlib.h>
-#include <util/system/datetime.h>
+#include <util/system/datetime.h>
#include <util/system/sem.h>
Y_UNIT_TEST_SUITE(THttpServerTest) {
@@ -139,9 +139,9 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
static const TString CrLf = "\r\n";
struct TTestRequest {
- TTestRequest(ui16 port, TString content = TString())
+ TTestRequest(ui16 port, TString content = TString())
: Port(port)
- , Content(std::move(content))
+ , Content(std::move(content))
{
}
@@ -369,59 +369,59 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
}
Y_UNIT_TEST(TestReusePortEnabled) {
- if (!IsReusePortAvailable()) {
+ if (!IsReusePortAvailable()) {
return; // skip test
- }
- TString res = TestData();
- TPortManager pm;
- const ui16 port = pm.GetPort();
-
- TEchoServer serverImpl(res);
+ }
+ TString res = TestData();
+ TPortManager pm;
+ const ui16 port = pm.GetPort();
+
+ TEchoServer serverImpl(res);
TVector<THolder<THttpServer>> servers;
- for (ui32 i = 0; i < 10; i++) {
- servers.push_back(MakeHolder<THttpServer>(&serverImpl, THttpServer::TOptions(port).EnableReusePort(true)));
- }
-
- for (ui32 testRun = 0; testRun < 3; testRun++) {
+ for (ui32 i = 0; i < 10; i++) {
+ servers.push_back(MakeHolder<THttpServer>(&serverImpl, THttpServer::TOptions(port).EnableReusePort(true)));
+ }
+
+ for (ui32 testRun = 0; testRun < 3; testRun++) {
for (auto& server : servers) {
- // start servers one at a time and check at least one of them is replying
- UNIT_ASSERT(server->Start());
-
- TTestRequest r(port, res);
- UNIT_ASSERT_C(r.Execute() == res, "diff echo response for request:\n" + r.GetDescription());
- }
-
+ // start servers one at a time and check at least one of them is replying
+ UNIT_ASSERT(server->Start());
+
+ TTestRequest r(port, res);
+ UNIT_ASSERT_C(r.Execute() == res, "diff echo response for request:\n" + r.GetDescription());
+ }
+
for (auto& server : servers) {
- // ping servers and stop them one at a time
- // at the last iteration only one server is still working and then gets stopped as well
-
- TTestRequest r(port, res);
- UNIT_ASSERT_C(r.Execute() == res, "diff echo response for request:\n" + r.GetDescription());
-
- server->Stop();
- }
- }
- }
-
+ // ping servers and stop them one at a time
+ // at the last iteration only one server is still working and then gets stopped as well
+
+ TTestRequest r(port, res);
+ UNIT_ASSERT_C(r.Execute() == res, "diff echo response for request:\n" + r.GetDescription());
+
+ server->Stop();
+ }
+ }
+ }
+
Y_UNIT_TEST(TestReusePortDisabled) {
- // check that with the ReusePort option disabled it's impossible to start two servers on the same port
- // check that ReusePort option is disabled by default (don't set it explicitly in the test)
- TPortManager pm;
- const ui16 port = pm.GetPort();
-
- TEchoServer serverImpl(TString{});
- THttpServer server1(&serverImpl, THttpServer::TOptions(port));
- THttpServer server2(&serverImpl, THttpServer::TOptions(port));
-
- UNIT_ASSERT(true == server1.Start());
- UNIT_ASSERT(false == server2.Start());
-
- server1.Stop();
- // Stop() is a sync call, port should be free by now
- UNIT_ASSERT(true == server2.Start());
- UNIT_ASSERT(false == server1.Start());
- }
-
+ // check that with the ReusePort option disabled it's impossible to start two servers on the same port
+ // check that ReusePort option is disabled by default (don't set it explicitly in the test)
+ TPortManager pm;
+ const ui16 port = pm.GetPort();
+
+ TEchoServer serverImpl(TString{});
+ THttpServer server1(&serverImpl, THttpServer::TOptions(port));
+ THttpServer server2(&serverImpl, THttpServer::TOptions(port));
+
+ UNIT_ASSERT(true == server1.Start());
+ UNIT_ASSERT(false == server2.Start());
+
+ server1.Stop();
+ // Stop() is a sync call, port should be free by now
+ UNIT_ASSERT(true == server2.Start());
+ UNIT_ASSERT(false == server1.Start());
+ }
+
Y_UNIT_TEST(TestFailServer) {
/**
* Emulate request processing failures
diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h
index 9b9c7d3fe5..38eda0e5e7 100644
--- a/library/cpp/http/server/options.h
+++ b/library/cpp/http/server/options.h
@@ -50,12 +50,12 @@ public:
return *this;
}
- inline THttpServerOptions& EnableReusePort(bool enable) noexcept {
- ReusePort = enable;
-
- return *this;
- }
-
+ inline THttpServerOptions& EnableReusePort(bool enable) noexcept {
+ ReusePort = enable;
+
+ return *this;
+ }
+
inline THttpServerOptions& EnableReuseAddress(bool enable) noexcept {
ReuseAddress = enable;