diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-02-28 23:59:20 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-01 00:13:10 +0300 |
commit | b04e2faf41bf366d5f501c976bda00eb32d55660 (patch) | |
tree | f922ace378c0c471d912c33f2c0231144f898d78 /library | |
parent | 9ba742f4d36b4a3d879b4cf8d9234165413f4a0d (diff) | |
download | ydb-b04e2faf41bf366d5f501c976bda00eb32d55660.tar.gz |
Intermediate changes
commit_hash:e2da3ad430fabaa84a74178b1f2103b09ac69ae7
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/neh/http_common.cpp | 27 | ||||
-rw-r--r-- | library/cpp/neh/http_common.h | 3 | ||||
-rw-r--r-- | library/cpp/neh/https.cpp | 32 |
3 files changed, 31 insertions, 31 deletions
diff --git a/library/cpp/neh/http_common.cpp b/library/cpp/neh/http_common.cpp index 7ae466c31a..23ed6a2889 100644 --- a/library/cpp/neh/http_common.cpp +++ b/library/cpp/neh/http_common.cpp @@ -231,5 +231,32 @@ namespace NNeh { return NeedGetRequestFor(scheme) || NeedPostRequestFor(scheme); } } + + HttpCodes GetHttpCode(const IRequest::TResponseError& error) { + switch (error) { + case IRequest::TResponseError::BadRequest: + return HttpCodes::HTTP_BAD_REQUEST; + case IRequest::TResponseError::Forbidden: + return HttpCodes::HTTP_FORBIDDEN; + case IRequest::TResponseError::NotExistService: + return HttpCodes::HTTP_NOT_FOUND; + case IRequest::TResponseError::TooManyRequests: + return HttpCodes::HTTP_TOO_MANY_REQUESTS; + case IRequest::TResponseError::InternalError: + return HttpCodes::HTTP_INTERNAL_SERVER_ERROR; + case IRequest::TResponseError::NotImplemented: + return HttpCodes::HTTP_NOT_IMPLEMENTED; + case IRequest::TResponseError::BadGateway: + return HttpCodes::HTTP_BAD_GATEWAY; + case IRequest::TResponseError::ServiceUnavailable: + return HttpCodes::HTTP_SERVICE_UNAVAILABLE; + case IRequest::TResponseError::BandwidthLimitExceeded: + return HttpCodes::HTTP_BANDWIDTH_LIMIT_EXCEEDED; + case IRequest::TResponseError::MaxResponseError: + ythrow yexception() << TStringBuf("unknow type of error"); + + Y_UNREACHABLE(); + } + } } diff --git a/library/cpp/neh/http_common.h b/library/cpp/neh/http_common.h index 69659ba907..acefe80c37 100644 --- a/library/cpp/neh/http_common.h +++ b/library/cpp/neh/http_common.h @@ -7,6 +7,7 @@ #include <util/stream/mem.h> #include <util/stream/output.h> #include <library/cpp/deprecated/atomic/atomic.h> +#include <library/cpp/http/misc/httpcodes.h> #include "location.h" #include "neh.h" @@ -298,4 +299,6 @@ namespace NNeh { bool IsHttpScheme(TStringBuf scheme); } + + HttpCodes GetHttpCode(const IRequest::TResponseError&); } diff --git a/library/cpp/neh/https.cpp b/library/cpp/neh/https.cpp index f1a2ec9e7e..ece7d3cf2d 100644 --- a/library/cpp/neh/https.cpp +++ b/library/cpp/neh/https.cpp @@ -1394,37 +1394,7 @@ namespace NNeh { return; } - switch (*error) { - case IRequest::TResponseError::BadRequest: - os << HttpCodeStrEx(HttpCodes::HTTP_BAD_REQUEST); - break; - case IRequest::TResponseError::Forbidden: - os << HttpCodeStrEx(HttpCodes::HTTP_FORBIDDEN); - break; - case IRequest::TResponseError::NotExistService: - os << HttpCodeStrEx(HttpCodes::HTTP_NOT_FOUND); - break; - case IRequest::TResponseError::TooManyRequests: - os << HttpCodeStrEx(HttpCodes::HTTP_TOO_MANY_REQUESTS); - break; - case IRequest::TResponseError::InternalError: - os << HttpCodeStrEx(HttpCodes::HTTP_INTERNAL_SERVER_ERROR); - break; - case IRequest::TResponseError::NotImplemented: - os << HttpCodeStrEx(HttpCodes::HTTP_NOT_IMPLEMENTED); - break; - case IRequest::TResponseError::BadGateway: - os << HttpCodeStrEx(HttpCodes::HTTP_BAD_GATEWAY); - break; - case IRequest::TResponseError::ServiceUnavailable: - os << HttpCodeStrEx(HttpCodes::HTTP_SERVICE_UNAVAILABLE); - break; - case IRequest::TResponseError::BandwidthLimitExceeded: - os << HttpCodeStrEx(HttpCodes::HTTP_BANDWIDTH_LIMIT_EXCEEDED); - break; - case IRequest::TResponseError::MaxResponseError: - ythrow yexception() << TStringBuf("unknow type of error"); - } + os << HttpCodeStrEx(GetHttpCode(*error)); } public: |