From 28147ee0e3c31a65ccffca256f69d747b39cdc70 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 16 Nov 2024 22:36:39 +0300 Subject: [PATCH] fix on-push-commit-check --- library/include/larra/client/client.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/library/include/larra/client/client.hpp b/library/include/larra/client/client.hpp index 6791f7a..c9a2465 100644 --- a/library/include/larra/client/client.hpp +++ b/library/include/larra/client/client.hpp @@ -160,10 +160,10 @@ struct StartTlsRequest { template auto ConnectViaProxy(Socket& socket, const HttpProxy& param_proxy, std::string_view host, std::uint16_t port) -> boost::asio::awaitable { - constexpr char kHttpVersion[] = "HTTP/1.1"; + constexpr std::string_view kHttpVersion = "HTTP/1.1"; constexpr unsigned int kSuccessStatusCode = 200; - constexpr char kEndOfHeaders[] = "\r\n\r\n"; - + constexpr std::string_view kEndOfHeaders = "\r\n\r\n"; + constexpr int kEndOfHttpSubstring = 5; // HTTP CONNECT запрос std::string request = std::format("CONNECT {}:{} {}\r\nHost: {}:{}\r\n\r\n", host, port, kHttpVersion, host, port); @@ -182,7 +182,7 @@ auto ConnectViaProxy(Socket& socket, const HttpProxy& param_proxy, std::string_v response_stream >> http_version >> status_code; std::getline(response_stream, status_message); - if(!response_stream || http_version.substr(0, 5) != "HTTP/") { + if(!response_stream || http_version.substr(0, kEndOfHttpSubstring) != "HTTP/") { throw std::runtime_error("Invalid HTTP response from proxy"); } @@ -308,11 +308,12 @@ auto ConnectToServer(Socket& socket, const SystemConfiguredProxy& proxy, std::st template auto ConnectWithProxy(Socket& socket, const Proxy& proxy, std::string_view host, std::uint16_t port) -> boost::asio::awaitable { - co_await std::visit( - [&socket, host, port](const auto& proxy_variant) -> boost::asio::awaitable { - co_await ConnectToServer(socket, proxy_variant, host, port); + auto awaitable = std::visit( + [&socket, host, port](const auto& proxy_variant) { + return ConnectToServer(socket, proxy_variant, host, port); }, proxy); + co_await awaitable; } inline auto GetAuthData(const PlainUserAccount& account) -> std::string {