diff options
author | msherbakov <msherbakov@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
commit | c224a621661ddd69699f9476922eb316607ef57e (patch) | |
tree | 33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/encode/format.cpp | |
parent | 29d0b2eeae154d04156e0698067c0c21a97ea61d (diff) | |
download | ydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz |
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/format.cpp')
-rw-r--r-- | library/cpp/monlib/encode/format.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/monlib/encode/format.cpp b/library/cpp/monlib/encode/format.cpp index 400ce5a643..8861e3dcc2 100644 --- a/library/cpp/monlib/encode/format.cpp +++ b/library/cpp/monlib/encode/format.cpp @@ -7,65 +7,65 @@ #include <util/string/cast.h> namespace NMonitoring { - static ECompression CompressionFromHeader(TStringBuf value) { - if (value.empty()) { - return ECompression::UNKNOWN; - } - - for (const auto& it : StringSplitter(value).Split(',').SkipEmpty()) { - TStringBuf token = StripString(it.Token()); - - if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::IDENTITY)) { - return ECompression::IDENTITY; - } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::ZLIB)) { - return ECompression::ZLIB; - } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::LZ4)) { - return ECompression::LZ4; - } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::ZSTD)) { - return ECompression::ZSTD; - } - } - - return ECompression::UNKNOWN; - } - - static EFormat FormatFromHttpMedia(TStringBuf value) { - if (AsciiEqualsIgnoreCase(value, NFormatContenType::SPACK)) { - return EFormat::SPACK; - } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::JSON)) { - return EFormat::JSON; - } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::PROTOBUF)) { - return EFormat::PROTOBUF; - } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::TEXT)) { - return EFormat::TEXT; + static ECompression CompressionFromHeader(TStringBuf value) { + if (value.empty()) { + return ECompression::UNKNOWN; + } + + for (const auto& it : StringSplitter(value).Split(',').SkipEmpty()) { + TStringBuf token = StripString(it.Token()); + + if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::IDENTITY)) { + return ECompression::IDENTITY; + } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::ZLIB)) { + return ECompression::ZLIB; + } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::LZ4)) { + return ECompression::LZ4; + } else if (AsciiEqualsIgnoreCase(token, NFormatContentEncoding::ZSTD)) { + return ECompression::ZSTD; + } + } + + return ECompression::UNKNOWN; + } + + static EFormat FormatFromHttpMedia(TStringBuf value) { + if (AsciiEqualsIgnoreCase(value, NFormatContenType::SPACK)) { + return EFormat::SPACK; + } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::JSON)) { + return EFormat::JSON; + } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::PROTOBUF)) { + return EFormat::PROTOBUF; + } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::TEXT)) { + return EFormat::TEXT; } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::PROMETHEUS)) { return EFormat::PROMETHEUS; } - return EFormat::UNKNOWN; - } - - EFormat FormatFromAcceptHeader(TStringBuf value) { - EFormat result{EFormat::UNKNOWN}; - + return EFormat::UNKNOWN; + } + + EFormat FormatFromAcceptHeader(TStringBuf value) { + EFormat result{EFormat::UNKNOWN}; + for (const auto& it : StringSplitter(value).Split(',').SkipEmpty()) { TStringBuf token = StripString(it.Token()); - result = FormatFromHttpMedia(token); - if (result != EFormat::UNKNOWN) { - break; + result = FormatFromHttpMedia(token); + if (result != EFormat::UNKNOWN) { + break; } } - return result; - } - - EFormat FormatFromContentType(TStringBuf value) { - value = value.NextTok(';'); - - return FormatFromHttpMedia(value); + return result; } + EFormat FormatFromContentType(TStringBuf value) { + value = value.NextTok(';'); + + return FormatFromHttpMedia(value); + } + TStringBuf ContentTypeByFormat(EFormat format) { switch (format) { case EFormat::SPACK: @@ -86,11 +86,11 @@ namespace NMonitoring { } ECompression CompressionFromAcceptEncodingHeader(TStringBuf value) { - return CompressionFromHeader(value); - } + return CompressionFromHeader(value); + } - ECompression CompressionFromContentEncodingHeader(TStringBuf value) { - return CompressionFromHeader(value); + ECompression CompressionFromContentEncodingHeader(TStringBuf value) { + return CompressionFromHeader(value); } TStringBuf ContentEncodingByCompression(ECompression compression) { |