aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratayan1 <atayan1@yandex-team.ru>2022-02-10 16:49:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:38 +0300
commit9700ce2289436b557831d64eb47682c8c2a30ee2 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8
parentc711d9aae73052830cd54065a75b3e3739893aba (diff)
downloadydb-9700ce2289436b557831d64eb47682c8c2a30ee2.tar.gz
Restoring authorship annotation for <atayan1@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--library/cpp/http/server/http.cpp28
-rw-r--r--library/cpp/http/server/http.h2
-rw-r--r--library/cpp/http/server/http_ut.cpp86
3 files changed, 58 insertions, 58 deletions
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index 115623490e..128583bdd7 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -52,7 +52,7 @@ namespace {
class TClientConnection: public IPollAble, public TIntrusiveListItem<TClientConnection> {
public:
- TClientConnection(const TSocket& s, THttpServer::TImpl* serv, NAddr::IRemoteAddrRef listenerSockAddrRef);
+ TClientConnection(const TSocket& s, THttpServer::TImpl* serv, NAddr::IRemoteAddrRef listenerSockAddrRef);
~TClientConnection() override;
void OnPollEvent(TInstant now) override;
@@ -63,7 +63,7 @@ public:
public:
TSocket Socket_;
- NAddr::IRemoteAddrRef ListenerSockAddrRef_;
+ NAddr::IRemoteAddrRef ListenerSockAddrRef_;
THttpServer::TImpl* HttpServ_ = nullptr;
bool Reject_ = false;
TInstant LastUsed;
@@ -153,17 +153,17 @@ public:
return obj;
}
- void AddRequestFromSocket(const TSocket& s, TInstant now, NAddr::IRemoteAddrRef listenerSockAddrRef) {
+ void AddRequestFromSocket(const TSocket& s, TInstant now, NAddr::IRemoteAddrRef listenerSockAddrRef) {
if (MaxRequestsReached()) {
Cb_->OnMaxConn();
bool wasRemoved = Connections->RemoveOld(TInstant::Max());
if (!wasRemoved && Options_.RejectExcessConnections) {
- (new TClientConnection(s, this, listenerSockAddrRef))->Reject();
+ (new TClientConnection(s, this, listenerSockAddrRef))->Reject();
return;
}
}
- auto connection = new TClientConnection(s, this, listenerSockAddrRef);
+ auto connection = new TClientConnection(s, this, listenerSockAddrRef);
connection->LastUsed = now;
connection->DeActivate();
}
@@ -293,7 +293,7 @@ public:
inline TListenSocket(const TSocket& s, TImpl* parent)
: S_(s)
, Server_(parent)
- , SockAddrRef_(GetSockAddr(S_))
+ , SockAddrRef_(GetSockAddr(S_))
{
}
@@ -307,7 +307,7 @@ public:
ythrow yexception() << "accept: " << LastSystemErrorText();
}
- Server_->AddRequestFromSocket(s, TInstant::Now(), SockAddrRef_);
+ Server_->AddRequestFromSocket(s, TInstant::Now(), SockAddrRef_);
}
SOCKET GetSocket() const noexcept {
@@ -317,7 +317,7 @@ public:
private:
TSocket S_;
TImpl* Server_ = nullptr;
- NAddr::IRemoteAddrRef SockAddrRef_;
+ NAddr::IRemoteAddrRef SockAddrRef_;
};
void ListenSocket() {
@@ -551,9 +551,9 @@ bool THttpServer::MaxRequestsReached() const {
return Impl_->MaxRequestsReached();
}
-TClientConnection::TClientConnection(const TSocket& s, THttpServer::TImpl* serv, NAddr::IRemoteAddrRef listenerSockAddrRef)
+TClientConnection::TClientConnection(const TSocket& s, THttpServer::TImpl* serv, NAddr::IRemoteAddrRef listenerSockAddrRef)
: Socket_(s)
- , ListenerSockAddrRef_(listenerSockAddrRef)
+ , ListenerSockAddrRef_(listenerSockAddrRef)
, HttpServ_(serv)
{
SetNoDelay(Socket_, true);
@@ -772,10 +772,10 @@ const TSocket& TClientRequest::Socket() const noexcept {
return Conn_->Socket_;
}
-NAddr::IRemoteAddrRef TClientRequest::GetListenerSockAddrRef() const noexcept {
- return Conn_->ListenerSockAddrRef_;
-}
-
+NAddr::IRemoteAddrRef TClientRequest::GetListenerSockAddrRef() const noexcept {
+ return Conn_->ListenerSockAddrRef_;
+}
+
TInstant TClientRequest::AcceptMoment() const noexcept {
return Conn_->AcceptMoment;
}
diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h
index 88e6b5a7ac..b292d38f27 100644
--- a/library/cpp/http/server/http.h
+++ b/library/cpp/http/server/http.h
@@ -119,7 +119,7 @@ public:
THttpServer* HttpServ() const noexcept;
const TSocket& Socket() const noexcept;
- NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept;
+ NAddr::IRemoteAddrRef GetListenerSockAddrRef() const noexcept;
TInstant AcceptMoment() const noexcept;
bool IsLocal() const;
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index 61bf44a7ed..cc62bb988e 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -507,25 +507,25 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
TString ExceptionMessage;
};
- class TListenerSockAddrReplyServer: public THttpServer::ICallBack {
- class TRequest: public TClientRequest {
- public:
- bool Reply(void* /*tsr*/) override {
- Output() << "HTTP/1.1 200 Ok\r\n\r\n";
- Output() << PrintHostAndPort(*GetListenerSockAddrRef());
-
- Output().Finish();
-
- return true;
- }
- };
-
- public:
- TClientRequest* CreateClient() override {
- return new TRequest();
- }
- };
-
+ class TListenerSockAddrReplyServer: public THttpServer::ICallBack {
+ class TRequest: public TClientRequest {
+ public:
+ bool Reply(void* /*tsr*/) override {
+ Output() << "HTTP/1.1 200 Ok\r\n\r\n";
+ Output() << PrintHostAndPort(*GetListenerSockAddrRef());
+
+ Output().Finish();
+
+ return true;
+ }
+ };
+
+ public:
+ TClientRequest* CreateClient() override {
+ return new TRequest();
+ }
+ };
+
Y_UNIT_TEST(TTestResetConnection) {
TPortManager pm;
const ui16 port = pm.GetPort();
@@ -660,30 +660,30 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
server.Stop();
}
- Y_UNIT_TEST(TTestListenerSockAddrConnection) {
- TPortManager pm;
- const ui16 port1 = pm.GetPort();
- const ui16 port2 = pm.GetPort();
-
- TListenerSockAddrReplyServer serverImpl;
- THttpServer server(&serverImpl, THttpServer::TOptions().EnableKeepAlive(true).AddBindAddress("127.0.0.1", port1).AddBindAddress("127.0.0.1", port2));
- UNIT_ASSERT(server.Start());
-
- TTestRequest r1(port1);
- r1.KeepAliveConnection = true;
-
- TString resp = r1.Execute();
- UNIT_ASSERT(resp == TString::Join("127.0.0.1", ":", ToString(port1)));
-
- TTestRequest r2(port2);
- r2.KeepAliveConnection = true;
-
- resp = r2.Execute();
- UNIT_ASSERT(resp == TString::Join("127.0.0.1", ":", ToString(port2)));
-
- server.Stop();
- };
-
+ Y_UNIT_TEST(TTestListenerSockAddrConnection) {
+ TPortManager pm;
+ const ui16 port1 = pm.GetPort();
+ const ui16 port2 = pm.GetPort();
+
+ TListenerSockAddrReplyServer serverImpl;
+ THttpServer server(&serverImpl, THttpServer::TOptions().EnableKeepAlive(true).AddBindAddress("127.0.0.1", port1).AddBindAddress("127.0.0.1", port2));
+ UNIT_ASSERT(server.Start());
+
+ TTestRequest r1(port1);
+ r1.KeepAliveConnection = true;
+
+ TString resp = r1.Execute();
+ UNIT_ASSERT(resp == TString::Join("127.0.0.1", ":", ToString(port1)));
+
+ TTestRequest r2(port2);
+ r2.KeepAliveConnection = true;
+
+ resp = r2.Execute();
+ UNIT_ASSERT(resp == TString::Join("127.0.0.1", ":", ToString(port2)));
+
+ server.Stop();
+ };
+
#if 0
Y_UNIT_TEST(TestSocketsLeak) {
const bool trueFalse[] = {true, false};