diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/http/io/headers.cpp | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/io/headers.cpp')
-rw-r--r-- | library/cpp/http/io/headers.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 4ec27a29e8..6358d23f01 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -1,10 +1,10 @@ #include "headers.h" #include "stream.h" -#include <util/generic/strbuf.h> +#include <util/generic/strbuf.h> #include <util/generic/yexception.h> -#include <util/stream/output.h> -#include <util/string/ascii.h> +#include <util/stream/output.h> +#include <util/string/ascii.h> #include <util/string/cast.h> #include <util/string/strip.h> @@ -12,25 +12,25 @@ static inline TStringBuf Trim(const char* b, const char* e) noexcept { return StripString(TStringBuf(b, e)); } -THttpInputHeader::THttpInputHeader(const TStringBuf header) { +THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); if (pos == TString::npos) { ythrow THttpParseException() << "can not parse http header(" << TString{header}.Quote() << ")"; } - Name_ = TString(header.cbegin(), header.cbegin() + pos); - Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); + Name_ = TString(header.cbegin(), header.cbegin() + pos); + Value_ = ::ToString(Trim(header.cbegin() + pos + 1, header.cend())); } -THttpInputHeader::THttpInputHeader(TString name, TString value) - : Name_(std::move(name)) - , Value_(std::move(value)) +THttpInputHeader::THttpInputHeader(TString name, TString value) + : Name_(std::move(name)) + , Value_(std::move(value)) { } -void THttpInputHeader::OutTo(IOutputStream* stream) const { - typedef IOutputStream::TPart TPart; +void THttpInputHeader::OutTo(IOutputStream* stream) const { + typedef IOutputStream::TPart TPart; const TPart parts[] = { TPart(Name_), @@ -42,7 +42,7 @@ void THttpInputHeader::OutTo(IOutputStream* stream) const { stream->Write(parts, sizeof(parts) / sizeof(*parts)); } -THttpHeaders::THttpHeaders(IInputStream* stream) { +THttpHeaders::THttpHeaders(IInputStream* stream) { TString header; TString line; @@ -53,28 +53,28 @@ THttpHeaders::THttpHeaders(IInputStream* stream) { if (rdOk && ((line[0] == ' ') || (line[0] == '\t'))) { header += line; } else { - AddHeader(THttpInputHeader(header)); + AddHeader(THttpInputHeader(header)); header = line; } } } -bool THttpHeaders::HasHeader(const TStringBuf header) const { +bool THttpHeaders::HasHeader(const TStringBuf header) const { return FindHeader(header); } -const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { +const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { for (const auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { + if (AsciiCompareIgnoreCase(hdr.Name(), header) == 0) { return &hdr; } } return nullptr; } -void THttpHeaders::RemoveHeader(const TStringBuf header) { - for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { - if (AsciiCompareIgnoreCase(h->Name(), header) == 0) { +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; } @@ -82,9 +82,9 @@ void THttpHeaders::RemoveHeader(const TStringBuf header) { } void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { - for (auto& hdr : Headers_) { - if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { - hdr = header; + for (auto& hdr : Headers_) { + if (AsciiCompareIgnoreCase(hdr.Name(), header.Name()) == 0) { + hdr = header; return; } } @@ -92,17 +92,17 @@ void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { AddHeader(header); } -void THttpHeaders::AddHeader(THttpInputHeader header) { - Headers_.push_back(std::move(header)); +void THttpHeaders::AddHeader(THttpInputHeader header) { + Headers_.push_back(std::move(header)); } -void THttpHeaders::OutTo(IOutputStream* stream) const { +void THttpHeaders::OutTo(IOutputStream* stream) const { for (TConstIterator header = Begin(); header != End(); ++header) { header->OutTo(stream); } } template <> -void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { +void Out<THttpHeaders>(IOutputStream& out, const THttpHeaders& h) { h.OutTo(&out); } |