aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrew-iv <andrew-iv@yandex-team.ru>2022-02-10 16:49:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:36 +0300
commita7c41f2d250ec4075eb32fb0da0fd5c85308c8f0 (patch)
treee9434a3e8d049e76df899af7e8f6eb5bd2d5c827
parentc617191a3b33c0f5e1be6390361dbe540775d158 (diff)
downloadydb-a7c41f2d250ec4075eb32fb0da0fd5c85308c8f0.tar.gz
Restoring authorship annotation for <andrew-iv@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/http/server/http_ex.cpp14
-rw-r--r--library/cpp/http/server/http_ut.cpp84
-rw-r--r--library/cpp/http/server/options.h16
-rw-r--r--library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp4
4 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/http/server/http_ex.cpp b/library/cpp/http/server/http_ex.cpp
index e07db22bfc..ec82a3dee6 100644
--- a/library/cpp/http/server/http_ex.cpp
+++ b/library/cpp/http/server/http_ex.cpp
@@ -2,7 +2,7 @@
#include <util/generic/buffer.h>
#include <util/generic/cast.h>
-#include <util/stream/null.h>
+#include <util/stream/null.h>
bool THttpClientRequestExtension::Parse(char* req, TBaseServerRequestData& rd) {
rd.SetSocket(Socket());
@@ -76,12 +76,12 @@ bool THttpClientRequestExtension::ProcessHeaders(TBaseServerRequestData& rd, TBl
}
if (!Input().ContentEncoded() && Input().GetContentLength(contentLength)) {
- if (contentLength > HttpServ()->Options().MaxInputContentLength) {
- Output() << "HTTP/1.1 413 Payload Too Large\r\nContent-Length:0\r\n\r\n";
- Output().Finish();
- return false;
- }
-
+ if (contentLength > HttpServ()->Options().MaxInputContentLength) {
+ Output() << "HTTP/1.1 413 Payload Too Large\r\nContent-Length:0\r\n\r\n";
+ Output().Finish();
+ return false;
+ }
+
TBuffer buf(SafeIntegerCast<size_t>(contentLength));
buf.Resize(Input().Load(buf.Data(), (size_t)contentLength));
postData = TBlob::FromBuffer(buf);
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index cc62bb988e..082a81caa2 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -574,22 +574,22 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
return input;
}
- THttpInput SendRequestWithBody(TSocket& socket, ui16 port, TString body) {
- TSocketInput si(socket);
- TSocketOutput so(socket);
- THttpOutput out(&so);
- out << "POST / HTTP/1.1" << CrLf;
- out << "Host: localhost:" + ToString(port) << CrLf;
- out << "Content-Length: " + ToString(body.size()) << CrLf;
- out << CrLf;
- out << body;
- out.Flush();
-
- THttpInput input(&si);
- input.ReadAll();
- return input;
- }
-
+ THttpInput SendRequestWithBody(TSocket& socket, ui16 port, TString body) {
+ TSocketInput si(socket);
+ TSocketOutput so(socket);
+ THttpOutput out(&so);
+ out << "POST / HTTP/1.1" << CrLf;
+ out << "Host: localhost:" + ToString(port) << CrLf;
+ out << "Content-Length: " + ToString(body.size()) << CrLf;
+ out << CrLf;
+ out << body;
+ out.Flush();
+
+ THttpInput input(&si);
+ input.ReadAll();
+ return input;
+ }
+
Y_UNIT_TEST(TTestExpirationTimeout) {
TPortManager pm;
const ui16 port = pm.GetPort();
@@ -616,32 +616,32 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
server.Stop();
}
- Y_UNIT_TEST(TTestContentLengthTooLarge) {
- TPortManager pm;
- const ui16 port = pm.GetPort();
-
- TEchoServer serverImpl("test_data");
- THttpServer::TOptions options(port);
- options.nThreads = 1;
- options.MaxQueueSize = 0;
- options.MaxInputContentLength = 2_KB;
- options.MaxConnections = 0;
- options.KeepAliveEnabled = false;
- options.ExpirationTimeout = TDuration::Seconds(1);
- options.PollTimeout = TDuration::MilliSeconds(100);
- THttpServer server(&serverImpl, options);
- UNIT_ASSERT(server.Start());
-
- TSocket socket(TNetworkAddress("localhost", port), TDuration::Seconds(5));
- UNIT_ASSERT_STRING_CONTAINS(SendRequestWithBody(socket, port, TString(1_KB, 'a')).FirstLine(), "HTTP/1.1 200 Ok");
-
- TSocket socket2(TNetworkAddress("localhost", port), TDuration::Seconds(5));
- UNIT_ASSERT_STRING_CONTAINS(SendRequestWithBody(socket2, port, TString(10_KB, 'a')).FirstLine(), "HTTP/1.1 413 Payload Too Large");
-
- server.Stop();
- }
-
-
+ Y_UNIT_TEST(TTestContentLengthTooLarge) {
+ TPortManager pm;
+ const ui16 port = pm.GetPort();
+
+ TEchoServer serverImpl("test_data");
+ THttpServer::TOptions options(port);
+ options.nThreads = 1;
+ options.MaxQueueSize = 0;
+ options.MaxInputContentLength = 2_KB;
+ options.MaxConnections = 0;
+ options.KeepAliveEnabled = false;
+ options.ExpirationTimeout = TDuration::Seconds(1);
+ options.PollTimeout = TDuration::MilliSeconds(100);
+ THttpServer server(&serverImpl, options);
+ UNIT_ASSERT(server.Start());
+
+ TSocket socket(TNetworkAddress("localhost", port), TDuration::Seconds(5));
+ UNIT_ASSERT_STRING_CONTAINS(SendRequestWithBody(socket, port, TString(1_KB, 'a')).FirstLine(), "HTTP/1.1 200 Ok");
+
+ TSocket socket2(TNetworkAddress("localhost", port), TDuration::Seconds(5));
+ UNIT_ASSERT_STRING_CONTAINS(SendRequestWithBody(socket2, port, TString(10_KB, 'a')).FirstLine(), "HTTP/1.1 413 Payload Too Large");
+
+ server.Stop();
+ }
+
+
Y_UNIT_TEST(TTestCloseConnectionOnRequestLimit) {
TPortManager pm;
const ui16 port = pm.GetPort();
diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h
index 38eda0e5e7..72591c4f55 100644
--- a/library/cpp/http/server/options.h
+++ b/library/cpp/http/server/options.h
@@ -3,7 +3,7 @@
#include <util/network/ip.h>
#include <util/network/init.h>
#include <util/network/address.h>
-#include <util/generic/size_literals.h>
+#include <util/generic/size_literals.h>
#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/datetime/base.h>
@@ -112,12 +112,12 @@ public:
return *this;
}
- inline THttpServerOptions& SetMaxInputContentLength(ui64 val) noexcept {
- MaxInputContentLength = val;
-
- return *this;
- }
-
+ inline THttpServerOptions& SetMaxInputContentLength(ui64 val) noexcept {
+ MaxInputContentLength = val;
+
+ return *this;
+ }
+
inline THttpServerOptions& SetMaxRequestsPerConnection(size_t val) noexcept {
MaxRequestsPerConnection = val;
@@ -163,7 +163,7 @@ public:
int ListenBacklog = SOMAXCONN;
TDuration ClientTimeout;
size_t OutputBufferSize = 0;
- ui64 MaxInputContentLength = sizeof(size_t) <= 4 ? 2_GB : 64_GB;
+ 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
bool UseElasticQueues = false;
diff --git a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
index c3ed068a37..62689c37f8 100644
--- a/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
+++ b/library/cpp/string_utils/base64/base64_decode_uneven_ut.cpp
@@ -1,5 +1,5 @@
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <library/cpp/string_utils/base64/base64.h>
Y_UNIT_TEST_SUITE(TBase64DecodeUneven) {
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TBase64DecodeUneven) {
"c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0"
"aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl"
"LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
-
+
UNIT_ASSERT_VALUES_EQUAL(encoded, Base64Encode(wikipedia_slogan));
UNIT_ASSERT_VALUES_EQUAL(wikipedia_slogan, Base64DecodeUneven(encoded));