From 9dc63fbb8cb9468eb9a2efbeab6bcabd8398be5a Mon Sep 17 00:00:00 2001 From: klzgrad Date: Mon, 22 Jul 2024 00:21:45 +0800 Subject: [PATCH] net: Allow http proxies in proxy chains --- src/net/base/proxy_chain.cc | 2 +- src/net/http/http_proxy_connect_job.cc | 14 +++++++++++--- src/net/http/http_proxy_connect_job.h | 7 +++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/net/base/proxy_chain.cc b/src/net/base/proxy_chain.cc index 4288cc30bf..5ae183287c 100644 --- a/src/net/base/proxy_chain.cc +++ b/src/net/base/proxy_chain.cc @@ -137,7 +137,7 @@ bool ProxyChain::IsValidInternal() const { return false; } seen_quic = true; - } else if (proxy_server.is_https()) { + } else if (proxy_server.is_https() || proxy_server.is_http()) { seen_https = true; } else { return false; diff --git a/src/net/http/http_proxy_connect_job.cc b/src/net/http/http_proxy_connect_job.cc index f11edb5dbc..b70d876a5d 100644 --- a/src/net/http/http_proxy_connect_job.cc +++ b/src/net/http/http_proxy_connect_job.cc @@ -487,9 +487,17 @@ int HttpProxyConnectJob::DoBeginConnect() { int HttpProxyConnectJob::DoTransportConnect() { ProxyServer::Scheme scheme = GetProxyServerScheme(); if (scheme == ProxyServer::SCHEME_HTTP) { - nested_connect_job_ = std::make_unique( - priority(), socket_tag(), common_connect_job_params(), - params_->transport_params(), this, &net_log()); + if (params_->is_over_transport()) { + nested_connect_job_ = std::make_unique( + priority(), socket_tag(), common_connect_job_params(), + params_->transport_params(), this, &net_log()); + } else if (params_->is_over_http()) { + nested_connect_job_ = std::make_unique( + priority(), socket_tag(), common_connect_job_params(), + params_->http_params(), this, &net_log()); + } else { + CHECK(false) << "Invalid nested connect job"; + } } else { DCHECK_EQ(scheme, ProxyServer::SCHEME_HTTPS); DCHECK(params_->is_over_ssl()); diff --git a/src/net/http/http_proxy_connect_job.h b/src/net/http/http_proxy_connect_job.h index c176371fbc..afc09d1a97 100644 --- a/src/net/http/http_proxy_connect_job.h +++ b/src/net/http/http_proxy_connect_job.h @@ -99,6 +99,13 @@ class NET_EXPORT_PRIVATE HttpProxySocketParams return quic_ssl_config_; } + bool is_over_http() const { + return nested_params_ && nested_params_->is_http_proxy(); + } + const scoped_refptr& http_params() const { + return nested_params_->http_proxy(); + } + const HostPortPair& endpoint() const { return endpoint_; } const ProxyChain& proxy_chain() const { return proxy_chain_; } const ProxyServer& proxy_server() const {