diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-10-13 14:45:44 +0200 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-11-07 12:49:45 +0100 |
commit | eda7378655fa047007dcdb47aec3641b2a89d0de (patch) | |
tree | bee30f279431ef3f9e99a64aeb10a0fe3444b4cd /src/core/net | |
parent | ec27984cfb257e94a0ca6fdb2e40c278fdf94663 (diff) |
Let page interceptor process requests with extra headers
If a QWebEngineUrlRequestInterceptor has added extra headers to
the request on profile level, later the request was not processed
by the page interceptor. Relax this rule and only prevent the
interception of blocked or redirected requests.
Add auto test and extend documentation.
Pick-to: 6.6
Task-number: QTBUG-117752
Change-Id: I503bfc256a5e874a678be64c597c74e04e7ce966
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/net')
-rw-r--r-- | src/core/net/proxying_url_loader_factory_qt.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp index 7fd7a866d..3a83ed7ea 100644 --- a/src/core/net/proxying_url_loader_factory_qt.cpp +++ b/src/core/net/proxying_url_loader_factory_qt.cpp @@ -364,19 +364,18 @@ void InterceptedRequest::ContinueAfterIntercept() const auto scoped_request_info = std::move(request_info_); QWebEngineUrlRequestInfoPrivate &info = *scoped_request_info->d_ptr; + for (auto header = info.extraHeaders.constBegin(); header != info.extraHeaders.constEnd(); ++header) { + std::string h = header.key().toStdString(); + if (base::EqualsCaseInsensitiveASCII(h, "referer")) + request_.referrer = GURL(header.value().toStdString()); + else + request_.headers.SetHeader(h, header.value().toStdString()); + } + if (info.changed) { if (info.shouldBlockRequest) return SendErrorAndCompleteImmediately(net::ERR_BLOCKED_BY_CLIENT); - for (auto header = info.extraHeaders.constBegin(); header != info.extraHeaders.constEnd(); ++header) { - std::string h = header.key().toStdString(); - if (base::EqualsCaseInsensitiveASCII(h, "referer")) { - request_.referrer = GURL(header.value().toStdString()); - } else { - request_.headers.SetHeader(h, header.value().toStdString()); - } - } - if (info.shouldRedirectRequest) { net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy = request_.update_first_party_url_on_redirect ? net::RedirectInfo::FirstPartyURLPolicy::UPDATE_URL_ON_REDIRECT |