aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/rain_check/http
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/rain_check/http
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/rain_check/http')
-rw-r--r--library/cpp/messagebus/rain_check/http/client.cpp228
-rw-r--r--library/cpp/messagebus/rain_check/http/client.h94
-rw-r--r--library/cpp/messagebus/rain_check/http/client_ut.cpp204
-rw-r--r--library/cpp/messagebus/rain_check/http/http_code_extractor.cpp32
-rw-r--r--library/cpp/messagebus/rain_check/http/http_code_extractor.h6
5 files changed, 282 insertions, 282 deletions
diff --git a/library/cpp/messagebus/rain_check/http/client.cpp b/library/cpp/messagebus/rain_check/http/client.cpp
index 5ef5ceeece..0fb8a93420 100644
--- a/library/cpp/messagebus/rain_check/http/client.cpp
+++ b/library/cpp/messagebus/rain_check/http/client.cpp
@@ -14,141 +14,141 @@
#include <util/stream/str.h>
namespace NRainCheck {
- class THttpCallback: public NNeh::IOnRecv {
- public:
- THttpCallback(NRainCheck::THttpFuture* future)
- : Future(future)
- {
- Y_VERIFY(!!future, "future is NULL");
- }
-
- void OnRecv(NNeh::THandle& handle) override {
- THolder<THttpCallback> self(this);
- NNeh::TResponseRef response = handle.Get();
- Future->SetDoneAndSchedule(response);
- }
-
- private:
- NRainCheck::THttpFuture* const Future;
- };
-
- THttpFuture::THttpFuture()
- : Task(nullptr)
- , ErrorCode(THttpFuture::NoError)
+ class THttpCallback: public NNeh::IOnRecv {
+ public:
+ THttpCallback(NRainCheck::THttpFuture* future)
+ : Future(future)
+ {
+ Y_VERIFY(!!future, "future is NULL");
+ }
+
+ void OnRecv(NNeh::THandle& handle) override {
+ THolder<THttpCallback> self(this);
+ NNeh::TResponseRef response = handle.Get();
+ Future->SetDoneAndSchedule(response);
+ }
+
+ private:
+ NRainCheck::THttpFuture* const Future;
+ };
+
+ THttpFuture::THttpFuture()
+ : Task(nullptr)
+ , ErrorCode(THttpFuture::NoError)
{
}
- THttpFuture::~THttpFuture() {
+ THttpFuture::~THttpFuture() {
}
- bool THttpFuture::HasError() const {
- return (ErrorCode != THttpFuture::NoError);
- }
+ bool THttpFuture::HasError() const {
+ return (ErrorCode != THttpFuture::NoError);
+ }
- THttpFuture::EError THttpFuture::GetErrorCode() const {
- return ErrorCode;
- }
+ THttpFuture::EError THttpFuture::GetErrorCode() const {
+ return ErrorCode;
+ }
- TString THttpFuture::GetErrorDescription() const {
- return ErrorDescription;
- }
+ TString THttpFuture::GetErrorDescription() const {
+ return ErrorDescription;
+ }
- THttpClientService::THttpClientService()
- : GetProtocol(NNeh::ProtocolFactory()->Protocol("http"))
- , FullProtocol(NNeh::ProtocolFactory()->Protocol("full"))
- {
- Y_VERIFY(!!GetProtocol, "GET protocol is NULL.");
- Y_VERIFY(!!FullProtocol, "POST protocol is NULL.");
- }
+ THttpClientService::THttpClientService()
+ : GetProtocol(NNeh::ProtocolFactory()->Protocol("http"))
+ , FullProtocol(NNeh::ProtocolFactory()->Protocol("full"))
+ {
+ Y_VERIFY(!!GetProtocol, "GET protocol is NULL.");
+ Y_VERIFY(!!FullProtocol, "POST protocol is NULL.");
+ }
- THttpClientService::~THttpClientService() {
- }
+ THttpClientService::~THttpClientService() {
+ }
- void THttpClientService::SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future) {
- Y_VERIFY(!!future, "future is NULL.");
+ void THttpClientService::SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future) {
+ Y_VERIFY(!!future, "future is NULL.");
- TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
- future->SetRunning(current);
- future->Task = current;
+ TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
+ future->SetRunning(current);
+ future->Task = current;
- THolder<THttpCallback> callback(new THttpCallback(future));
- NNeh::TServiceStatRef stat;
- try {
+ THolder<THttpCallback> callback(new THttpCallback(future));
+ NNeh::TServiceStatRef stat;
+ try {
NNeh::TMessage msg(addr.replace(0, NNeh::TParsedLocation(addr).Scheme.size(), "post"), data);
- TStringStream headersText;
- headers.OutTo(&headersText);
- NNeh::NHttp::MakeFullRequest(msg, headersText.Str(), TString());
- FullProtocol->ScheduleRequest(msg, callback.Get(), stat);
+ TStringStream headersText;
+ headers.OutTo(&headersText);
+ NNeh::NHttp::MakeFullRequest(msg, headersText.Str(), TString());
+ FullProtocol->ScheduleRequest(msg, callback.Get(), stat);
Y_UNUSED(callback.Release());
- } catch (const TNetworkResolutionError& err) {
- future->SetFail(THttpFuture::CantResolveNameError, err.AsStrBuf());
- } catch (const yexception& err) {
- future->SetFail(THttpFuture::OtherError, err.AsStrBuf());
- }
- }
-
- void THttpClientService::Send(const TString& request, THttpFuture* future) {
- Y_VERIFY(!!future, "future is NULL.");
-
- TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
- future->SetRunning(current);
- future->Task = current;
-
- THolder<THttpCallback> callback(new THttpCallback(future));
- NNeh::TServiceStatRef stat;
- try {
- GetProtocol->ScheduleRequest(NNeh::TMessage::FromString(request),
- callback.Get(),
- stat);
+ } catch (const TNetworkResolutionError& err) {
+ future->SetFail(THttpFuture::CantResolveNameError, err.AsStrBuf());
+ } catch (const yexception& err) {
+ future->SetFail(THttpFuture::OtherError, err.AsStrBuf());
+ }
+ }
+
+ void THttpClientService::Send(const TString& request, THttpFuture* future) {
+ Y_VERIFY(!!future, "future is NULL.");
+
+ TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
+ future->SetRunning(current);
+ future->Task = current;
+
+ THolder<THttpCallback> callback(new THttpCallback(future));
+ NNeh::TServiceStatRef stat;
+ try {
+ GetProtocol->ScheduleRequest(NNeh::TMessage::FromString(request),
+ callback.Get(),
+ stat);
Y_UNUSED(callback.Release());
- } catch (const TNetworkResolutionError& err) {
- future->SetFail(THttpFuture::CantResolveNameError, err.AsStrBuf());
- } catch (const yexception& err) {
- future->SetFail(THttpFuture::OtherError, err.AsStrBuf());
- }
- }
-
- bool THttpFuture::HasHttpCode() const {
- return !!HttpCode;
- }
-
- bool THttpFuture::HasResponseBody() const {
- return !!Response;
+ } catch (const TNetworkResolutionError& err) {
+ future->SetFail(THttpFuture::CantResolveNameError, err.AsStrBuf());
+ } catch (const yexception& err) {
+ future->SetFail(THttpFuture::OtherError, err.AsStrBuf());
+ }
+ }
+
+ bool THttpFuture::HasHttpCode() const {
+ return !!HttpCode;
}
- ui32 THttpFuture::GetHttpCode() const {
- Y_ASSERT(IsDone());
- Y_ASSERT(HasHttpCode());
+ bool THttpFuture::HasResponseBody() const {
+ return !!Response;
+ }
- return static_cast<ui32>(*HttpCode);
- }
-
- TString THttpFuture::GetResponseBody() const {
- Y_ASSERT(IsDone());
- Y_ASSERT(HasResponseBody());
-
- return Response->Data;
- }
+ ui32 THttpFuture::GetHttpCode() const {
+ Y_ASSERT(IsDone());
+ Y_ASSERT(HasHttpCode());
- void THttpFuture::SetDoneAndSchedule(TAutoPtr<NNeh::TResponse> response) {
- if (!response->IsError()) {
- ErrorCode = THttpFuture::NoError;
- HttpCode = HttpCodes::HTTP_OK;
- } else {
- ErrorCode = THttpFuture::BadHttpCodeError;
- ErrorDescription = response->GetErrorText();
-
- HttpCode = TryGetHttpCodeFromErrorDescription(ErrorDescription);
- }
- Response.Reset(response);
- SetDone();
+ return static_cast<ui32>(*HttpCode);
}
- void THttpFuture::SetFail(THttpFuture::EError errorCode, const TStringBuf& errorDescription) {
- ErrorCode = errorCode;
- ErrorDescription = errorDescription;
- Response.Destroy();
- SetDone();
+ TString THttpFuture::GetResponseBody() const {
+ Y_ASSERT(IsDone());
+ Y_ASSERT(HasResponseBody());
+
+ return Response->Data;
+ }
+
+ void THttpFuture::SetDoneAndSchedule(TAutoPtr<NNeh::TResponse> response) {
+ if (!response->IsError()) {
+ ErrorCode = THttpFuture::NoError;
+ HttpCode = HttpCodes::HTTP_OK;
+ } else {
+ ErrorCode = THttpFuture::BadHttpCodeError;
+ ErrorDescription = response->GetErrorText();
+
+ HttpCode = TryGetHttpCodeFromErrorDescription(ErrorDescription);
+ }
+ Response.Reset(response);
+ SetDone();
+ }
+
+ void THttpFuture::SetFail(THttpFuture::EError errorCode, const TStringBuf& errorDescription) {
+ ErrorCode = errorCode;
+ ErrorDescription = errorDescription;
+ Response.Destroy();
+ SetDone();
}
}
diff --git a/library/cpp/messagebus/rain_check/http/client.h b/library/cpp/messagebus/rain_check/http/client.h
index d4199c4c98..b7f822ae10 100644
--- a/library/cpp/messagebus/rain_check/http/client.h
+++ b/library/cpp/messagebus/rain_check/http/client.h
@@ -13,66 +13,66 @@
class THttpHeaders;
namespace NNeh {
- class IProtocol;
- struct TResponse;
-}
+ class IProtocol;
+ struct TResponse;
+}
namespace NRainCheck {
- class THttpCallback;
- class THttpClientService;
+ class THttpCallback;
+ class THttpClientService;
- class THttpFuture: public TSubtaskCompletion {
- public:
- enum EError {
- NoError = 0,
+ class THttpFuture: public TSubtaskCompletion {
+ public:
+ enum EError {
+ NoError = 0,
- CantResolveNameError = 1,
- BadHttpCodeError = 2,
+ CantResolveNameError = 1,
+ BadHttpCodeError = 2,
- OtherError = 100
- };
+ OtherError = 100
+ };
- private:
- friend class THttpCallback;
- friend class THttpClientService;
+ private:
+ friend class THttpCallback;
+ friend class THttpClientService;
- public:
- THttpFuture();
- ~THttpFuture() override;
+ public:
+ THttpFuture();
+ ~THttpFuture() override;
- bool HasHttpCode() const;
- bool HasResponseBody() const;
+ bool HasHttpCode() const;
+ bool HasResponseBody() const;
- ui32 GetHttpCode() const;
- TString GetResponseBody() const;
+ ui32 GetHttpCode() const;
+ TString GetResponseBody() const;
- bool HasError() const;
- EError GetErrorCode() const;
- TString GetErrorDescription() const;
+ bool HasError() const;
+ EError GetErrorCode() const;
+ TString GetErrorDescription() const;
- private:
- void SetDoneAndSchedule(TAutoPtr<NNeh::TResponse> response);
- void SetFail(EError errorCode, const TStringBuf& errorDescription);
+ private:
+ void SetDoneAndSchedule(TAutoPtr<NNeh::TResponse> response);
+ void SetFail(EError errorCode, const TStringBuf& errorDescription);
- private:
- TTaskRunnerBase* Task;
- TMaybe<HttpCodes> HttpCode;
- THolder<NNeh::TResponse> Response;
- EError ErrorCode;
- TString ErrorDescription;
- };
+ private:
+ TTaskRunnerBase* Task;
+ TMaybe<HttpCodes> HttpCode;
+ THolder<NNeh::TResponse> Response;
+ EError ErrorCode;
+ TString ErrorDescription;
+ };
- class THttpClientService {
- public:
- THttpClientService();
- virtual ~THttpClientService();
+ class THttpClientService {
+ public:
+ THttpClientService();
+ virtual ~THttpClientService();
- void Send(const TString& request, THttpFuture* future);
- void SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future);
+ void Send(const TString& request, THttpFuture* future);
+ void SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future);
- private:
- NNeh::IProtocol* const GetProtocol;
- NNeh::IProtocol* const FullProtocol;
- };
+ private:
+ NNeh::IProtocol* const GetProtocol;
+ NNeh::IProtocol* const FullProtocol;
+ };
-}
+}
diff --git a/library/cpp/messagebus/rain_check/http/client_ut.cpp b/library/cpp/messagebus/rain_check/http/client_ut.cpp
index 1628114391..51d0296a37 100644
--- a/library/cpp/messagebus/rain_check/http/client_ut.cpp
+++ b/library/cpp/messagebus/rain_check/http/client_ut.cpp
@@ -28,116 +28,116 @@ using namespace NRainCheck;
using namespace NBus::NTest;
namespace {
- class THttpClientEnv: public TTestEnvTemplate<THttpClientEnv> {
- public:
- THttpClientService HttpClientService;
- };
-
- const TString TEST_SERVICE = "test-service";
- const TString TEST_GET_PARAMS = "p=GET";
- const TString TEST_POST_PARAMS = "p=POST";
- const TString TEST_POST_HEADERS = "Content-Type: application/json\r\n";
- const TString TEST_GET_RECV = "GET was ok.";
- const TString TEST_POST_RECV = "POST was ok.";
-
- TString BuildServiceLocation(ui32 port) {
+ class THttpClientEnv: public TTestEnvTemplate<THttpClientEnv> {
+ public:
+ THttpClientService HttpClientService;
+ };
+
+ const TString TEST_SERVICE = "test-service";
+ const TString TEST_GET_PARAMS = "p=GET";
+ const TString TEST_POST_PARAMS = "p=POST";
+ const TString TEST_POST_HEADERS = "Content-Type: application/json\r\n";
+ const TString TEST_GET_RECV = "GET was ok.";
+ const TString TEST_POST_RECV = "POST was ok.";
+
+ TString BuildServiceLocation(ui32 port) {
return Sprintf("http://*:%" PRIu32 "/%s", port, TEST_SERVICE.data());
- }
+ }
- TString BuildPostServiceLocation(ui32 port) {
+ TString BuildPostServiceLocation(ui32 port) {
return Sprintf("post://*:%" PRIu32 "/%s", port + 1, TEST_SERVICE.data());
- }
-
- TString BuildGetTestRequest(ui32 port) {
- return BuildServiceLocation(port) + "?" + TEST_GET_PARAMS;
- }
-
- class TSimpleServer {
- public:
- inline void ServeRequest(const NNeh::IRequestRef& req) {
- NNeh::TData response;
- if (req->Data() == TEST_GET_PARAMS) {
- response.assign(TEST_GET_RECV.begin(), TEST_GET_RECV.end());
- } else {
- response.assign(TEST_POST_RECV.begin(), TEST_POST_RECV.end());
- }
- req->SendReply(response);
- }
- };
-
- NNeh::IServicesRef RunServer(ui32 port, TSimpleServer& server) {
- NNeh::IServicesRef runner = NNeh::CreateLoop();
- runner->Add(BuildServiceLocation(port), server);
- runner->Add(BuildPostServiceLocation(port), server);
-
- try {
- const int THR_POOL_SIZE = 2;
- runner->ForkLoop(THR_POOL_SIZE);
- } catch (...) {
+ }
+
+ TString BuildGetTestRequest(ui32 port) {
+ return BuildServiceLocation(port) + "?" + TEST_GET_PARAMS;
+ }
+
+ class TSimpleServer {
+ public:
+ inline void ServeRequest(const NNeh::IRequestRef& req) {
+ NNeh::TData response;
+ if (req->Data() == TEST_GET_PARAMS) {
+ response.assign(TEST_GET_RECV.begin(), TEST_GET_RECV.end());
+ } else {
+ response.assign(TEST_POST_RECV.begin(), TEST_POST_RECV.end());
+ }
+ req->SendReply(response);
+ }
+ };
+
+ NNeh::IServicesRef RunServer(ui32 port, TSimpleServer& server) {
+ NNeh::IServicesRef runner = NNeh::CreateLoop();
+ runner->Add(BuildServiceLocation(port), server);
+ runner->Add(BuildPostServiceLocation(port), server);
+
+ try {
+ const int THR_POOL_SIZE = 2;
+ runner->ForkLoop(THR_POOL_SIZE);
+ } catch (...) {
Y_FAIL("Can't run server: %s", CurrentExceptionMessage().data());
}
- return runner;
+ return runner;
}
- enum ERequestType {
- RT_HTTP_GET = 0,
- RT_HTTP_POST = 1
- };
-
- using TTaskParam = std::pair<TIpPort, ERequestType>;
-
- class THttpClientTask: public ISimpleTask {
- public:
- THttpClientTask(THttpClientEnv* env, TTaskParam param)
- : Env(env)
- , ServerPort(param.first)
- , ReqType(param.second)
- {
- }
-
- TContinueFunc Start() override {
- switch (ReqType) {
- case RT_HTTP_GET: {
- TString getRequest = BuildGetTestRequest(ServerPort);
- for (size_t i = 0; i < 3; ++i) {
- Requests.push_back(new THttpFuture());
- Env->HttpClientService.Send(getRequest, Requests[i].Get());
- }
- break;
+ enum ERequestType {
+ RT_HTTP_GET = 0,
+ RT_HTTP_POST = 1
+ };
+
+ using TTaskParam = std::pair<TIpPort, ERequestType>;
+
+ class THttpClientTask: public ISimpleTask {
+ public:
+ THttpClientTask(THttpClientEnv* env, TTaskParam param)
+ : Env(env)
+ , ServerPort(param.first)
+ , ReqType(param.second)
+ {
+ }
+
+ TContinueFunc Start() override {
+ switch (ReqType) {
+ case RT_HTTP_GET: {
+ TString getRequest = BuildGetTestRequest(ServerPort);
+ for (size_t i = 0; i < 3; ++i) {
+ Requests.push_back(new THttpFuture());
+ Env->HttpClientService.Send(getRequest, Requests[i].Get());
+ }
+ break;
}
- case RT_HTTP_POST: {
- TString servicePath = BuildPostServiceLocation(ServerPort);
- TStringInput headersText(TEST_POST_HEADERS);
- THttpHeaders headers(&headersText);
- for (size_t i = 0; i < 3; ++i) {
- Requests.push_back(new THttpFuture());
- Env->HttpClientService.SendPost(servicePath, TEST_POST_PARAMS, headers, Requests[i].Get());
- }
- break;
+ case RT_HTTP_POST: {
+ TString servicePath = BuildPostServiceLocation(ServerPort);
+ TStringInput headersText(TEST_POST_HEADERS);
+ THttpHeaders headers(&headersText);
+ for (size_t i = 0; i < 3; ++i) {
+ Requests.push_back(new THttpFuture());
+ Env->HttpClientService.SendPost(servicePath, TEST_POST_PARAMS, headers, Requests[i].Get());
+ }
+ break;
}
}
-
- return &THttpClientTask::GotReplies;
+
+ return &THttpClientTask::GotReplies;
}
- TContinueFunc GotReplies() {
- const TString& TEST_OK_RECV = (ReqType == RT_HTTP_GET) ? TEST_GET_RECV : TEST_POST_RECV;
- for (size_t i = 0; i < Requests.size(); ++i) {
- UNIT_ASSERT_EQUAL(Requests[i]->GetHttpCode(), 200);
- UNIT_ASSERT_EQUAL(Requests[i]->GetResponseBody(), TEST_OK_RECV);
- }
-
- Env->TestSync.CheckAndIncrement(0);
+ TContinueFunc GotReplies() {
+ const TString& TEST_OK_RECV = (ReqType == RT_HTTP_GET) ? TEST_GET_RECV : TEST_POST_RECV;
+ for (size_t i = 0; i < Requests.size(); ++i) {
+ UNIT_ASSERT_EQUAL(Requests[i]->GetHttpCode(), 200);
+ UNIT_ASSERT_EQUAL(Requests[i]->GetResponseBody(), TEST_OK_RECV);
+ }
- return nullptr;
+ Env->TestSync.CheckAndIncrement(0);
+
+ return nullptr;
}
- THttpClientEnv* const Env;
- const TIpPort ServerPort;
- const ERequestType ReqType;
+ THttpClientEnv* const Env;
+ const TIpPort ServerPort;
+ const ERequestType ReqType;
- TVector<TSimpleSharedPtr<THttpFuture>> Requests;
- };
+ TVector<TSimpleSharedPtr<THttpFuture>> Requests;
+ };
} // anonymous namespace
@@ -175,12 +175,12 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) {
}
Y_UNIT_TEST(HttpCodeExtraction) {
- // Find "request failed(" string, then copy len("HTTP/1.X NNN") chars and try to convert NNN to HTTP code.
+ // Find "request failed(" string, then copy len("HTTP/1.X NNN") chars and try to convert NNN to HTTP code.
-#define CHECK_VALID_LINE(line, code) \
- UNIT_ASSERT_NO_EXCEPTION(TryGetHttpCodeFromErrorDescription(line)); \
- UNIT_ASSERT(!!TryGetHttpCodeFromErrorDescription(line)); \
- UNIT_ASSERT_EQUAL(*TryGetHttpCodeFromErrorDescription(line), code)
+#define CHECK_VALID_LINE(line, code) \
+ UNIT_ASSERT_NO_EXCEPTION(TryGetHttpCodeFromErrorDescription(line)); \
+ UNIT_ASSERT(!!TryGetHttpCodeFromErrorDescription(line)); \
+ UNIT_ASSERT_EQUAL(*TryGetHttpCodeFromErrorDescription(line), code)
CHECK_VALID_LINE(TStringBuf("library/cpp/neh/http.cpp:<LINE>: request failed(HTTP/1.0 200 Some random message"), 200);
CHECK_VALID_LINE(TStringBuf("library/cpp/neh/http.cpp:<LINE>: request failed(HTTP/1.0 404 Some random message"), 404);
@@ -189,9 +189,9 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) {
CHECK_VALID_LINE(TStringBuf("request failed(HTTP/1.1 2004 Some random message"), 200);
#undef CHECK_VALID_LINE
-#define CHECK_INVALID_LINE(line) \
- UNIT_ASSERT_NO_EXCEPTION(TryGetHttpCodeFromErrorDescription(line)); \
- UNIT_ASSERT(!TryGetHttpCodeFromErrorDescription(line))
+#define CHECK_INVALID_LINE(line) \
+ UNIT_ASSERT_NO_EXCEPTION(TryGetHttpCodeFromErrorDescription(line)); \
+ UNIT_ASSERT(!TryGetHttpCodeFromErrorDescription(line))
CHECK_INVALID_LINE(TStringBuf("library/cpp/neh/http.cpp:<LINE>: request failed(HTTP/1.1 1 Some random message"));
CHECK_INVALID_LINE(TStringBuf("request failed(HTTP/1.0 asdf Some random message"));
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 51d75762f6..b0925c5a6b 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;
}
}
diff --git a/library/cpp/messagebus/rain_check/http/http_code_extractor.h b/library/cpp/messagebus/rain_check/http/http_code_extractor.h
index 33b565fa1c..322fe24fa0 100644
--- a/library/cpp/messagebus/rain_check/http/http_code_extractor.h
+++ b/library/cpp/messagebus/rain_check/http/http_code_extractor.h
@@ -10,7 +10,7 @@ namespace NRainCheck {
// 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.
- TMaybe<HttpCodes> TryGetHttpCodeFromErrorDescription(const TStringBuf& errorMessage);
+ // find out HttpCode in it. It is bad temporary solution, but we have no choice.
+ TMaybe<HttpCodes> TryGetHttpCodeFromErrorDescription(const TStringBuf& errorMessage);
-}
+}