diff options
author | lapshov <lapshov@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:39 +0300 |
commit | 1ef52da9919aaa7ec7e3c51da7fdaa637ab133b7 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp | |
parent | 4f36f44b1e216dca1f44ada8d126e7b70f05da2f (diff) | |
download | ydb-1ef52da9919aaa7ec7e3c51da7fdaa637ab133b7.tar.gz |
Restoring authorship annotation for <lapshov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
27 files changed, 344 insertions, 344 deletions
diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index aa387ef110..6dc997076d 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -5,7 +5,7 @@ #include <util/generic/intrlist.h> #include <util/generic/hash_set.h> #include <util/generic/vector.h> -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #include <utility> template <class TValue> @@ -57,7 +57,7 @@ public: struct THash { size_t operator()(const TItem& item) const { - return ::THash<TKey>()(item.Key); + return ::THash<TKey>()(item.Key); } }; }; @@ -427,7 +427,7 @@ public: TCache(TListType&& list, bool multiValue = false) : Index() , List(std::move(list)) - , MultiValue(multiValue) + , MultiValue(multiValue) { } @@ -435,10 +435,10 @@ public: Clear(); } - size_t Size() const { - return Index.size(); - } - + size_t Size() const { + return Index.size(); + } + TIterator Begin() const { return TIterator(Index.begin()); } @@ -458,28 +458,28 @@ public: return TIterator(Index.find(TItem(key))); } - // note: it shouldn't touch 'value' if it returns false. + // note: it shouldn't touch 'value' if it returns false. bool PickOut(const TKey& key, TValue* value) { Y_ASSERT(value); - TIndexIterator it = Index.find(TItem(key)); - if (it == Index.end()) - return false; - *value = it->Value; - List.Erase(const_cast<TItem*>(&*it)); - Index.erase(it); + TIndexIterator it = Index.find(TItem(key)); + if (it == Index.end()) + return false; + *value = it->Value; + List.Erase(const_cast<TItem*>(&*it)); + Index.erase(it); Y_ASSERT(Index.size() == List.GetSize()); - return true; - } - + return true; + } + bool Insert(const std::pair<TKey, TValue>& p) { return Insert(p.first, p.second); } bool Insert(const TKey& key, const TValue& value) { - TItem tmpItem(key, value); - if (!MultiValue && Index.find(tmpItem) != Index.end()) - return false; - TIndexIterator it = Index.insert(tmpItem); + TItem tmpItem(key, value); + if (!MultiValue && Index.find(tmpItem) != Index.end()) + return false; + TIndexIterator it = Index.insert(tmpItem); TItem* insertedItem = const_cast<TItem*>(&*it); auto removedItem = List.Insert(insertedItem); @@ -497,8 +497,8 @@ public: } void Update(const TKey& key, const TValue& value) { - if (MultiValue) - ythrow yexception() << "TCache: can't \"Update\" in multicache"; + if (MultiValue) + ythrow yexception() << "TCache: can't \"Update\" in multicache"; TIterator it = Find(key); if (it != End()) { Erase(it); @@ -548,23 +548,23 @@ public: protected: TIndex Index; TListType List; - bool MultiValue; + bool MultiValue; TIterator FindByItem(TItem* item) { std::pair<TIndexIterator, TIndexIterator> p = Index.equal_range(*item); - // we have to delete the exact unlinked item (there may be multiple items for one key) - TIndexIterator it; + // we have to delete the exact unlinked item (there may be multiple items for one key) + TIndexIterator it; for (it = p.first; it != p.second; ++it) - if (&*it == item) - break; + if (&*it == item) + break; return (it == p.second ? End() : TIterator(it)); - } - + } + void EraseFromIndex(TItem* item) { TDeleter::Destroy(item->Value); - TIterator it = FindByItem(item); + TIterator it = FindByItem(item); Y_ASSERT(it != End()); - Index.erase(it.Iter); + Index.erase(it.Iter); } }; @@ -579,7 +579,7 @@ class TLRUCache: public TCache<TKey, TValue, TLRUList<TKey, TValue, TSizeProvide using TListType = TLRUList<TKey, TValue, TSizeProvider>; typedef TCache<TKey, TValue, TListType, TDeleter> TBase; -public: +public: TLRUCache(size_t maxSize, bool multiValue = false, const TSizeProvider& sizeProvider = TSizeProvider()) : TBase(TListType(maxSize, sizeProvider), multiValue) { @@ -591,10 +591,10 @@ public: TValue& GetOldest() { return TBase::List.GetOldest()->Value; } - - TIterator FindOldest() { + + TIterator FindOldest() { return TBase::Empty() ? TBase::End() : this->FindByItem(TBase::List.GetOldest()); - } + } size_t TotalSize() const { return TBase::List.GetTotalSize(); diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index 3f54a232a0..329872cfde 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -313,17 +313,17 @@ Y_UNIT_TEST_SUITE(TCacheTest) { Y_UNIT_TEST(MultiCacheTest) { typedef TLRUCache<int, TString> TCache; - TCache s(3, true); - UNIT_ASSERT(s.Insert(1, "abcd")); - UNIT_ASSERT(s.Insert(1, "bcde")); - UNIT_ASSERT(s.Insert(2, "fghi")); - UNIT_ASSERT(s.Insert(2, "ghij")); - // (1, "abcd") will be deleted - UNIT_ASSERT(*s.Find(1) == "bcde"); - // (1, "bcde") will be promoted - UNIT_ASSERT(*s.FindOldest() == "fghi"); + TCache s(3, true); + UNIT_ASSERT(s.Insert(1, "abcd")); + UNIT_ASSERT(s.Insert(1, "bcde")); + UNIT_ASSERT(s.Insert(2, "fghi")); + UNIT_ASSERT(s.Insert(2, "ghij")); + // (1, "abcd") will be deleted + UNIT_ASSERT(*s.Find(1) == "bcde"); + // (1, "bcde") will be promoted + UNIT_ASSERT(*s.FindOldest() == "fghi"); } - + struct TMyDelete { static int count; template <typename T> diff --git a/library/cpp/charset/doccodes.h b/library/cpp/charset/doccodes.h index 2181aeb4c9..75c87adf9e 100644 --- a/library/cpp/charset/doccodes.h +++ b/library/cpp/charset/doccodes.h @@ -49,7 +49,7 @@ enum ECharset { CODES_CP1129, CODES_CP1131, CODES_CP1133, - CODES_CP1161, // [40] + CODES_CP1161, // [40] CODES_CP1162, CODES_CP1163, CODES_CP1258, @@ -59,7 +59,7 @@ enum ECharset { CODES_CP850, CODES_CP852, CODES_CP853, - CODES_CP856, // [50] + CODES_CP856, // [50] CODES_CP857, CODES_CP858, CODES_CP860, @@ -69,7 +69,7 @@ enum ECharset { CODES_CP864, CODES_CP865, CODES_CP869, - CODES_CP874, // [60] + CODES_CP874, // [60] CODES_CP922, CODES_HP_ROMAN8, CODES_ISO646_CN, @@ -79,7 +79,7 @@ enum ECharset { CODES_ISO8859_14, CODES_JISX0201, CODES_KOI8_T, - CODES_MAC_ARABIC, // [70] + CODES_MAC_ARABIC, // [70] CODES_MAC_CENTRALEUROPE, CODES_MAC_CROATIAN, CODES_MAC_GREEK, @@ -89,7 +89,7 @@ enum ECharset { CODES_MAC_ROMAN, CODES_MAC_THAI, CODES_MAC_TURKISH, - CODES_RESERVED_2, // [80] reserved code: use it for new encodings before adding them to the end of the list + CODES_RESERVED_2, // [80] reserved code: use it for new encodings before adding them to the end of the list CODES_MULELAO, CODES_NEXTSTEP, CODES_PT154, @@ -101,7 +101,7 @@ enum ECharset { CODES_VISCII, // libiconv multibyte codepages - CODES_BIG5, // [90] + CODES_BIG5, // [90] CODES_BIG5_HKSCS, CODES_BIG5_HKSCS_1999, CODES_BIG5_HKSCS_2001, @@ -111,7 +111,7 @@ enum ECharset { CODES_CP950, CODES_EUC_CN, CODES_EUC_JP, - CODES_EUC_KR, // [100] + CODES_EUC_KR, // [100] CODES_EUC_TW, CODES_GB18030, CODES_GBK, @@ -121,7 +121,7 @@ enum ECharset { CODES_ISO_2022_JP, CODES_ISO_2022_JP_1, CODES_ISO_2022_JP_2, - CODES_ISO_2022_KR, // [110] + CODES_ISO_2022_KR, // [110] CODES_JOHAB, CODES_SHIFT_JIS, diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index dd683bc96f..f273fa6571 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -453,10 +453,10 @@ bool TCompactTrieBuilder<T, D, S>::Find(const TSymbol* key, size_t keylen, TData template <class T, class D, class S> bool TCompactTrieBuilder<T, D, S>::FindLongestPrefix( const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const { - return Impl->FindLongestPrefix(key, keylen, prefixlen, value); -} - -template <class T, class D, class S> + return Impl->FindLongestPrefix(key, keylen, prefixlen, value); +} + +template <class T, class D, class S> size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const { return Impl->Save(os); } @@ -686,8 +686,8 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindEntryImpl(const template <class T, class D, class S> bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefix( const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const { - using namespace NCompactTrie; - + using namespace NCompactTrie; + if (!keylen) { const char zero = '\0'; const bool ret = FindLongestPrefixImpl(&zero, 1, prefixlen, value); @@ -703,14 +703,14 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefix( *prefixlen = 0; // if we have found empty key, set prefixlen to zero else if (!ret) // try to find value with empty key, because empty key is prefix of a every key ret = FindLongestPrefix(nullptr, 0, prefixlen, value); - + if (ret && prefixlen) *prefixlen /= sizeof(TSymbol); - + return ret; - } + } } - + template <class T, class D, class S> bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefixImpl(const char* keyptr, size_t keylen, size_t* prefixLen, TData* value) const { const TNode* node = Root; @@ -722,24 +722,24 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefixImp while (keyTail && (node = node->Subtree()->FindLongestPrefix(keyTail, value, endResult, Packer))) { if (endResult) // no more ways to find prefix and prefix has been found break; - + if (node->IsFinal()) { lastFinalNode = node; lastFinalKeyTail = keyTail; - } - } + } + } if (!endResult && lastFinalNode) { - if (value) + if (value) Packer.UnpackLeaf(lastFinalNode->GetPayload(), *value); keyTail = lastFinalKeyTail; endResult = true; - } + } if (endResult && prefixLen) *prefixLen = keyTail ? key.size() - keyTail.size() : key.size(); return endResult; -} - -template <class T, class D, class S> +} + +template <class T, class D, class S> void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Clear() { DestroyNode(Root); Pool.Clear(); diff --git a/library/cpp/http/fetch/exthttpcodes.cpp b/library/cpp/http/fetch/exthttpcodes.cpp index ce9d683412..acc05650c8 100644 --- a/library/cpp/http/fetch/exthttpcodes.cpp +++ b/library/cpp/http/fetch/exthttpcodes.cpp @@ -158,8 +158,8 @@ static ui16* prepare_flags(http_flag* arg) { // для стандартных кодов ошибок берем флаги из первого кода каждой группы и проставляем их // всем кодам не перечисленным в таблице выше - for (size_t group = 0; group < 1000; group += 100) - for (size_t j = group + 1; j < group + 100; ++j) + for (size_t group = 0; group < 1000; group += 100) + for (size_t j = group + 1; j < group + 100; ++j) flags[j] = flags[group]; // предыдущий цикл затер некоторые флаги перечисленные в таблице выше @@ -171,12 +171,12 @@ static ui16* prepare_flags(http_flag* arg) { } ui16* http2status = prepare_flags(HTTP_FLAG); - + TStringBuf ExtHttpCodeStr(int code) noexcept { - if (code < HTTP_CODE_MAX) { + if (code < HTTP_CODE_MAX) { return HttpCodeStr(code); - } - switch (code) { + } + switch (code) { case HTTP_BAD_RESPONSE_HEADER: return TStringBuf("Bad response header"); case HTTP_CONNECTION_LOST: @@ -257,10 +257,10 @@ TStringBuf ExtHttpCodeStr(int code) noexcept { return TStringBuf("Cached copy for the url is not available"); case HTTP_TIMEDOUT_WHILE_BYTES_RECEIVING: return TStringBuf("Timed out while bytes receiving"); - + // TODO: messages for >2000 codes - + default: return TStringBuf("Unknown HTTP code"); - } -} + } +} diff --git a/library/cpp/http/fetch/exthttpcodes.h b/library/cpp/http/fetch/exthttpcodes.h index a6a0aa31be..6b525052cd 100644 --- a/library/cpp/http/fetch/exthttpcodes.h +++ b/library/cpp/http/fetch/exthttpcodes.h @@ -4,7 +4,7 @@ #include <library/cpp/http/misc/httpcodes.h> enum ExtHttpCodes { - // Custom + // Custom HTTP_EXTENDED = 1000, HTTP_BAD_RESPONSE_HEADER = 1000, HTTP_CONNECTION_LOST = 1001, @@ -137,5 +137,5 @@ static inline int Http2Status(int code) { extern ui16* http2status; return http2status[code & (EXT_HTTP_CODE_MAX - 1)]; } - + TStringBuf ExtHttpCodeStr(int code) noexcept; diff --git a/library/cpp/http/fetch/httpfetcher.h b/library/cpp/http/fetch/httpfetcher.h index 8e1efdc0c2..7fc251afd2 100644 --- a/library/cpp/http/fetch/httpfetcher.h +++ b/library/cpp/http/fetch/httpfetcher.h @@ -52,7 +52,7 @@ public: THttpParser<TCheck>::Init(header, head_request); const char* scheme = HttpUrlSchemeKindToString((THttpURL::TSchemeKind)TAgent::GetScheme()); - size_t schemelen = strlen(scheme); + size_t schemelen = strlen(scheme); if (*path == '/') { header->base = TStringBuf(scheme, schemelen); header->base += TStringBuf("://", 3); @@ -123,8 +123,8 @@ public: header->error = HTTP_HEADER_TOO_LARGE; break; } - } - if (!inheader) { + } + if (!inheader) { maxsize = TCheck::GetMaxBodySize(header); } if (header->http_status >= HTTP_EXTENDED) diff --git a/library/cpp/http/fetch/httpfsm.h b/library/cpp/http/fetch/httpfsm.h index 9d4262f88f..c4abdcd0d2 100644 --- a/library/cpp/http/fetch/httpfsm.h +++ b/library/cpp/http/fetch/httpfsm.h @@ -5,8 +5,8 @@ #include <util/system/maxlen.h> #include <util/datetime/parser.h> -#include <time.h> - +#include <time.h> + struct THttpHeaderParser { static constexpr int ErrFirstlineTypeMismatch = -3; static constexpr int ErrHeader = -2; diff --git a/library/cpp/http/fetch/httpfsm.rl6 b/library/cpp/http/fetch/httpfsm.rl6 index 79fc390efb..eab0328b18 100644 --- a/library/cpp/http/fetch/httpfsm.rl6 +++ b/library/cpp/http/fetch/httpfsm.rl6 @@ -128,8 +128,8 @@ connection = "connection"i def %beg_connection c_tokenlist eoh %set_connect ################# content-encoding ################ action beg_content_encoding { I = HTTP_COMPRESSION_ERROR; } action set_content_encoding { base_hd->compression_method = - ((base_hd->compression_method == HTTP_COMPRESSION_UNSET || - base_hd->compression_method == I) ? + ((base_hd->compression_method == HTTP_COMPRESSION_UNSET || + base_hd->compression_method == I) ? I : (int)HTTP_COMPRESSION_ERROR); } ce_tokenlist = "identity"i %{c(HTTP_COMPRESSION_IDENTITY)} @@ -189,49 +189,49 @@ action set_charset { } } -mime_type = "text/plain"i %{c(MIME_TEXT)} - | "text/html"i %{c(MIME_HTML)} - | "application/pdf"i %{c(MIME_PDF)} - | "application/rtf"i %{c(MIME_RTF)} - | "text/rtf"i %{c(MIME_RTF)} - | "application/msword"i %{c(MIME_DOC)} - | "audio/mpeg"i %{c(MIME_MPEG)} - | "text/xml"i %{c(MIME_XML)} - | "application/xml"i %{c(MIME_XML)} - | "application/rss+xml"i %{c(MIME_RSS)} - | "application/rdf+xml"i %{c(MIME_RSS)} - | "application/atom+xml"i %{c(MIME_RSS)} - | "text/vnd.wap.wml"i %{c(MIME_WML)} - | "application/x-shockwave-flash"i %{c(MIME_SWF)} - | "application/vnd.ms-excel"i %{c(MIME_XLS)} - | "application/vnd.ms-powerpoint"i %{c(MIME_PPT)} - | "image/jpeg"i %{c(MIME_IMAGE_JPG)} - | "image/jpg"i %{c(MIME_IMAGE_JPG)} - | "image/pjpeg"i %{c(MIME_IMAGE_PJPG)} - | "image/png"i %{c(MIME_IMAGE_PNG)} - | "image/gif"i %{c(MIME_IMAGE_GIF)} - | "application/xhtml+xml"i %{c(MIME_XHTMLXML)} - | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"i %{c(MIME_DOCX)} - | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"i %{c(MIME_XLSX)} - | "application/vnd.openxmlformats-officedocument.presentationml.presentation"i %{c(MIME_PPTX)} - | "application/vnd.oasis.opendocument.text"i %{c(MIME_ODT)} - | "application/vnd.oasis.opendocument.presentation"i %{c(MIME_ODP)} - | "application/vnd.oasis.opendocument.spreadsheet"i %{c(MIME_ODS)} - | "application/vnd.oasis.opendocument.graphics"i %{c(MIME_ODG)} - | "image/x-ms-bmp"i %{c(MIME_IMAGE_BMP)} - | "image/bmp"i %{c(MIME_IMAGE_BMP)} - | "audio/x-wav"i %{c(MIME_WAV)} - | ( "application/x-tar"i | "application/x-ustar"i | "application/x-gtar"i | "application/zip"i | "application/x-archive"i - | "application/x-bzip2"i | "application/x-rar"i ) %{c(MIME_ARCHIVE)} - | "application/x-dosexec"i %{c(MIME_EXE)} +mime_type = "text/plain"i %{c(MIME_TEXT)} + | "text/html"i %{c(MIME_HTML)} + | "application/pdf"i %{c(MIME_PDF)} + | "application/rtf"i %{c(MIME_RTF)} + | "text/rtf"i %{c(MIME_RTF)} + | "application/msword"i %{c(MIME_DOC)} + | "audio/mpeg"i %{c(MIME_MPEG)} + | "text/xml"i %{c(MIME_XML)} + | "application/xml"i %{c(MIME_XML)} + | "application/rss+xml"i %{c(MIME_RSS)} + | "application/rdf+xml"i %{c(MIME_RSS)} + | "application/atom+xml"i %{c(MIME_RSS)} + | "text/vnd.wap.wml"i %{c(MIME_WML)} + | "application/x-shockwave-flash"i %{c(MIME_SWF)} + | "application/vnd.ms-excel"i %{c(MIME_XLS)} + | "application/vnd.ms-powerpoint"i %{c(MIME_PPT)} + | "image/jpeg"i %{c(MIME_IMAGE_JPG)} + | "image/jpg"i %{c(MIME_IMAGE_JPG)} + | "image/pjpeg"i %{c(MIME_IMAGE_PJPG)} + | "image/png"i %{c(MIME_IMAGE_PNG)} + | "image/gif"i %{c(MIME_IMAGE_GIF)} + | "application/xhtml+xml"i %{c(MIME_XHTMLXML)} + | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"i %{c(MIME_DOCX)} + | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"i %{c(MIME_XLSX)} + | "application/vnd.openxmlformats-officedocument.presentationml.presentation"i %{c(MIME_PPTX)} + | "application/vnd.oasis.opendocument.text"i %{c(MIME_ODT)} + | "application/vnd.oasis.opendocument.presentation"i %{c(MIME_ODP)} + | "application/vnd.oasis.opendocument.spreadsheet"i %{c(MIME_ODS)} + | "application/vnd.oasis.opendocument.graphics"i %{c(MIME_ODG)} + | "image/x-ms-bmp"i %{c(MIME_IMAGE_BMP)} + | "image/bmp"i %{c(MIME_IMAGE_BMP)} + | "audio/x-wav"i %{c(MIME_WAV)} + | ( "application/x-tar"i | "application/x-ustar"i | "application/x-gtar"i | "application/zip"i | "application/x-archive"i + | "application/x-bzip2"i | "application/x-rar"i ) %{c(MIME_ARCHIVE)} + | "application/x-dosexec"i %{c(MIME_EXE)} | "application/x-gzip"i %{c(MIME_GZIP)} | "application/json"i %{c(MIME_JSON)} | ("application/javascript"i | "text/javascript"i) %{c(MIME_JAVASCRIPT)} | "application/vnd.android.package-archive"i %{c(MIME_APK)} | ("image/x-icon"i | "image/vnd.microsoft.icon"i) %{c(MIME_IMAGE_ICON)} ; - - + + charset_name = token_char+ >clear_buf $update_buf; mime_param = "charset"i ws* '=' ws* '"'? charset_name '"'? %set_charset @2 | token ws* '=' ws* '"'? token '"'? @1 @@ -249,9 +249,9 @@ last_modified = "last-modified"i def %beg_modtime http_date eoh %set_modtime; ################# location ######################## action set_location { - while (buflen > 0 && (buf[buflen - 1] == ' ' || buf[buflen - 1] == '\t')) { - buflen --; - } + while (buflen > 0 && (buf[buflen - 1] == ' ' || buf[buflen - 1] == '\t')) { + buflen --; + } if (hd && buflen < FETCHER_URL_MAX) { hd->location = TStringBuf(buf, buflen); } @@ -259,34 +259,34 @@ action set_location { action set_status_303{ if (hd) hd->http_status = 303; } -url = url_char+ >clear_buf $update_buf; -loc_url = any_text_char+ >clear_buf $update_buf; -location = "location"i def loc_url eoh %set_location; +url = url_char+ >clear_buf $update_buf; +loc_url = any_text_char+ >clear_buf $update_buf; +location = "location"i def loc_url eoh %set_location; refresh = "refresh"i def int ';' lws "url="i loc_url eoh %set_location; ################# x-robots-tag ################ action set_x_robots { if (hd && AcceptingXRobots) { - if (I > 0) - hd->x_robots_tag |= I; - - int pos = (I > 0 ? I : -I); - for (size_t i = 0; i < 5; ++i) - if (abs(pos) & (1 << i)) // permissive flags take priority - hd->x_robots_state[i] = (I < 0) ? '1' : (hd->x_robots_state[i] != '1') ? '0' : '1'; - } + if (I > 0) + hd->x_robots_tag |= I; + + int pos = (I > 0 ? I : -I); + for (size_t i = 0; i < 5; ++i) + if (abs(pos) & (1 << i)) // permissive flags take priority + hd->x_robots_state[i] = (I < 0) ? '1' : (hd->x_robots_state[i] != '1') ? '0' : '1'; + } } action accept_x_robots { AcceptingXRobots = (bool)I; } -x_robots_directive = "none"i %{c(3)} | "all"i %{c(-3)} - | "noindex"i %{c(1)} | "index"i %{c(-1)} - | "nofollow"i %{c(2)} | "follow"i %{c(-2)} - | "noarchive"i %{c(4)} | "archive"i %{c(-4)} +x_robots_directive = "none"i %{c(3)} | "all"i %{c(-3)} + | "noindex"i %{c(1)} | "index"i %{c(-1)} + | "nofollow"i %{c(2)} | "follow"i %{c(-2)} + | "noarchive"i %{c(4)} | "archive"i %{c(-4)} | "noyaca"i %{c(16)} - | "noodp"i %{c(8)}; + | "noodp"i %{c(8)}; any_value = (any_text_char - [, \t])+ (lws (any_text_char - [, \t])+)*; any_key = (any_text_char - [:, \t])+ (lws (any_text_char - [:, \t])+)*; @@ -311,12 +311,12 @@ action set_canonical { rel_canonical = "link"i def '<' url ">;"i lws "rel"i lws '=' lws "\"canonical\"" eoh %set_canonical; ################# hreflang ############### action set_hreflang { - bool first = (hreflangpos == hd->hreflangs); + bool first = (hreflangpos == hd->hreflangs); size_t len2 = (first ? 0 : 1) + langlen + 1 + buflen; if (langlen && len2 < hreflangspace) { - if (!first) { - *(hreflangpos++) = '\t'; - } + if (!first) { + *(hreflangpos++) = '\t'; + } memcpy(hreflangpos, langstart, langlen); hreflangpos += langlen; *(hreflangpos++) = ' '; @@ -342,13 +342,13 @@ hreflang = "link"i def '<' url '>' lws ";" lws ( ( "rel"i lws '=' lws quote "alternate" quote lws ';' lws "hreflang"i lws '=' lws quote lang quote ) | ( "hreflang"i lws '=' lws quote lang quote lws ';' lws "rel"i lws '=' lws quote "alternate" quote ) ) eoh %set_hreflang; -################# squid_error ################# -action set_squid_error { - hd->squid_error = 1; -} - -squid_error = "X-Yandex-Squid-Error"i def any_text eoh %set_squid_error; - +################# squid_error ################# +action set_squid_error { + hd->squid_error = 1; +} + +squid_error = "X-Yandex-Squid-Error"i def any_text eoh %set_squid_error; + ################# auth ######################## action init_auth { if (auth_hd) @@ -441,20 +441,20 @@ action set_user_agent { user_agent = any_text_char* >clear_buf $update_buf; user_agent_header = "user-agent"i def user_agent eoh %set_user_agent; -############### x-yandex-langregion ################ -action set_langregion { - if (request_hd && buflen < MAX_LANGREGION_LEN) { - buf[buflen++] = 0; - if (request_hd->x_yandex_langregion[0] != 0) { - return -2; - } - memcpy(request_hd->x_yandex_langregion, buf, buflen); - } -} - -langregion = any_text_char* >clear_buf $update_buf; -langregion_header = "x-yandex-langregion"i def langregion eoh %set_langregion; - +############### x-yandex-langregion ################ +action set_langregion { + if (request_hd && buflen < MAX_LANGREGION_LEN) { + buf[buflen++] = 0; + if (request_hd->x_yandex_langregion[0] != 0) { + return -2; + } + memcpy(request_hd->x_yandex_langregion, buf, buflen); + } +} + +langregion = any_text_char* >clear_buf $update_buf; +langregion_header = "x-yandex-langregion"i def langregion eoh %set_langregion; + ############### x-yandex-sourcename ################ action set_sourcename { if (request_hd && buflen < MAXWORD_LEN) { @@ -469,34 +469,34 @@ action set_sourcename { sourcename = any_text_char* >clear_buf $update_buf; sourcename_header = "x-yandex-sourcename"i def sourcename eoh %set_sourcename; -############### x-yandex-requesttype ############### -action set_requesttype { - if (request_hd && buflen < MAXWORD_LEN) { - buf[buflen++] = 0; - if (request_hd->x_yandex_requesttype[0] != 0) { - return -2; - } - memcpy(request_hd->x_yandex_requesttype, buf, buflen); - } -} - -requesttype = any_text_char* >clear_buf $update_buf; -requesttype_header = "x-yandex-requesttype"i def requesttype eoh %set_requesttype; - -################ x-yandex-fetchoptions ############### -action set_fetchoptions { - if (request_hd && buflen < MAXWORD_LEN) { - buf[buflen++] = 0; - if (request_hd->x_yandex_fetchoptions[0] != 0) { - return -2; - } - memcpy(request_hd->x_yandex_fetchoptions, buf, buflen); - } -} - -fetchoptions = any_text_char* >clear_buf $update_buf; -fetchoptions_header = "x-yandex-fetchoptions"i def fetchoptions eoh %set_fetchoptions; - +############### x-yandex-requesttype ############### +action set_requesttype { + if (request_hd && buflen < MAXWORD_LEN) { + buf[buflen++] = 0; + if (request_hd->x_yandex_requesttype[0] != 0) { + return -2; + } + memcpy(request_hd->x_yandex_requesttype, buf, buflen); + } +} + +requesttype = any_text_char* >clear_buf $update_buf; +requesttype_header = "x-yandex-requesttype"i def requesttype eoh %set_requesttype; + +################ x-yandex-fetchoptions ############### +action set_fetchoptions { + if (request_hd && buflen < MAXWORD_LEN) { + buf[buflen++] = 0; + if (request_hd->x_yandex_fetchoptions[0] != 0) { + return -2; + } + memcpy(request_hd->x_yandex_fetchoptions, buf, buflen); + } +} + +fetchoptions = any_text_char* >clear_buf $update_buf; +fetchoptions_header = "x-yandex-fetchoptions"i def fetchoptions eoh %set_fetchoptions; + ################ if-modified-since ################ action set_if_modified_since { if (request_hd) { @@ -576,7 +576,7 @@ message_header = other_header $0 response_header = message_header $0 | auth @1 | accept_ranges @1 - | location @1 + | location @1 | x_robots_tag @1 | rel_canonical @1 | hreflang @1 @@ -588,9 +588,9 @@ request_header = message_header $0 | host_header @1 | user_agent_header @1 | sourcename_header @1 - | requesttype_header @1 - | langregion_header @1 - | fetchoptions_header @1 + | requesttype_header @1 + | langregion_header @1 + | fetchoptions_header @1 | if_modified_since @1 | request_cache_control @1 | response_timeout @1 diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp index 05fede5a02..b018e80101 100644 --- a/library/cpp/http/fetch/httpfsm_ut.cpp +++ b/library/cpp/http/fetch/httpfsm_ut.cpp @@ -17,19 +17,19 @@ class THttpHeaderParserTestSuite: public TTestBase { UNIT_TEST(TestLastModifiedCorrupted); UNIT_TEST(TestResponseHeaderOnRequest); UNIT_TEST(TestRequestHeaderOnResponse); - UNIT_TEST(TestXRobotsTagUnknownTags); + UNIT_TEST(TestXRobotsTagUnknownTags); UNIT_TEST(TestXRobotsTagMyBot); UNIT_TEST(TestXRobotsTagOtherBot); UNIT_TEST(TestXRobotsTagUnavailableAfterAware); UNIT_TEST(TestXRobotsTagUnavailableAfterWorks); - UNIT_TEST(TestXRobotsTagOverridePriority); + UNIT_TEST(TestXRobotsTagOverridePriority); UNIT_TEST(TestXRobotsTagDoesNotBreakCharset); UNIT_TEST(TestXRobotsTagAllowsMultiline); UNIT_TEST(TestRelCanonical); UNIT_TEST(TestHreflang); UNIT_TEST(TestHreflangOnLongInput); UNIT_TEST(TestMimeType); - UNIT_TEST(TestRepeatedContentEncoding); + UNIT_TEST(TestRepeatedContentEncoding); UNIT_TEST_SUITE_END(); private: @@ -49,19 +49,19 @@ public: void TestLastModifiedCorrupted(); void TestResponseHeaderOnRequest(); void TestRequestHeaderOnResponse(); - void TestXRobotsTagUnknownTags(); + void TestXRobotsTagUnknownTags(); void TestXRobotsTagMyBot(); void TestXRobotsTagOtherBot(); void TestXRobotsTagUnavailableAfterAware(); void TestXRobotsTagUnavailableAfterWorks(); - void TestXRobotsTagOverridePriority(); + void TestXRobotsTagOverridePriority(); void TestXRobotsTagDoesNotBreakCharset(); void TestXRobotsTagAllowsMultiline(); void TestRelCanonical(); void TestHreflang(); void TestHreflangOnLongInput(); void TestMimeType(); - void TestRepeatedContentEncoding(); + void TestRepeatedContentEncoding(); }; void THttpHeaderParserTestSuite::TestStart() { @@ -91,8 +91,8 @@ void THttpHeaderParserTestSuite::TestRequestHeader() { UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority, DEFAULT_REQUEST_PRIORITY); UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, ""), 0); - UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, ""), 0); - UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, ""), 0); + UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, ""), 0); + UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, ""), 0); TestFinish(); UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, DEFAULT_MAX_AGE); } @@ -161,8 +161,8 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() { "X-Yandex-Response-Timeout: 1000\r\n" "X-Yandex-Request-Priority: 2\r\n" "X-Yandex-Sourcename: orange\r\n" - "X-Yandex-Requesttype: userproxy\r\n" - "X-Yandex-FetchOptions: d;c\r\n" + "X-Yandex-Requesttype: userproxy\r\n" + "X-Yandex-FetchOptions: d;c\r\n" "Cache-control: max-age=100\r\n" "If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT\r\n" "User-Agent: Yandex/1.01.001 (compatible; Win16; I)\r\n" @@ -172,9 +172,9 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() { UNIT_ASSERT_EQUAL(httpRequestHeader.http_method, HTTP_METHOD_GET); UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_response_timeout, 1000); UNIT_ASSERT_EQUAL(httpRequestHeader.x_yandex_request_priority, 2); - UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, "orange"), 0); - UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, "userproxy"), 0); - UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, "d;c"), 0); + UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_sourcename, "orange"), 0); + UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_requesttype, "userproxy"), 0); + UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, "d;c"), 0); UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, 100); UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since, TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT()); @@ -231,7 +231,7 @@ void THttpHeaderParserTestSuite::TestLastModifiedCorrupted() { TestFinish(); } -void THttpHeaderParserTestSuite::TestXRobotsTagUnknownTags() { +void THttpHeaderParserTestSuite::TestXRobotsTagUnknownTags() { TestStart(); THttpHeader httpHeader; httpHeaderParser->Init(&httpHeader); @@ -312,21 +312,21 @@ void THttpHeaderParserTestSuite::TestXRobotsTagUnavailableAfterWorks() { TestFinish(); } -void THttpHeaderParserTestSuite::TestXRobotsTagOverridePriority() { - TestStart(); - THttpHeader httpHeader; - httpHeaderParser->Init(&httpHeader); - const char* headers = - "HTTP/1.1 200 OK\r\n" - "Content-Type: text/html\r\n" - "x-robots-tag: all, none\r\n\r\n"; - i32 result = httpHeaderParser->Execute(headers, strlen(headers)); - UNIT_ASSERT_EQUAL(result, 2); - UNIT_ASSERT_EQUAL(httpHeader.x_robots_state, "11xxx"); - UNIT_ASSERT_EQUAL(httpHeader.x_robots_tag, 3); // NOTE legacy behavior, should be 0 as `all` overrides - TestFinish(); -} - +void THttpHeaderParserTestSuite::TestXRobotsTagOverridePriority() { + TestStart(); + THttpHeader httpHeader; + httpHeaderParser->Init(&httpHeader); + const char* headers = + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html\r\n" + "x-robots-tag: all, none\r\n\r\n"; + i32 result = httpHeaderParser->Execute(headers, strlen(headers)); + UNIT_ASSERT_EQUAL(result, 2); + UNIT_ASSERT_EQUAL(httpHeader.x_robots_state, "11xxx"); + UNIT_ASSERT_EQUAL(httpHeader.x_robots_tag, 3); // NOTE legacy behavior, should be 0 as `all` overrides + TestFinish(); +} + void THttpHeaderParserTestSuite::TestXRobotsTagDoesNotBreakCharset() { TestStart(); THttpHeader httpHeader; @@ -394,7 +394,7 @@ void THttpHeaderParserTestSuite::TestHreflang() { i32 result = httpHeaderParser->Execute(headers, strlen(headers)); UNIT_ASSERT_VALUES_EQUAL(result, 2); // UNIT_ASSERT_VALUES_EQUAL(strcmp(httpHeader.hreflangs, "x-default http://www.high.ru/;"), 0); - UNIT_ASSERT_VALUES_EQUAL(httpHeader.hreflangs, "x-default http://www.high.ru/\ten_GB http://www.high.ru/en.html\tru_RU.KOI8-r http://www.high.ru/ru.html"); + UNIT_ASSERT_VALUES_EQUAL(httpHeader.hreflangs, "x-default http://www.high.ru/\ten_GB http://www.high.ru/en.html\tru_RU.KOI8-r http://www.high.ru/ru.html"); TestFinish(); } @@ -461,31 +461,31 @@ void THttpHeaderParserTestSuite::TestMimeType() { TestFinish(); } -void THttpHeaderParserTestSuite::TestRepeatedContentEncoding() { - TestStart(); - THttpHeader httpHeader; - httpHeaderParser->Init(&httpHeader); - const char *headers = - "HTTP/1.1 200 OK\r\n" - "Server: nginx\r\n" - "Date: Mon, 15 Oct 2018 10:40:44 GMT\r\n" - "Content-Type: text/plain\r\n" - "Transfer-Encoding: chunked\r\n" - "Connection: keep-alive\r\n" - "Last-Modified: Mon, 15 Oct 2018 03:48:54 GMT\r\n" - "ETag: W/\"5bc40e26-a956d\"\r\n" - "X-Autoru-LB: lb-03-sas.prod.vertis.yandex.net\r\n" - "Content-Encoding: gzip\r\n" - "Content-Encoding: gzip\r\n" - "X-UA-Bot: 1\r\n" - "\r\n"; - i32 result = httpHeaderParser->Execute(headers, strlen(headers)); - UNIT_ASSERT_EQUAL(result, 2); - UNIT_ASSERT_EQUAL(httpHeader.error, 0); - UNIT_ASSERT_EQUAL(httpHeader.compression_method, 3); - TestFinish(); -} - +void THttpHeaderParserTestSuite::TestRepeatedContentEncoding() { + TestStart(); + THttpHeader httpHeader; + httpHeaderParser->Init(&httpHeader); + const char *headers = + "HTTP/1.1 200 OK\r\n" + "Server: nginx\r\n" + "Date: Mon, 15 Oct 2018 10:40:44 GMT\r\n" + "Content-Type: text/plain\r\n" + "Transfer-Encoding: chunked\r\n" + "Connection: keep-alive\r\n" + "Last-Modified: Mon, 15 Oct 2018 03:48:54 GMT\r\n" + "ETag: W/\"5bc40e26-a956d\"\r\n" + "X-Autoru-LB: lb-03-sas.prod.vertis.yandex.net\r\n" + "Content-Encoding: gzip\r\n" + "Content-Encoding: gzip\r\n" + "X-UA-Bot: 1\r\n" + "\r\n"; + i32 result = httpHeaderParser->Execute(headers, strlen(headers)); + UNIT_ASSERT_EQUAL(result, 2); + UNIT_ASSERT_EQUAL(httpHeader.error, 0); + UNIT_ASSERT_EQUAL(httpHeader.compression_method, 3); + TestFinish(); +} + UNIT_TEST_SUITE_REGISTRATION(THttpHeaderParserTestSuite); Y_UNIT_TEST_SUITE(TestHttpChunkParser) { diff --git a/library/cpp/http/fetch/httpheader.h b/library/cpp/http/fetch/httpheader.h index ef4519ead4..b2810bbd41 100644 --- a/library/cpp/http/fetch/httpheader.h +++ b/library/cpp/http/fetch/httpheader.h @@ -5,9 +5,9 @@ #include <library/cpp/mime/types/mime.h> #include <util/system/defaults.h> -#include <util/system/compat.h> +#include <util/system/compat.h> #include <util/generic/string.h> -#include <util/generic/ylimits.h> +#include <util/generic/ylimits.h> #include <util/system/maxlen.h> #include <ctime> @@ -26,9 +26,9 @@ extern const i8 DEFAULT_REQUEST_PRIORITY; /// == -1 extern const i32 DEFAULT_RESPONSE_TIMEOUT; /// == -1 #define HTTP_PREFIX "http://" -#define MAX_LANGREGION_LEN 4 +#define MAX_LANGREGION_LEN 4 #define MAXWORD_LEN 55 - + enum HTTP_COMPRESSION { HTTP_COMPRESSION_UNSET = 0, HTTP_COMPRESSION_ERROR = 1, @@ -105,9 +105,9 @@ public: printf("compression_method: %" PRIi8 "\n", compression_method); printf("transfer_chunked: %" PRIi8 "\n", transfer_chunked); printf("connection_closed: %" PRIi8 "\n", connection_closed); - printf("content_range_start: %" PRIi64 "\n", content_range_start); - printf("content_range_end: %" PRIi64 "\n", content_range_end); - printf("content_range_entity_length: %" PRIi64 "\n", content_range_entity_length); + printf("content_range_start: %" PRIi64 "\n", content_range_start); + printf("content_range_end: %" PRIi64 "\n", content_range_end); + printf("content_range_entity_length: %" PRIi64 "\n", content_range_entity_length); printf("base: \"%s\"\n", base.c_str()); printf("error: %" PRIi16 "\n", error); } @@ -132,26 +132,26 @@ struct THttpHeader: public THttpBaseHeader { public: i8 accept_ranges; i8 squid_error; - i8 x_robots_tag; // deprecated, use x_robots_state instead + i8 x_robots_tag; // deprecated, use x_robots_state instead i16 http_status; TString location; TString rel_canonical; char hreflangs[HREFLANG_MAX]; i64 retry_after; - TString x_robots_state; // 'xxxxx' format, see `library/html/zoneconf/parsefunc.cpp` + TString x_robots_state; // 'xxxxx' format, see `library/html/zoneconf/parsefunc.cpp` public: void Init() { THttpBaseHeader::Init(); accept_ranges = -1; - squid_error = 0; + squid_error = 0; x_robots_tag = 0; rel_canonical.clear(); http_status = -1; location.clear(); hreflangs[0] = 0; retry_after = DEFAULT_RETRY_AFTER; - x_robots_state = "xxxxx"; + x_robots_state = "xxxxx"; } void Print() const { @@ -170,10 +170,10 @@ public: char host[HOST_MAX]; char from[MAXWORD_LEN]; char user_agent[MAXWORD_LEN]; - char x_yandex_langregion[MAX_LANGREGION_LEN]; + char x_yandex_langregion[MAX_LANGREGION_LEN]; char x_yandex_sourcename[MAXWORD_LEN]; - char x_yandex_requesttype[MAXWORD_LEN]; - char x_yandex_fetchoptions[MAXWORD_LEN]; + char x_yandex_requesttype[MAXWORD_LEN]; + char x_yandex_fetchoptions[MAXWORD_LEN]; i8 http_method; i8 x_yandex_request_priority; i32 x_yandex_response_timeout; @@ -190,10 +190,10 @@ public: host[0] = 0; from[0] = 0; user_agent[0] = 0; - x_yandex_langregion[0] = 0; + x_yandex_langregion[0] = 0; x_yandex_sourcename[0] = 0; - x_yandex_requesttype[0] = 0; - x_yandex_fetchoptions[0] = 0; + x_yandex_requesttype[0] = 0; + x_yandex_fetchoptions[0] = 0; http_method = HTTP_METHOD_UNDEFINED; x_yandex_request_priority = DEFAULT_REQUEST_PRIORITY; x_yandex_response_timeout = DEFAULT_RESPONSE_TIMEOUT; diff --git a/library/cpp/http/fetch/httpparser.h b/library/cpp/http/fetch/httpparser.h index 25a5b4385c..769828e4ae 100644 --- a/library/cpp/http/fetch/httpparser.h +++ b/library/cpp/http/fetch/httpparser.h @@ -4,7 +4,7 @@ #include "httpheader.h" #include <library/cpp/mime/types/mime.h> -#include <util/system/yassert.h> +#include <util/system/yassert.h> #include <library/cpp/http/misc/httpcodes.h> template <size_t headermax = 100 << 10, size_t bodymax = 1 << 20> @@ -294,7 +294,7 @@ public: Header = H; Eoferr = 1; Size = 0; - AssumeConnectionClosed = assumeConnectionClosed; + AssumeConnectionClosed = assumeConnectionClosed; HeadRequest = headRequest; return parsHeader ? ParseHeader() : SkipHeader(); } diff --git a/library/cpp/http/fetch/httpzreader.h b/library/cpp/http/fetch/httpzreader.h index fcb95baa56..68eb00853d 100644 --- a/library/cpp/http/fetch/httpzreader.h +++ b/library/cpp/http/fetch/httpzreader.h @@ -4,9 +4,9 @@ #include "httpparser.h" #include "exthttpcodes.h" -#include <util/system/defaults.h> -#include <util/generic/yexception.h> - +#include <util/system/defaults.h> +#include <util/generic/yexception.h> + #include <contrib/libs/zlib/zlib.h> #include <errno.h> @@ -35,8 +35,8 @@ public: , MaxContSize(0) , Buf(nullptr) , ZErr(0) - , ConnectionClosed(0) - , IgnoreTrailingGarbage(true) + , ConnectionClosed(0) + , IgnoreTrailingGarbage(true) { memset(&Stream, 0, sizeof(Stream)); } @@ -50,14 +50,14 @@ public: } } - void SetConnectionClosed(int cc) { - ConnectionClosed = cc; - } - - void SetIgnoreTrailingGarbage(bool ignore) { - IgnoreTrailingGarbage = ignore; - } - + void SetConnectionClosed(int cc) { + ConnectionClosed = cc; + } + + void SetIgnoreTrailingGarbage(bool ignore) { + IgnoreTrailingGarbage = ignore; + } + int Init( THttpHeader* H, int parsHeader, @@ -122,11 +122,11 @@ public: return -1; } if (!IgnoreTrailingGarbage && BufSize == Stream.avail_out && Stream.avail_in > 0) { - Header->error = EXT_HTTP_GZIPERROR; - ZErr = EFAULT; + Header->error = EXT_HTTP_GZIPERROR; + ZErr = EFAULT; Stream.msg = (char*)"trailing garbage"; - return -1; - } + return -1; + } return long(BufSize - Stream.avail_out); case Z_NEED_DICT: @@ -236,8 +236,8 @@ protected: size_t CurContSize, MaxContSize; ui8* Buf; int ZErr; - int ConnectionClosed; - bool IgnoreTrailingGarbage; + int ConnectionClosed; + bool IgnoreTrailingGarbage; }; class zlib_exception: public yexception { diff --git a/library/cpp/http/fetch/ut/ya.make b/library/cpp/http/fetch/ut/ya.make index 42392f2ee0..7486986b36 100644 --- a/library/cpp/http/fetch/ut/ya.make +++ b/library/cpp/http/fetch/ut/ya.make @@ -1,7 +1,7 @@ UNITTEST_FOR(library/cpp/http/fetch) OWNER( - g:zora + g:zora ) SRCS( diff --git a/library/cpp/http/fetch/ya.make b/library/cpp/http/fetch/ya.make index 99cf53da03..7737127463 100644 --- a/library/cpp/http/fetch/ya.make +++ b/library/cpp/http/fetch/ya.make @@ -1,7 +1,7 @@ LIBRARY() OWNER( - g:zora + g:zora ) PEERDIR( @@ -26,7 +26,7 @@ SRCS( httpheader.h httpparser.h httpzreader.h - sockhandler.h + sockhandler.h ) GENERATE_ENUM_SERIALIZATION(httpheader.h) diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp index 74f024d97f..4a3031bbf4 100644 --- a/library/cpp/http/misc/httpdate.cpp +++ b/library/cpp/http/misc/httpdate.cpp @@ -49,18 +49,18 @@ static const char *months[] = { "Nov", "Dec" }; -int format_http_date(char buf[], size_t size, time_t when) { +int format_http_date(char buf[], size_t size, time_t when) { struct tm tms; - GmTimeR(&when, &tms); + GmTimeR(&when, &tms); #ifndef HTTP_DATE_ISO_8601 return snprintf(buf, size, "%s, %02d %s %04d %02d:%02d:%02d GMT", - wkdays[tms.tm_wday], tms.tm_mday, months[tms.tm_mon], - tms.tm_year + 1900, tms.tm_hour, tms.tm_min, tms.tm_sec); + wkdays[tms.tm_wday], tms.tm_mday, months[tms.tm_mon], + tms.tm_year + 1900, tms.tm_hour, tms.tm_min, tms.tm_sec); #else /* ISO 8601 */ return snprintf(buf, size, "%04d%02d%02dT%02d%02d%02d+0000", - tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, - tms.tm_hour, tms.tm_min, tms.tm_sec); + tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec); #endif } diff --git a/library/cpp/ipv6_address/ipv6_address.cpp b/library/cpp/ipv6_address/ipv6_address.cpp index 48c9e8c860..be8fcbae13 100644 --- a/library/cpp/ipv6_address/ipv6_address.cpp +++ b/library/cpp/ipv6_address/ipv6_address.cpp @@ -122,17 +122,17 @@ TString TIpv6Address::ToString(bool PrintScopeId, bool* ok) const noexcept { in_addr addr; ToInAddr(addr); isOk = inet_ntop(AF_INET, &addr, result.begin(), INET_ADDRSTRLEN); - result.resize(result.find('\0')); + result.resize(result.find('\0')); } else if (Type_ == TIpv6Address::Ipv6) { result.resize(INET6_ADDRSTRLEN + 2); in6_addr addr; ToIn6Addr(addr); isOk = inet_ntop(AF_INET6, &addr, result.begin(), INET6_ADDRSTRLEN); - result.resize(result.find('\0')); + result.resize(result.find('\0')); if (PrintScopeId) result += "%" + ::ToString(ScopeId_); - } else { - result = "null"; + } else { + result = "null"; isOk = true; } diff --git a/library/cpp/ipv6_address/ipv6_address.h b/library/cpp/ipv6_address/ipv6_address.h index 6b1b106dfe..1d7eb0b65f 100644 --- a/library/cpp/ipv6_address/ipv6_address.h +++ b/library/cpp/ipv6_address/ipv6_address.h @@ -97,21 +97,21 @@ public: constexpr bool operator<(const TIpv6Address& other) const noexcept { if (Type_ != other.Type_) - return Type_ > other.Type_; - else - return Ip < other.Ip; + return Type_ > other.Type_; + else + return Ip < other.Ip; } constexpr bool operator>(const TIpv6Address& other) const noexcept { if (Type_ != other.Type_) - return Type_ < other.Type_; - else - return Ip > other.Ip; + return Type_ < other.Type_; + else + return Ip > other.Ip; } constexpr bool operator==(const TIpv6Address& other) const noexcept { - return Type_ == other.Type_ && Ip == other.Ip; + return Type_ == other.Type_ && Ip == other.Ip; } constexpr bool operator!=(const TIpv6Address& other) const noexcept { - return Type_ != other.Type_ || Ip != other.Ip; + return Type_ != other.Type_ || Ip != other.Ip; } constexpr bool operator<=(const TIpv6Address& other) const noexcept { diff --git a/library/cpp/monlib/counters/counters.cpp b/library/cpp/monlib/counters/counters.cpp index 726b8b9944..50dca4c577 100644 --- a/library/cpp/monlib/counters/counters.cpp +++ b/library/cpp/monlib/counters/counters.cpp @@ -3,7 +3,7 @@ namespace NMonitoring { char* PrettyNumShort(i64 val, char* buf, size_t size) { - static const char shorts[] = {' ', 'K', 'M', 'G', 'T', 'P', 'E'}; + static const char shorts[] = {' ', 'K', 'M', 'G', 'T', 'P', 'E'}; unsigned i = 0; i64 major = val; i64 minor = 0; diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 172398b78f..929efbf816 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -31,9 +31,9 @@ namespace NMonitoring { } TString path = GetPath(); if (!path.StartsWith('/')) { - out << "HTTP/1.1 400 Bad request\r\nConnection: Close\r\n\r\n"; - return; - } + out << "HTTP/1.1 400 Bad request\r\nConnection: Close\r\n\r\n"; + return; + } Headers = &in.Headers(); CgiParams.Scan(Url.Get(THttpURL::FieldQuery)); } catch (...) { @@ -43,7 +43,7 @@ namespace NMonitoring { if (Header.http_method == HTTP_METHOD_POST) TransferData(&in, &PostContent); - + Handler(out, *this); out.Finish(); } catch (...) { @@ -66,8 +66,8 @@ namespace NMonitoring { const TCgiParameters& GetPostParams() const override { if (PostParams.empty() && !PostContent.Buffer().Empty()) const_cast<THttpClient*>(this)->ScanPostParams(); - return PostParams; - } + return PostParams; + } TStringBuf GetPostContent() const override { return TStringBuf(PostContent.Buffer().Data(), PostContent.Buffer().Size()); } @@ -95,7 +95,7 @@ namespace NMonitoring { const THttpHeaders* Headers = nullptr; THttpURL Url; TCgiParameters CgiParams; - TCgiParameters PostParams; + TCgiParameters PostParams; TBufferOutput PostContent; const NAddr::IRemoteAddr* RemoteAddr = nullptr; }; @@ -140,11 +140,11 @@ namespace NMonitoring { , BindAddr(bindAddr) , Port(port) { - try { - Listener.Bind(TIpAddress(bindAddr, port)); - } catch (yexception e) { + try { + Listener.Bind(TIpAddress(bindAddr, port)); + } catch (yexception e) { Y_FAIL("TCoHttpServer::TCoHttpServer: couldn't bind to %s:%d\n", bindAddr.data(), port); - } + } } void TCoHttpServer::Start() { diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 07f1df9c3a..2f66dddaf8 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -20,7 +20,7 @@ namespace NMonitoring { virtual const char* GetURI() const = 0; virtual const char* GetPath() const = 0; virtual const TCgiParameters& GetParams() const = 0; - virtual const TCgiParameters& GetPostParams() const = 0; + virtual const TCgiParameters& GetPostParams() const = 0; virtual TStringBuf GetPostContent() const = 0; virtual HTTP_METHOD GetMethod() const = 0; virtual const THttpHeaders& GetHeaders() const = 0; diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp index 94ca7511de..85f4ac5d69 100644 --- a/library/cpp/string_utils/url/url.cpp +++ b/library/cpp/string_utils/url/url.cpp @@ -376,12 +376,12 @@ size_t NormalizeHostName(char* dest, const TStringBuf source, size_t dest_size, size_t len = Min(dest_size - 1, source.length()); memcpy(dest, source.data(), len); dest[len] = 0; - char buf[8] = ":"; - size_t buflen = 1 + ToString(defport, buf + 1, sizeof(buf) - 2); - buf[buflen] = '\0'; + char buf[8] = ":"; + size_t buflen = 1 + ToString(defport, buf + 1, sizeof(buf) - 2); + buf[buflen] = '\0'; char* ptr = strstr(dest, buf); if (ptr && ptr[buflen] == 0) { - len -= buflen; + len -= buflen; *ptr = 0; } strlwr(dest); diff --git a/library/cpp/uri/common.cpp b/library/cpp/uri/common.cpp index b4917023e2..05af1e57d1 100644 --- a/library/cpp/uri/common.cpp +++ b/library/cpp/uri/common.cpp @@ -112,4 +112,4 @@ namespace NUri { return TScheme::SchemeEmpty == t ? "empty" : "unknown"; } -} +} diff --git a/library/cpp/uri/common.h b/library/cpp/uri/common.h index 682c8b6387..8025357763 100644 --- a/library/cpp/uri/common.h +++ b/library/cpp/uri/common.h @@ -145,7 +145,7 @@ namespace NUri { // Cases interpreted for processing (if required): // (effects on result of Parse method) //============================== - + // path needs normalization // (simplification of directory tree: /../, /./, etc. FEATURE_NAME(PathOperation), diff --git a/library/cpp/uri/parsefsm.rl6 b/library/cpp/uri/parsefsm.rl6 index c79e537326..7097723650 100644 --- a/library/cpp/uri/parsefsm.rl6 +++ b/library/cpp/uri/parsefsm.rl6 @@ -458,7 +458,7 @@ ) ; - write data; + write data; }%% @@ -469,7 +469,7 @@ bool TParser::doParse(const char* str_beg, size_t length) const char* p = str_beg; const char* pe = str_beg + length; const char* eof = pe; - int cs; + int cs; #define BEG(ptr, fld) startSection (ptr, TField::Field ## fld); #define END(ptr, fld) finishSection(ptr, TField::Field ## fld); diff --git a/library/cpp/uri/uri.h b/library/cpp/uri/uri.h index 422c95cd61..3b6c19fe4a 100644 --- a/library/cpp/uri/uri.h +++ b/library/cpp/uri/uri.h @@ -432,7 +432,7 @@ namespace NUri { // Info methods int Compare(const TUri& A, int flags = FlagUrlFields) const; - + int CompareField(EField fld, const TUri& url) const; const TStringBuf& GetField(EField fld) const { diff --git a/library/cpp/uri/uri_ut.cpp b/library/cpp/uri/uri_ut.cpp index bac723e523..2ebd83fc93 100644 --- a/library/cpp/uri/uri_ut.cpp +++ b/library/cpp/uri/uri_ut.cpp @@ -264,21 +264,21 @@ namespace NUri { TUri url; URL_TEST(url, test); } - + Y_UNIT_TEST(test02) { TTest test = { "http://host", TFeature::FeaturesAll, TState::ParsedOK, "http", "", "", "host", 80, "/", "", ""}; TUri url; URL_TEST(url, test); } - + Y_UNIT_TEST(test03) { TTest test = { "https://host", TFeature::FeatureSchemeFlexible | TFeature::FeatureAllowHostIDN, TState::ParsedOK, "https", "", "", "host", 443, "/", "", ""}; TUri url; URL_TEST(url, test); } - + Y_UNIT_TEST(test04) { TTest test = { "user:pass@host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "user", "", "", "", 0, "pass@host:8080", "", ""}; @@ -288,7 +288,7 @@ namespace NUri { CMP_URL(url2, test); URL_EQ(url, url2); } - + Y_UNIT_TEST(test05) { TTest test = { "host:8080", TFeature::FeaturesAll | TFeature::FeatureNoRelPath | TFeature::FeatureAllowRootless, TState::ParsedOK, "host", "", "", "", 0, "8080", "", ""}; |