diff options
author | myltsev <myltsev@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
commit | fc361854fd6ee8d747229b090f0b8018e260d1fb (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/http | |
parent | 9166d66c30c23c9e85a7c88185a068987148d23f (diff) | |
download | ydb-fc361854fd6ee8d747229b090f0b8018e260d1fb.tar.gz |
Restoring authorship annotation for <myltsev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http')
-rw-r--r-- | library/cpp/http/io/headers.cpp | 12 | ||||
-rw-r--r-- | library/cpp/http/io/headers.h | 4 | ||||
-rw-r--r-- | library/cpp/http/io/stream.cpp | 8 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 36 | ||||
-rw-r--r-- | library/cpp/http/misc/httpdate.cpp | 6 | ||||
-rw-r--r-- | library/cpp/http/misc/httpdate.h | 2 | ||||
-rw-r--r-- | library/cpp/http/misc/httpdate_ut.cpp | 4 | ||||
-rw-r--r-- | library/cpp/http/server/response.h | 8 |
8 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index fe82383318..4ec27a29e8 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -75,12 +75,12 @@ const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const void THttpHeaders::RemoveHeader(const TStringBuf header) { for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { - Headers_.erase(h); - return; - } - } -} - + Headers_.erase(h); + return; + } + } +} + void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { for (auto& hdr : Headers_) { if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { diff --git a/library/cpp/http/io/headers.h b/library/cpp/http/io/headers.h index 3b15d60462..a71793d1c6 100644 --- a/library/cpp/http/io/headers.h +++ b/library/cpp/http/io/headers.h @@ -102,9 +102,9 @@ public: // Проверяет, есть ли такой заголовок bool HasHeader(TStringBuf header) const; - /// Удаляет заголовок, если он есть. + /// Удаляет заголовок, если он есть. void RemoveHeader(TStringBuf header); - + /// Ищет заголовок по указанному имени /// Возвращает nullptr, если не нашел const THttpInputHeader* FindHeader(TStringBuf header) const; diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 90d063a4ba..6689be684f 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -776,7 +776,7 @@ private: TString scheme = Request_->BestCompressionScheme(ComprSchemas_); if (scheme != "identity") { AddOrReplaceHeader(THttpInputHeader("Content-Encoding", scheme)); - RemoveHeader("Content-Length"); + RemoveHeader("Content-Length"); } } @@ -851,9 +851,9 @@ private: } inline void RemoveHeader(const TString& hdr) { - Headers_.RemoveHeader(hdr); - } - + Headers_.RemoveHeader(hdr); + } + private: IOutputStream* Slave_; TState State_; diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 64b48b4a66..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -420,27 +420,27 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { } Y_UNIT_TEST(ContentLengthRemoval) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); - THttpInput i(&request); + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); + THttpInput i(&request); TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); - httpOut.EnableCompression(true); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); + httpOut.EnableCompression(true); + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; httpOut << "Content-Length: " << strlen(answer) << "\r\n" "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: gzip")); - UNIT_ASSERT(!result.Contains("content-length")); - } - + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: gzip")); + UNIT_ASSERT(!result.Contains("content-length")); + } + Y_UNIT_TEST(CodecsPriority) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"br", "gzip"}; diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp index 1d6617eeec..4a3031bbf4 100644 --- a/library/cpp/http/misc/httpdate.cpp +++ b/library/cpp/http/misc/httpdate.cpp @@ -75,9 +75,9 @@ char* format_http_date(time_t when, char* buf, size_t buflen) { return buf; } - + TString FormatHttpDate(time_t when) { - char str[64] = {0}; + char str[64] = {0}; format_http_date(str, Y_ARRAY_SIZE(str), when); return TString(str); -} +} diff --git a/library/cpp/http/misc/httpdate.h b/library/cpp/http/misc/httpdate.h index 2a33545a7e..04876f38fe 100644 --- a/library/cpp/http/misc/httpdate.h +++ b/library/cpp/http/misc/httpdate.h @@ -17,5 +17,5 @@ inline time_t parse_http_date(const TStringBuf& datestring) { int format_http_date(char buf[], size_t size, time_t when); char* format_http_date(time_t when, char* buf, size_t len); - + TString FormatHttpDate(time_t when); diff --git a/library/cpp/http/misc/httpdate_ut.cpp b/library/cpp/http/misc/httpdate_ut.cpp index 8d700a9593..c1a0103501 100644 --- a/library/cpp/http/misc/httpdate_ut.cpp +++ b/library/cpp/http/misc/httpdate_ut.cpp @@ -10,6 +10,6 @@ Y_UNIT_TEST_SUITE(TestHttpDate) { UNIT_ASSERT((int)strlen(format_http_date(0, buf1, sizeof(buf1))) == format_http_date(buf2, sizeof(buf2), 0)); } Y_UNIT_TEST(Test2) { - UNIT_ASSERT_STRINGS_EQUAL(FormatHttpDate(1234567890), "Fri, 13 Feb 2009 23:31:30 GMT"); - } + UNIT_ASSERT_STRINGS_EQUAL(FormatHttpDate(1234567890), "Fri, 13 Feb 2009 23:31:30 GMT"); + } } diff --git a/library/cpp/http/server/response.h b/library/cpp/http/server/response.h index 05a4d53caa..a75cb85605 100644 --- a/library/cpp/http/server/response.h +++ b/library/cpp/http/server/response.h @@ -51,10 +51,10 @@ public: return *this; } - TString GetContent() const { - return Content; - } - + TString GetContent() const { + return Content; + } + /** * @note If @arg content isn't empty its size is automatically added as a * "Content-Length" header during output to IOutputStream. |