Browse Source

Restoring authorship annotation for <cherenkov-p-a@yandex-team.ru>. Commit 2 of 2.

cherenkov-p-a 3 years ago
parent
commit
8124e2bb21

+ 2 - 2
library/cpp/http/io/stream.cpp

@@ -394,8 +394,8 @@ THttpInput::THttpInput(IInputStream* slave)
 {
 }
 
-THttpInput::THttpInput(THttpInput&& httpInput) = default; 
- 
+THttpInput::THttpInput(THttpInput&& httpInput) = default;
+
 THttpInput::~THttpInput() {
 }
 

+ 1 - 1
library/cpp/http/io/stream.h

@@ -25,7 +25,7 @@ struct THttpReadException: public THttpException {
 class THttpInput: public IInputStream {
 public:
     THttpInput(IInputStream* slave);
-    THttpInput(THttpInput&& httpInput); 
+    THttpInput(THttpInput&& httpInput);
     ~THttpInput() override;
 
     /*

+ 4 - 4
library/cpp/http/server/http.cpp

@@ -68,7 +68,7 @@ public:
     bool Reject_ = false;
     TInstant LastUsed;
     TInstant AcceptMoment;
-    size_t ReceivedRequests = 0; 
+    size_t ReceivedRequests = 0;
 };
 
 class THttpServer::TImpl {
@@ -597,7 +597,7 @@ void TClientConnection::OnPollEvent(TInstant now) {
 void TClientConnection::Activate(TInstant now) noexcept {
     HttpServ_->Connections->Erase(this, now);
     LastUsed = now;
-    ++ReceivedRequests; 
+    ++ReceivedRequests;
 }
 
 void TClientConnection::DeActivate() {
@@ -690,8 +690,8 @@ void TClientRequest::Process(void* ThreadSpecificResource) {
                 HttpConn_.Reset(new THttpServerConn(Socket()));
             }
 
-            auto maxRequestsPerConnection = HttpServ()->Options().MaxRequestsPerConnection; 
-            HttpConn_->Output()->EnableKeepAlive(HttpServ()->Options().KeepAliveEnabled && (!maxRequestsPerConnection || Conn_->ReceivedRequests < maxRequestsPerConnection)); 
+            auto maxRequestsPerConnection = HttpServ()->Options().MaxRequestsPerConnection;
+            HttpConn_->Output()->EnableKeepAlive(HttpServ()->Options().KeepAliveEnabled && (!maxRequestsPerConnection || Conn_->ReceivedRequests < maxRequestsPerConnection));
             HttpConn_->Output()->EnableCompression(HttpServ()->Options().CompressionEnabled);
         }
 

+ 20 - 20
library/cpp/http/server/http_ut.cpp

@@ -559,7 +559,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
         UNIT_ASSERT_STRINGS_EQUAL(serverImpl.ExceptionMessage, "(yexception) some error");
     };
 
-    THttpInput SendRequest(TSocket& socket, ui16 port) { 
+    THttpInput SendRequest(TSocket& socket, ui16 port) {
         TSocketInput si(socket);
         TSocketOutput so(socket);
         THttpOutput out(&so);
@@ -571,7 +571,7 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
 
         THttpInput input(&si);
         input.ReadAll();
-        return input; 
+        return input;
     }
 
     THttpInput SendRequestWithBody(TSocket& socket, ui16 port, TString body) {
@@ -642,24 +642,24 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
     }
 
 
-    Y_UNIT_TEST(TTestCloseConnectionOnRequestLimit) { 
-        TPortManager pm; 
-        const ui16 port = pm.GetPort(); 
- 
-        TEchoServer serverImpl("test_data"); 
-        THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true).SetMaxRequestsPerConnection(2)); 
-        UNIT_ASSERT(server.Start()); 
- 
-        TSocket socket(TNetworkAddress("localhost", port), TDuration::Seconds(10)); 
- 
-        UNIT_ASSERT(SendRequest(socket, port).IsKeepAlive()); 
-        UNIT_ASSERT(!SendRequest(socket, port).IsKeepAlive()); 
- 
-        UNIT_ASSERT_EXCEPTION(SendRequest(socket, port), THttpReadException); 
- 
-        server.Stop(); 
-    } 
- 
+    Y_UNIT_TEST(TTestCloseConnectionOnRequestLimit) {
+        TPortManager pm;
+        const ui16 port = pm.GetPort();
+
+        TEchoServer serverImpl("test_data");
+        THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true).SetMaxRequestsPerConnection(2));
+        UNIT_ASSERT(server.Start());
+
+        TSocket socket(TNetworkAddress("localhost", port), TDuration::Seconds(10));
+
+        UNIT_ASSERT(SendRequest(socket, port).IsKeepAlive());
+        UNIT_ASSERT(!SendRequest(socket, port).IsKeepAlive());
+
+        UNIT_ASSERT_EXCEPTION(SendRequest(socket, port), THttpReadException);
+
+        server.Stop();
+    }
+
     Y_UNIT_TEST(TTestListenerSockAddrConnection) {
         TPortManager pm;
         const ui16 port1 = pm.GetPort();

+ 7 - 7
library/cpp/http/server/options.h

@@ -118,12 +118,12 @@ public:
         return *this;
     }
 
-    inline THttpServerOptions& SetMaxRequestsPerConnection(size_t val) noexcept { 
-        MaxRequestsPerConnection = val; 
- 
-        return *this; 
-    } 
- 
+    inline THttpServerOptions& SetMaxRequestsPerConnection(size_t val) noexcept {
+        MaxRequestsPerConnection = val;
+
+        return *this;
+    }
+
     /// Use TElasticQueue instead of TThreadPool for request queues
     inline THttpServerOptions& EnableElasticQueues(bool enable) noexcept {
         UseElasticQueues = enable;
@@ -164,7 +164,7 @@ public:
     TDuration ClientTimeout;
     size_t OutputBufferSize = 0;
     ui64 MaxInputContentLength = sizeof(size_t) <= 4 ? 2_GB : 64_GB;
-    size_t MaxRequestsPerConnection = 0;  // If keep-alive is enabled, request limit before connection is closed 
+    size_t MaxRequestsPerConnection = 0;  // If keep-alive is enabled, request limit before connection is closed
     bool UseElasticQueues = false;
 
     TDuration PollTimeout; // timeout of TSocketPoller::WaitT call

+ 2 - 2
library/cpp/iterator/concatenate.h

@@ -77,9 +77,9 @@ namespace NPrivate {
                 TValue operator*() const {
                     return GetCurrentValue(Position_, Iterators_);
                 }
-                TIterator& operator++() { 
+                TIterator& operator++() {
                     MaybeIncrementIteratorAndSkipExhaustedContainers<true>();
-                    return *this; 
+                    return *this;
                 }
                 bool operator!=(const TSentinel& other) const {
                     // give compiler an opportunity to optimize sentinel case (-70% of time)

+ 3 - 3
library/cpp/protobuf/ya.make

@@ -1,5 +1,5 @@
-RECURSE( 
-    dynamic_prototype 
+RECURSE(
+    dynamic_prototype
     from_xml
     from_xml/ut
     interop
@@ -16,4 +16,4 @@ RECURSE(
     yql/ut
     yandex_patches_ut
     yt
-) 
+)

+ 20 - 20
library/cpp/string_utils/url/url.cpp

@@ -283,26 +283,26 @@ TStringBuf CutWWWPrefix(const TStringBuf url) noexcept {
     return url;
 }
 
-TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept { 
-    auto it = url.begin(); 
- 
-    StripRangeBegin(it, url.end(), [](auto& it){ return *it == 'w' || *it == 'W'; }); 
-    if (it == url.begin()) { 
-        return url; 
-    } 
- 
-    StripRangeBegin(it, url.end(), [](auto& it){ return IsAsciiDigit(*it); }); 
-    if (it == url.end()) { 
-        return url; 
-    } 
- 
-    if (*it++ == '.') { 
-        return url.Tail(it - url.begin()); 
-    } 
- 
-    return url; 
-} 
- 
+TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept {
+    auto it = url.begin();
+
+    StripRangeBegin(it, url.end(), [](auto& it){ return *it == 'w' || *it == 'W'; });
+    if (it == url.begin()) {
+        return url;
+    }
+
+    StripRangeBegin(it, url.end(), [](auto& it){ return IsAsciiDigit(*it); });
+    if (it == url.end()) {
+        return url;
+    }
+
+    if (*it++ == '.') {
+        return url.Tail(it - url.begin());
+    }
+
+    return url;
+}
+
 TStringBuf CutMPrefix(const TStringBuf url) noexcept {
     if (url.size() >= 2 && url[1] == '.' && (url[0] == 'm' || url[0] == 'M')) {
         return url.substr(2);

+ 3 - 3
library/cpp/string_utils/url/url.h

@@ -142,9 +142,9 @@ TStringBuf GetZone(const TStringBuf host) noexcept;
 Y_PURE_FUNCTION
 TStringBuf CutWWWPrefix(const TStringBuf url) noexcept;
 
-Y_PURE_FUNCTION 
-TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept; 
- 
+Y_PURE_FUNCTION
+TStringBuf CutWWWNumberedPrefix(const TStringBuf url) noexcept;
+
 /**
  * Cuts 'm.' prefix from url if and only if the url starts with it
  * Example: 'm.some-domain.com' -> 'some-domain.com'.

+ 11 - 11
library/cpp/string_utils/url/url_ut.cpp

@@ -110,17 +110,17 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
         UNIT_ASSERT_VALUES_EQUAL("www", CutWWWPrefix("www"));
         UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWPrefix("www.ya.ru"));
 
-        UNIT_ASSERT_VALUES_EQUAL("", CutWWWNumberedPrefix("www.")); 
-        UNIT_ASSERT_VALUES_EQUAL("www", CutWWWNumberedPrefix("www")); 
-        UNIT_ASSERT_VALUES_EQUAL("www27", CutWWWNumberedPrefix("www27")); 
-        UNIT_ASSERT_VALUES_EQUAL("", CutWWWNumberedPrefix("www27.")); 
-        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www.ya.ru")); 
-        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www2.ya.ru")); 
-        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www12.ya.ru")); 
-        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("ww2.ya.ru")); 
-        UNIT_ASSERT_VALUES_EQUAL("w1w2w3.ya.ru", CutWWWNumberedPrefix("w1w2w3.ya.ru")); 
-        UNIT_ASSERT_VALUES_EQUAL("123.ya.ru", CutWWWNumberedPrefix("123.ya.ru")); 
- 
+        UNIT_ASSERT_VALUES_EQUAL("", CutWWWNumberedPrefix("www."));
+        UNIT_ASSERT_VALUES_EQUAL("www", CutWWWNumberedPrefix("www"));
+        UNIT_ASSERT_VALUES_EQUAL("www27", CutWWWNumberedPrefix("www27"));
+        UNIT_ASSERT_VALUES_EQUAL("", CutWWWNumberedPrefix("www27."));
+        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www.ya.ru"));
+        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www2.ya.ru"));
+        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("www12.ya.ru"));
+        UNIT_ASSERT_VALUES_EQUAL("ya.ru", CutWWWNumberedPrefix("ww2.ya.ru"));
+        UNIT_ASSERT_VALUES_EQUAL("w1w2w3.ya.ru", CutWWWNumberedPrefix("w1w2w3.ya.ru"));
+        UNIT_ASSERT_VALUES_EQUAL("123.ya.ru", CutWWWNumberedPrefix("123.ya.ru"));
+
         UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("m."));
         UNIT_ASSERT_VALUES_EQUAL("", CutMPrefix("M."));
         UNIT_ASSERT_VALUES_EQUAL("m", CutMPrefix("m"));