diff options
author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/messagebus/rain_check/http/http_code_extractor.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/rain_check/http/http_code_extractor.cpp')
-rw-r--r-- | library/cpp/messagebus/rain_check/http/http_code_extractor.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/library/cpp/messagebus/rain_check/http/http_code_extractor.cpp b/library/cpp/messagebus/rain_check/http/http_code_extractor.cpp index b0925c5a6b8..51d75762f68 100644 --- a/library/cpp/messagebus/rain_check/http/http_code_extractor.cpp +++ b/library/cpp/messagebus/rain_check/http/http_code_extractor.cpp @@ -8,32 +8,32 @@ #include <util/string/cast.h> namespace NRainCheck { - TMaybe<HttpCodes> TryGetHttpCodeFromErrorDescription(const TStringBuf& errorMessage) { + TMaybe<HttpCodes> TryGetHttpCodeFromErrorDescription(const TStringBuf& errorMessage) { // Try to get HttpCode from library/cpp/neh response. // If response has HttpCode and it is not 200 OK, library/cpp/neh will send a message // "library/cpp/neh/http.cpp:<LINE>: request failed(<FIRST-HTTP-RESPONSE-LINE>)" // (see library/cpp/neh/http.cpp:625). So, we will try to parse this message and - // find out HttpCode in it. It is bad temporary solution, but we have no choice. + // find out HttpCode in it. It is bad temporary solution, but we have no choice. const TStringBuf SUBSTR = "request failed("; - const size_t SUBSTR_LEN = SUBSTR.size(); + const size_t SUBSTR_LEN = SUBSTR.size(); const size_t FIRST_LINE_LEN = TStringBuf("HTTP/1.X NNN").size(); - TMaybe<HttpCodes> httpCode; + TMaybe<HttpCodes> httpCode; - const size_t substrPos = errorMessage.find(SUBSTR); - if (substrPos != TStringBuf::npos) { - const TStringBuf firstLineStart = errorMessage.SubStr(substrPos + SUBSTR_LEN, FIRST_LINE_LEN); - try { - httpCode = static_cast<HttpCodes>(ParseHttpRetCode(firstLineStart)); - if (*httpCode < HTTP_CONTINUE || *httpCode >= HTTP_CODE_MAX) { - httpCode = Nothing(); - } - } catch (const TFromStringException& ex) { - // Can't parse HttpCode: it is OK, because ErrorDescription can be random string. + const size_t substrPos = errorMessage.find(SUBSTR); + if (substrPos != TStringBuf::npos) { + const TStringBuf firstLineStart = errorMessage.SubStr(substrPos + SUBSTR_LEN, FIRST_LINE_LEN); + try { + httpCode = static_cast<HttpCodes>(ParseHttpRetCode(firstLineStart)); + if (*httpCode < HTTP_CONTINUE || *httpCode >= HTTP_CODE_MAX) { + httpCode = Nothing(); + } + } catch (const TFromStringException& ex) { + // Can't parse HttpCode: it is OK, because ErrorDescription can be random string. } } - - return httpCode; + + return httpCode; } } |