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 | 9166d66c30c23c9e85a7c88185a068987148d23f (patch) | |
tree | 421bdcec5755d9e441c485560aab5ab8d74c7475 /library/cpp/http/io | |
parent | 8d3a5ed3a188a34167eaee54f1691ce5c9edf2f3 (diff) | |
download | ydb-9166d66c30c23c9e85a7c88185a068987148d23f.tar.gz |
Restoring authorship annotation for <myltsev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/io')
-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 |
4 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 4ec27a29e8..fe82383318 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 a71793d1c6..3b15d60462 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 6689be684f..90d063a4ba 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 1ea35df675..64b48b4a66 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"}; |