fix on-push-commit-check
All checks were successful
PR Check / on-push-commit-check (push) Successful in 13m18s
All checks were successful
PR Check / on-push-commit-check (push) Successful in 13m18s
This commit is contained in:
parent
ee408b7ff8
commit
28147ee0e3
1 changed files with 8 additions and 7 deletions
|
@ -160,10 +160,10 @@ struct StartTlsRequest {
|
||||||
template <typename Socket>
|
template <typename Socket>
|
||||||
auto ConnectViaProxy(Socket& socket, const HttpProxy& param_proxy, std::string_view host, std::uint16_t port)
|
auto ConnectViaProxy(Socket& socket, const HttpProxy& param_proxy, std::string_view host, std::uint16_t port)
|
||||||
-> boost::asio::awaitable<void> {
|
-> boost::asio::awaitable<void> {
|
||||||
constexpr char kHttpVersion[] = "HTTP/1.1";
|
constexpr std::string_view kHttpVersion = "HTTP/1.1";
|
||||||
constexpr unsigned int kSuccessStatusCode = 200;
|
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 запрос
|
// HTTP CONNECT запрос
|
||||||
std::string request = std::format("CONNECT {}:{} {}\r\nHost: {}:{}\r\n\r\n", host, port, kHttpVersion, host, port);
|
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;
|
response_stream >> http_version >> status_code;
|
||||||
std::getline(response_stream, status_message);
|
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");
|
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>
|
template <typename Socket>
|
||||||
auto ConnectWithProxy(Socket& socket, const Proxy& proxy, std::string_view host, std::uint16_t port) -> boost::asio::awaitable<void> {
|
auto ConnectWithProxy(Socket& socket, const Proxy& proxy, std::string_view host, std::uint16_t port) -> boost::asio::awaitable<void> {
|
||||||
co_await std::visit(
|
auto awaitable = std::visit(
|
||||||
[&socket, host, port](const auto& proxy_variant) -> boost::asio::awaitable<void> {
|
[&socket, host, port](const auto& proxy_variant) {
|
||||||
co_await ConnectToServer(socket, proxy_variant, host, port);
|
return ConnectToServer(socket, proxy_variant, host, port);
|
||||||
},
|
},
|
||||||
proxy);
|
proxy);
|
||||||
|
co_await awaitable;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto GetAuthData(const PlainUserAccount& account) -> std::string {
|
inline auto GetAuthData(const PlainUserAccount& account) -> std::string {
|
||||||
|
|
Loading…
Reference in a new issue