mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 23:28:12 +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
1 changed files with 7 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <LibWeb/Namespace.h>
|
#include <LibWeb/Namespace.h>
|
||||||
#include <LibWeb/Page/Page.h>
|
#include <LibWeb/Page/Page.h>
|
||||||
#include <LibWeb/Platform/ImageCodecPlugin.h>
|
#include <LibWeb/Platform/ImageCodecPlugin.h>
|
||||||
|
#include <LibWeb/ReferrerPolicy/AbstractOperations.h>
|
||||||
#include <LibWeb/XML/XMLDocumentBuilder.h>
|
#include <LibWeb/XML/XMLDocumentBuilder.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -77,6 +78,12 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
||||||
if (!request.headers().contains("Accept"))
|
if (!request.headers().contains("Accept"))
|
||||||
request.set_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
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));
|
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||||
|
|
||||||
if (type == Type::IFrame)
|
if (type == Type::IFrame)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue