mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Add hack for computing the request referer during load
This is a temporary hack until navigables are used to load pages, which uses fetch infrastructure that does this according to spec.
This commit is contained in:
parent
029160fd27
commit
7192cf7487
Notes:
sideshowbarker
2024-07-17 06:35:16 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/7192cf7487 Pull-request: https://github.com/SerenityOS/serenity/pull/20549
1 changed files with 7 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/ImageCodecPlugin.h>
|
||||
#include <LibWeb/ReferrerPolicy/AbstractOperations.h>
|
||||
#include <LibWeb/XML/XMLDocumentBuilder.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -77,6 +78,12 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
|||
if (!request.headers().contains("Accept"))
|
||||
request.set_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
||||
|
||||
// HACK: We're crudely computing the referer value and shoving it into the
|
||||
// request until fetch infrastructure is used here.
|
||||
auto referrer_url = ReferrerPolicy::strip_url_for_use_as_referrer(url);
|
||||
if (referrer_url.has_value() && !request.headers().contains("Referer"))
|
||||
request.set_header("Referer", referrer_url->serialize());
|
||||
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
|
||||
if (type == Type::IFrame)
|
||||
|
|
Loading…
Reference in a new issue