summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaloyan Chehlarski <kaloyan.chehlarski@qt.io>2025-09-25 12:59:04 +0200
committerKaloyan Chehlarski <kaloyan.chehlarski@qt.io>2025-10-01 16:17:09 +0200
commitec2ad7c978ea86b0c03d8b0987f7421da40d75ff (patch)
treee01e7b041aaec4d2a5f8de98e6ef5467cb1547d7
parentce191e5f3503b3026aa46cfeef7b04e4fda92cbd (diff)
Fix user agent override when intercepting a redirect
When a redirect is followed, Chromium will inject the profile's default user agent string into the list of headers to modify for the redirect request. This effectively clears any user-provided user agent overrides. This change removes the User-Agent header from the list of modified headers, allowing the user-supplied one to be used instead. Fixes: QTBUG-140515 Pick-to: 6.10 6.9 6.8 Change-Id: I444a286cc5ca728a2d8abcd51eee69cf95a4e543 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index fd3ef9fa0..120b8c589 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -463,8 +463,14 @@ void InterceptedRequest::FollowRedirect(const std::vector<std::string> &removed_
const net::HttpRequestHeaders &modified_cors_exempt_headers,
const std::optional<GURL> &new_url)
{
+ // On a redirect, Chromium will add User-Agent to the list of modified headers,
+ // which will erase any user-provided overrides. Remove it from the list to keep
+ // the user-supplied one for the redirect
+ net::HttpRequestHeaders interceptedModifiedHeaders = modified_headers;
+ interceptedModifiedHeaders.RemoveHeader("User-Agent");
+
if (target_loader_)
- target_loader_->FollowRedirect(removed_headers, modified_headers, modified_cors_exempt_headers, new_url);
+ target_loader_->FollowRedirect(removed_headers, interceptedModifiedHeaders, modified_cors_exempt_headers, new_url);
// If |OnURLLoaderClientError| was called then we're just waiting for the
// connection error handler of |proxied_loader_binding_|. Don't restart the