aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/io
diff options
context:
space:
mode:
authorkulikov <kulikov@yandex-team.ru>2022-02-10 16:49:34 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:34 +0300
commit65e5266709e7ff94b14ae128309e229de714b0df (patch)
treed4901f06e56d95f5e5d36bd1806bcc144d03bf41 /library/cpp/http/io
parent0041d99876ae3dccc3f0fa8787131d85ddfd486b (diff)
downloadydb-65e5266709e7ff94b14ae128309e229de714b0df.tar.gz
Restoring authorship annotation for <kulikov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/io')
-rw-r--r--library/cpp/http/io/compression.h44
-rw-r--r--library/cpp/http/io/compression_ut.cpp30
-rw-r--r--library/cpp/http/io/stream.cpp14
-rw-r--r--library/cpp/http/io/stream_ut.cpp98
4 files changed, 93 insertions, 93 deletions
diff --git a/library/cpp/http/io/compression.h b/library/cpp/http/io/compression.h
index f16c4a18eb..30eccdaca5 100644
--- a/library/cpp/http/io/compression.h
+++ b/library/cpp/http/io/compression.h
@@ -48,25 +48,25 @@ private:
THashMap<TStringBuf, TCodec> Codecs_;
TVector<TStringBuf> BestCodecs_;
};
-
-namespace NHttp {
- template <typename F>
- TString ChooseBestCompressionScheme(F accepted, TArrayRef<const TStringBuf> available) {
- if (available.empty()) {
- return "identity";
- }
-
- if (accepted("*")) {
- return TString(available[0]);
- }
-
- for (const auto& coding : available) {
- TString s(coding);
- if (accepted(s)) {
- return s;
- }
- }
-
- return "identity";
- }
-}
+
+namespace NHttp {
+ template <typename F>
+ TString ChooseBestCompressionScheme(F accepted, TArrayRef<const TStringBuf> available) {
+ if (available.empty()) {
+ return "identity";
+ }
+
+ if (accepted("*")) {
+ return TString(available[0]);
+ }
+
+ for (const auto& coding : available) {
+ TString s(coding);
+ if (accepted(s)) {
+ return s;
+ }
+ }
+
+ return "identity";
+ }
+}
diff --git a/library/cpp/http/io/compression_ut.cpp b/library/cpp/http/io/compression_ut.cpp
index 2f3d131f8c..d8a2d11a08 100644
--- a/library/cpp/http/io/compression_ut.cpp
+++ b/library/cpp/http/io/compression_ut.cpp
@@ -5,7 +5,7 @@
#include <library/cpp/testing/unittest/tests_data.h>
#include <util/stream/zlib.h>
-#include <util/generic/hash_set.h>
+#include <util/generic/hash_set.h>
Y_UNIT_TEST_SUITE(THttpCompressionTest) {
static const TString DATA = "I'm a teapot";
@@ -43,18 +43,18 @@ Y_UNIT_TEST_SUITE(THttpCompressionTest) {
auto decodedStream = (*decoder)(&buffer);
UNIT_ASSERT_EQUAL(decodedStream->ReadAll(), DATA);
}
-
- Y_UNIT_TEST(TestChooseBestCompressionScheme) {
- THashSet<TString> accepted;
-
- auto checkAccepted = [&accepted](const TString& v) {
- return accepted.contains(v);
- };
-
- UNIT_ASSERT_VALUES_EQUAL("identity", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
- accepted.insert("deflate");
- UNIT_ASSERT_VALUES_EQUAL("deflate", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
- accepted.insert("*");
- UNIT_ASSERT_VALUES_EQUAL("gzip", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
- }
+
+ Y_UNIT_TEST(TestChooseBestCompressionScheme) {
+ THashSet<TString> accepted;
+
+ auto checkAccepted = [&accepted](const TString& v) {
+ return accepted.contains(v);
+ };
+
+ UNIT_ASSERT_VALUES_EQUAL("identity", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
+ accepted.insert("deflate");
+ UNIT_ASSERT_VALUES_EQUAL("deflate", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
+ accepted.insert("*");
+ UNIT_ASSERT_VALUES_EQUAL("gzip", NHttp::ChooseBestCompressionScheme(checkAccepted, {"gzip", "deflate"}));
+ }
} // THttpCompressionTest suite
diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp
index 6689be684f..728d1a89c1 100644
--- a/library/cpp/http/io/stream.cpp
+++ b/library/cpp/http/io/stream.cpp
@@ -286,7 +286,7 @@ private:
TParsedHeaders p;
size_t pos = FirstLine_.rfind(' ');
- // In HTTP/1.1 Keep-Alive is turned on by default
+ // In HTTP/1.1 Keep-Alive is turned on by default
if (pos != TString::npos && strcmp(FirstLine_.c_str() + pos + 1, "HTTP/1.1") == 0) {
p.KeepAlive = true; //request
} else if (strnicmp(FirstLine_.data(), "HTTP/1.1", 8) == 0) {
@@ -428,12 +428,12 @@ bool THttpInput::AcceptEncoding(const TString& coding) const {
}
TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) const {
- return NHttp::ChooseBestCompressionScheme(
- [this](const TString& coding) {
- return AcceptEncoding(coding);
- },
- codings
- );
+ return NHttp::ChooseBestCompressionScheme(
+ [this](const TString& coding) {
+ return AcceptEncoding(coding);
+ },
+ codings
+ );
}
TString THttpInput::BestCompressionScheme() const {
diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp
index 1ea35df675..1d78c82e0e 100644
--- a/library/cpp/http/io/stream_ut.cpp
+++ b/library/cpp/http/io/stream_ut.cpp
@@ -179,63 +179,63 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) {
}
Y_UNIT_TEST(TestKeepAlive) {
- {
+ {
TString s = "GET / HTTP/1.0\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(!in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(!in.IsKeepAlive());
+ }
+
+ {
TString s = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(in.IsKeepAlive());
+ }
+
+ {
TString s = "GET / HTTP/1.1\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(in.IsKeepAlive());
+ }
+
+ {
TString s = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(!in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(!in.IsKeepAlive());
+ }
+
+ {
TString s = "HTTP/1.0 200 Ok\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(!in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(!in.IsKeepAlive());
+ }
+
+ {
TString s = "HTTP/1.0 200 Ok\r\nConnection: keep-alive\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(in.IsKeepAlive());
+ }
+
+ {
TString s = "HTTP/1.1 200 Ok\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(in.IsKeepAlive());
- }
-
- {
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(in.IsKeepAlive());
+ }
+
+ {
TString s = "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n";
- TStringInput si(s);
- THttpInput in(&si);
- UNIT_ASSERT(!in.IsKeepAlive());
- }
- }
-
+ TStringInput si(s);
+ THttpInput in(&si);
+ UNIT_ASSERT(!in.IsKeepAlive());
+ }
+ }
+
Y_UNIT_TEST(TestMinRequest) {
TString res = "qqqqqq";
TPortManager pm;