fix on-push-commit-check
All checks were successful
PR Check / on-push-commit-check (push) Successful in 13m18s

This commit is contained in:
Anton 2024-11-16 22:36:39 +03:00
parent ee408b7ff8
commit 28147ee0e3

View file

@ -160,10 +160,10 @@ struct StartTlsRequest {
template <typename Socket>
auto ConnectViaProxy(Socket& socket, const HttpProxy& param_proxy, std::string_view host, std::uint16_t port)
-> boost::asio::awaitable<void> {
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 <typename Socket>
auto ConnectWithProxy(Socket& socket, const Proxy& proxy, std::string_view host, std::uint16_t port) -> boost::asio::awaitable<void> {
co_await std::visit(
[&socket, host, port](const auto& proxy_variant) -> boost::asio::awaitable<void> {
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 {