diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-04-08 01:46:47 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-09 12:21:43 +0200 |
commit | a42e03b01a7c2c98377f3851cb4e5f07d7e3ba35 (patch) | |
tree | 812e97db21dee65573b5a669a2b643ee4ea83426 /Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | |
parent | f9fc28931fe42700bbfc8964a0a7ceb5940a46f7 (diff) | |
download | serenity-a42e03b01a7c2c98377f3851cb4e5f07d7e3ba35.zip |
Browser+LibWeb+WebContent: Implement per-URL-pattern proxies
...at least for SOCKS5.
Diffstat (limited to 'Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 737598cc3d..76a634f80f 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -14,6 +14,7 @@ #include <LibProtocol/RequestClient.h> #include <LibWeb/Loader/ContentFilter.h> #include <LibWeb/Loader/LoadRequest.h> +#include <LibWeb/Loader/ProxyMappings.h> #include <LibWeb/Loader/Resource.h> #include <LibWeb/Loader/ResourceLoader.h> #include <serenity.h> @@ -213,6 +214,9 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has } if (url.protocol() == "http" || url.protocol() == "https" || url.protocol() == "gemini") { + auto proxy = ProxyMappings::the().proxy_for_url(url); + dbgln("Proxy for {} is {}", url, proxy.type == decltype(proxy.type)::SOCKS5 ? IPv4Address(proxy.host_ipv4).to_string() : "(direct)"); + HashMap<String, String> headers; headers.set("User-Agent", m_user_agent); headers.set("Accept-Encoding", "gzip, deflate"); @@ -221,7 +225,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has headers.set(it.key, it.value); } - auto protocol_request = protocol_client().start_request(request.method(), url, headers, request.body()); + auto protocol_request = protocol_client().start_request(request.method(), url, headers, request.body(), proxy); if (!protocol_request) { auto start_request_failure_msg = "Failed to initiate load"sv; log_failure(request, start_request_failure_msg); |