2022-07-14 00:51:42 +01:00
|
|
|
|
/*
|
2023-03-02 23:26:35 +00:00
|
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2023-10-29 02:49:22 +01:00
|
|
|
|
* Copyright (c) 2023, networkException <networkexception@serenityos.org>
|
2022-07-14 00:51:42 +01:00
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
|
#include <AK/Error.h>
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
#include <AK/Optional.h>
|
2023-03-02 23:26:35 +00:00
|
|
|
|
#include <AK/String.h>
|
2022-07-14 00:51:42 +01:00
|
|
|
|
#include <AK/Variant.h>
|
|
|
|
|
#include <AK/Vector.h>
|
2024-11-15 04:01:23 +13:00
|
|
|
|
#include <LibGC/Ptr.h>
|
2022-10-30 01:52:07 +00:00
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
|
#include <LibJS/Heap/Cell.h>
|
2024-10-05 15:33:34 +13:00
|
|
|
|
#include <LibURL/Origin.h>
|
2024-03-18 16:22:27 +13:00
|
|
|
|
#include <LibURL/URL.h>
|
2022-07-14 00:51:42 +01:00
|
|
|
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
|
|
|
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
|
|
|
|
|
#include <LibWeb/HTML/PolicyContainers.h>
|
|
|
|
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
|
|
|
|
|
2022-07-17 23:52:02 +01:00
|
|
|
|
namespace Web::Fetch::Infrastructure {
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request
|
2022-10-30 01:52:07 +00:00
|
|
|
|
class Request final : public JS::Cell {
|
2024-11-15 04:01:23 +13:00
|
|
|
|
GC_CELL(Request, JS::Cell);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(Request);
|
2022-10-30 01:52:07 +00:00
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
public:
|
|
|
|
|
enum class CacheMode {
|
|
|
|
|
Default,
|
|
|
|
|
NoStore,
|
|
|
|
|
Reload,
|
|
|
|
|
NoCache,
|
|
|
|
|
ForceCache,
|
|
|
|
|
OnlyIfCached,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class CredentialsMode {
|
|
|
|
|
Omit,
|
|
|
|
|
SameOrigin,
|
|
|
|
|
Include,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Destination {
|
|
|
|
|
Audio,
|
|
|
|
|
AudioWorklet,
|
|
|
|
|
Document,
|
|
|
|
|
Embed,
|
|
|
|
|
Font,
|
|
|
|
|
Frame,
|
|
|
|
|
IFrame,
|
|
|
|
|
Image,
|
2024-04-29 20:11:02 +01:00
|
|
|
|
JSON,
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Manifest,
|
|
|
|
|
Object,
|
|
|
|
|
PaintWorklet,
|
|
|
|
|
Report,
|
|
|
|
|
Script,
|
|
|
|
|
ServiceWorker,
|
|
|
|
|
SharedWorker,
|
|
|
|
|
Style,
|
|
|
|
|
Track,
|
|
|
|
|
Video,
|
2022-10-15 00:42:52 +02:00
|
|
|
|
WebIdentity,
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Worker,
|
|
|
|
|
XSLT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Initiator {
|
|
|
|
|
Download,
|
|
|
|
|
ImageSet,
|
|
|
|
|
Manifest,
|
|
|
|
|
Prefetch,
|
|
|
|
|
Prerender,
|
|
|
|
|
XSLT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class InitiatorType {
|
|
|
|
|
Audio,
|
|
|
|
|
Beacon,
|
|
|
|
|
Body,
|
|
|
|
|
CSS,
|
|
|
|
|
EarlyHint,
|
|
|
|
|
Embed,
|
|
|
|
|
Fetch,
|
|
|
|
|
Font,
|
|
|
|
|
Frame,
|
|
|
|
|
IFrame,
|
|
|
|
|
Image,
|
|
|
|
|
IMG,
|
|
|
|
|
Input,
|
|
|
|
|
Link,
|
|
|
|
|
Object,
|
|
|
|
|
Ping,
|
|
|
|
|
Script,
|
|
|
|
|
Track,
|
|
|
|
|
Video,
|
|
|
|
|
XMLHttpRequest,
|
|
|
|
|
Other,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Mode {
|
|
|
|
|
SameOrigin,
|
|
|
|
|
CORS,
|
|
|
|
|
NoCORS,
|
|
|
|
|
Navigate,
|
|
|
|
|
WebSocket,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Origin {
|
|
|
|
|
Client,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ParserMetadata {
|
|
|
|
|
ParserInserted,
|
|
|
|
|
NotParserInserted,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class PolicyContainer {
|
|
|
|
|
Client,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class RedirectMode {
|
|
|
|
|
Follow,
|
|
|
|
|
Error,
|
|
|
|
|
Manual,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Referrer {
|
|
|
|
|
NoReferrer,
|
|
|
|
|
Client,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ResponseTainting {
|
|
|
|
|
Basic,
|
|
|
|
|
CORS,
|
|
|
|
|
Opaque,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ServiceWorkersMode {
|
|
|
|
|
All,
|
|
|
|
|
None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Window {
|
|
|
|
|
NoWindow,
|
|
|
|
|
Client,
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-29 02:49:22 +01:00
|
|
|
|
enum class Priority {
|
|
|
|
|
High,
|
|
|
|
|
Low,
|
|
|
|
|
Auto
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-26 08:03:29 -04:00
|
|
|
|
// AD-HOC: Some web features need to receive data as it arrives, rather than when the response is fully complete
|
|
|
|
|
// or when enough data has been buffered. Use this buffer policy to inform fetch of that requirement.
|
|
|
|
|
enum class BufferPolicy {
|
|
|
|
|
BufferResponse,
|
|
|
|
|
DoNotBufferResponse,
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
// Members are implementation-defined
|
2023-10-29 02:49:22 +01:00
|
|
|
|
struct InternalPriority { };
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
using BodyType = Variant<Empty, ByteBuffer, GC::Ref<Body>>;
|
2024-10-05 15:33:34 +13:00
|
|
|
|
using OriginType = Variant<Origin, URL::Origin>;
|
2024-11-25 14:30:12 +00:00
|
|
|
|
using PolicyContainerType = Variant<PolicyContainer, GC::Ref<HTML::PolicyContainer>>;
|
2024-03-18 16:22:27 +13:00
|
|
|
|
using ReferrerType = Variant<Referrer, URL::URL>;
|
2024-11-15 04:01:23 +13:00
|
|
|
|
using ReservedClientType = GC::Ptr<HTML::Environment>;
|
|
|
|
|
using WindowType = Variant<Window, GC::Ptr<HTML::EnvironmentSettingsObject>>;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
[[nodiscard]] static GC::Ref<Request> create(JS::VM&);
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2022-09-24 00:23:55 +01:00
|
|
|
|
[[nodiscard]] ReadonlyBytes method() const { return m_method; }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
void set_method(ByteBuffer method) { m_method = move(method); }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool local_urls_only() const { return m_local_urls_only; }
|
|
|
|
|
void set_local_urls_only(bool local_urls_only) { m_local_urls_only = local_urls_only; }
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
[[nodiscard]] GC::Ref<HeaderList> header_list() const { return m_header_list; }
|
|
|
|
|
void set_header_list(GC::Ref<HeaderList> header_list) { m_header_list = header_list; }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool unsafe_request() const { return m_unsafe_request; }
|
|
|
|
|
void set_unsafe_request(bool unsafe_request) { m_unsafe_request = unsafe_request; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] BodyType const& body() const { return m_body; }
|
|
|
|
|
[[nodiscard]] BodyType& body() { return m_body; }
|
|
|
|
|
void set_body(BodyType body) { m_body = move(body); }
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
[[nodiscard]] GC::Ptr<HTML::EnvironmentSettingsObject const> client() const { return m_client; }
|
|
|
|
|
[[nodiscard]] GC::Ptr<HTML::EnvironmentSettingsObject> client() { return m_client; }
|
2022-10-04 23:43:37 +01:00
|
|
|
|
void set_client(HTML::EnvironmentSettingsObject* client) { m_client = client; }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] ReservedClientType const& reserved_client() const { return m_reserved_client; }
|
|
|
|
|
[[nodiscard]] ReservedClientType& reserved_client() { return m_reserved_client; }
|
|
|
|
|
void set_reserved_client(ReservedClientType reserved_client) { m_reserved_client = move(reserved_client); }
|
|
|
|
|
|
2023-03-02 23:26:35 +00:00
|
|
|
|
[[nodiscard]] String const& replaces_client_id() const { return m_replaces_client_id; }
|
|
|
|
|
void set_replaces_client_id(String replaces_client_id) { m_replaces_client_id = move(replaces_client_id); }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] WindowType const& window() const { return m_window; }
|
|
|
|
|
void set_window(WindowType window) { m_window = move(window); }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool keepalive() const { return m_keepalive; }
|
|
|
|
|
void set_keepalive(bool keepalive) { m_keepalive = keepalive; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] Optional<InitiatorType> const& initiator_type() const { return m_initiator_type; }
|
|
|
|
|
void set_initiator_type(Optional<InitiatorType> initiator_type) { m_initiator_type = move(initiator_type); }
|
|
|
|
|
|
2022-09-24 00:23:55 +01:00
|
|
|
|
[[nodiscard]] ServiceWorkersMode service_workers_mode() const { return m_service_workers_mode; }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
void set_service_workers_mode(ServiceWorkersMode service_workers_mode) { m_service_workers_mode = service_workers_mode; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] Optional<Initiator> const& initiator() const { return m_initiator; }
|
|
|
|
|
void set_initiator(Optional<Initiator> initiator) { m_initiator = move(initiator); }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] Optional<Destination> const& destination() const { return m_destination; }
|
|
|
|
|
void set_destination(Optional<Destination> destination) { m_destination = move(destination); }
|
|
|
|
|
|
2023-10-29 02:49:22 +01:00
|
|
|
|
[[nodiscard]] Priority const& priority() const { return m_priority; }
|
|
|
|
|
void set_priority(Priority priority) { m_priority = priority; }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] OriginType const& origin() const { return m_origin; }
|
|
|
|
|
void set_origin(OriginType origin) { m_origin = move(origin); }
|
|
|
|
|
|
2022-10-04 23:45:28 +01:00
|
|
|
|
[[nodiscard]] PolicyContainerType const& policy_container() const { return m_policy_container; }
|
|
|
|
|
void set_policy_container(PolicyContainerType policy_container) { m_policy_container = move(policy_container); }
|
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
[[nodiscard]] Mode mode() const { return m_mode; }
|
|
|
|
|
void set_mode(Mode mode) { m_mode = mode; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool use_cors_preflight() const { return m_use_cors_preflight; }
|
|
|
|
|
void set_use_cors_preflight(bool use_cors_preflight) { m_use_cors_preflight = use_cors_preflight; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] CredentialsMode credentials_mode() const { return m_credentials_mode; }
|
|
|
|
|
void set_credentials_mode(CredentialsMode credentials_mode) { m_credentials_mode = credentials_mode; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool use_url_credentials() const { return m_use_url_credentials; }
|
|
|
|
|
void set_use_url_credentials(bool use_url_credentials) { m_use_url_credentials = use_url_credentials; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] CacheMode cache_mode() const { return m_cache_mode; }
|
|
|
|
|
void set_cache_mode(CacheMode cache_mode) { m_cache_mode = cache_mode; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] RedirectMode redirect_mode() const { return m_redirect_mode; }
|
|
|
|
|
void set_redirect_mode(RedirectMode redirect_mode) { m_redirect_mode = redirect_mode; }
|
|
|
|
|
|
2023-03-02 23:26:35 +00:00
|
|
|
|
[[nodiscard]] String const& integrity_metadata() const { return m_integrity_metadata; }
|
|
|
|
|
void set_integrity_metadata(String integrity_metadata) { m_integrity_metadata = move(integrity_metadata); }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2023-03-02 23:26:35 +00:00
|
|
|
|
[[nodiscard]] String const& cryptographic_nonce_metadata() const { return m_cryptographic_nonce_metadata; }
|
|
|
|
|
void set_cryptographic_nonce_metadata(String cryptographic_nonce_metadata) { m_cryptographic_nonce_metadata = move(cryptographic_nonce_metadata); }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] Optional<ParserMetadata> const& parser_metadata() const { return m_parser_metadata; }
|
|
|
|
|
void set_parser_metadata(Optional<ParserMetadata> parser_metadata) { m_parser_metadata = move(parser_metadata); }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool reload_navigation() const { return m_reload_navigation; }
|
|
|
|
|
void set_reload_navigation(bool reload_navigation) { m_reload_navigation = reload_navigation; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool history_navigation() const { return m_history_navigation; }
|
|
|
|
|
void set_history_navigation(bool history_navigation) { m_history_navigation = history_navigation; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool user_activation() const { return m_user_activation; }
|
|
|
|
|
void set_user_activation(bool user_activation) { m_user_activation = user_activation; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool render_blocking() const { return m_render_blocking; }
|
|
|
|
|
void set_render_blocking(bool render_blocking) { m_render_blocking = render_blocking; }
|
|
|
|
|
|
2024-03-18 16:22:27 +13:00
|
|
|
|
[[nodiscard]] Vector<URL::URL> const& url_list() const { return m_url_list; }
|
|
|
|
|
[[nodiscard]] Vector<URL::URL>& url_list() { return m_url_list; }
|
|
|
|
|
void set_url_list(Vector<URL::URL> url_list) { m_url_list = move(url_list); }
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] u8 redirect_count() const { return m_redirect_count; }
|
|
|
|
|
void set_redirect_count(u8 redirect_count) { m_redirect_count = redirect_count; }
|
|
|
|
|
|
2022-09-20 10:47:24 +02:00
|
|
|
|
[[nodiscard]] ReferrerType const& referrer() const { return m_referrer; }
|
|
|
|
|
void set_referrer(ReferrerType referrer) { m_referrer = move(referrer); }
|
|
|
|
|
|
2024-03-05 09:35:25 -07:00
|
|
|
|
[[nodiscard]] ReferrerPolicy::ReferrerPolicy const& referrer_policy() const { return m_referrer_policy; }
|
|
|
|
|
void set_referrer_policy(ReferrerPolicy::ReferrerPolicy referrer_policy) { m_referrer_policy = move(referrer_policy); }
|
2022-09-24 00:29:45 +01:00
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
[[nodiscard]] ResponseTainting response_tainting() const { return m_response_tainting; }
|
|
|
|
|
void set_response_tainting(ResponseTainting response_tainting) { m_response_tainting = response_tainting; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool prevent_no_cache_cache_control_header_modification() const { return m_prevent_no_cache_cache_control_header_modification; }
|
|
|
|
|
void set_prevent_no_cache_cache_control_header_modification(bool prevent_no_cache_cache_control_header_modification) { m_prevent_no_cache_cache_control_header_modification = prevent_no_cache_cache_control_header_modification; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool done() const { return m_done; }
|
|
|
|
|
void set_done(bool done) { m_done = done; }
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool timing_allow_failed() const { return m_timing_allow_failed; }
|
|
|
|
|
void set_timing_allow_failed(bool timing_allow_failed) { m_timing_allow_failed = timing_allow_failed; }
|
|
|
|
|
|
2024-03-18 16:22:27 +13:00
|
|
|
|
[[nodiscard]] URL::URL& url();
|
|
|
|
|
[[nodiscard]] URL::URL const& url() const;
|
|
|
|
|
[[nodiscard]] URL::URL& current_url();
|
|
|
|
|
[[nodiscard]] URL::URL const& current_url() const;
|
|
|
|
|
void set_url(URL::URL url);
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool destination_is_script_like() const;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool is_subresource_request() const;
|
|
|
|
|
[[nodiscard]] bool is_non_subresource_request() const;
|
|
|
|
|
[[nodiscard]] bool is_navigation_request() const;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool has_redirect_tainted_origin() const;
|
|
|
|
|
|
2024-04-26 13:35:10 -04:00
|
|
|
|
[[nodiscard]] String serialize_origin() const;
|
|
|
|
|
[[nodiscard]] ByteBuffer byte_serialize_origin() const;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
[[nodiscard]] GC::Ref<Request> clone(JS::Realm&) const;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2024-04-26 13:35:10 -04:00
|
|
|
|
void add_range_header(u64 first, Optional<u64> const& last);
|
|
|
|
|
void add_origin_header();
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
[[nodiscard]] bool cross_origin_embedder_policy_allows_credentials() const;
|
|
|
|
|
|
2022-11-01 19:35:38 +00:00
|
|
|
|
// Non-standard
|
2024-11-15 04:01:23 +13:00
|
|
|
|
void add_pending_response(Badge<Fetching::PendingResponse>, GC::Ref<Fetching::PendingResponse> pending_response)
|
2022-11-01 19:35:38 +00:00
|
|
|
|
{
|
|
|
|
|
VERIFY(!m_pending_responses.contains_slow(pending_response));
|
|
|
|
|
m_pending_responses.append(pending_response);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
|
void remove_pending_response(Badge<Fetching::PendingResponse>, GC::Ref<Fetching::PendingResponse> pending_response)
|
2022-11-01 19:35:38 +00:00
|
|
|
|
{
|
|
|
|
|
m_pending_responses.remove_first_matching([&](auto gc_ptr) { return gc_ptr == pending_response; });
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 08:03:29 -04:00
|
|
|
|
[[nodiscard]] BufferPolicy buffer_policy() const { return m_buffer_policy; }
|
|
|
|
|
void set_buffer_policy(BufferPolicy buffer_policy) { m_buffer_policy = buffer_policy; }
|
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
private:
|
2024-11-15 04:01:23 +13:00
|
|
|
|
explicit Request(GC::Ref<HeaderList>);
|
2022-10-30 01:52:07 +00:00
|
|
|
|
|
|
|
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
2022-10-04 23:45:47 +01:00
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-method
|
|
|
|
|
// A request has an associated method (a method). Unless stated otherwise it is `GET`.
|
2022-09-25 19:28:48 +01:00
|
|
|
|
ByteBuffer m_method { ByteBuffer::copy("GET"sv.bytes()).release_value() };
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#local-urls-only-flag
|
|
|
|
|
// A request has an associated local-URLs-only flag. Unless stated otherwise it is unset.
|
|
|
|
|
bool m_local_urls_only { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-header-list
|
|
|
|
|
// A request has an associated header list (a header list). Unless stated otherwise it is empty.
|
2024-11-15 04:01:23 +13:00
|
|
|
|
GC::Ref<HeaderList> m_header_list;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#unsafe-request-flag
|
|
|
|
|
// A request has an associated unsafe-request flag. Unless stated otherwise it is unset.
|
|
|
|
|
bool m_unsafe_request { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-body
|
|
|
|
|
// A request has an associated body (null, a byte sequence, or a body). Unless stated otherwise it is null.
|
|
|
|
|
BodyType m_body;
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-client
|
|
|
|
|
// A request has an associated client (null or an environment settings object).
|
2024-11-15 04:01:23 +13:00
|
|
|
|
GC::Ptr<HTML::EnvironmentSettingsObject> m_client;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-reserved-client
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated reserved client (null, an environment, or an environment settings object). Unless
|
|
|
|
|
// stated otherwise it is null.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
ReservedClientType m_reserved_client;
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-replaces-client-id
|
|
|
|
|
// A request has an associated replaces client id (a string). Unless stated otherwise it is the empty string.
|
2023-03-02 23:26:35 +00:00
|
|
|
|
String m_replaces_client_id;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-window
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated window ("no-window", "client", or an environment settings object whose global object
|
|
|
|
|
// is a Window object). Unless stated otherwise it is "client".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
WindowType m_window { Window::Client };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-keepalive-flag
|
|
|
|
|
// A request has an associated boolean keepalive. Unless stated otherwise it is false.
|
|
|
|
|
bool m_keepalive { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-initiator-type
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated initiator type, which is null, "audio", "beacon", "body", "css", "early-hint",
|
|
|
|
|
// "embed", "fetch", "font", "frame", "iframe", "image", "img", "input", "link", "object", "ping", "script",
|
|
|
|
|
// "track", "video", "xmlhttprequest", or "other". Unless stated otherwise it is null. [RESOURCE-TIMING]
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Optional<InitiatorType> m_initiator_type;
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-service-workers-mode
|
|
|
|
|
// A request has an associated service-workers mode, that is "all" or "none". Unless stated otherwise it is "all".
|
|
|
|
|
ServiceWorkersMode m_service_workers_mode { ServiceWorkersMode::All };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-initiator
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated initiator, which is the empty string, "download", "imageset", "manifest",
|
|
|
|
|
// "prefetch", "prerender", or "xslt". Unless stated otherwise it is the empty string.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Optional<Initiator> m_initiator;
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-destination
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated destination, which is the empty string, "audio", "audioworklet", "document",
|
2024-04-29 20:11:02 +01:00
|
|
|
|
// "embed", "font", "frame", "iframe", "image", "json", "manifest", "object", "paintworklet", "report", "script",
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// "serviceworker", "sharedworker", "style", "track", "video", "webidentity", "worker", or "xslt". Unless stated
|
|
|
|
|
// otherwise it is the empty string.
|
|
|
|
|
// NOTE: These are reflected on RequestDestination except for "serviceworker" and "webidentity" as fetches with
|
|
|
|
|
// those destinations skip service workers.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Optional<Destination> m_destination;
|
|
|
|
|
|
2023-10-29 02:49:22 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#request-priority
|
|
|
|
|
// A request has an associated priority, which is "high", "low", or "auto". Unless stated otherwise it is "auto".
|
|
|
|
|
Priority m_priority { Priority::Auto };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-internal-priority
|
|
|
|
|
// A request has an associated internal priority (null or an implementation-defined object). Unless otherwise stated it is null.
|
|
|
|
|
Optional<InternalPriority> m_internal_priority;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-origin
|
|
|
|
|
// A request has an associated origin, which is "client" or an origin. Unless stated otherwise it is "client".
|
|
|
|
|
OriginType m_origin { Origin::Client };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-policy-container
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated policy container, which is "client" or a policy container. Unless stated otherwise
|
|
|
|
|
// it is "client".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
PolicyContainerType m_policy_container { PolicyContainer::Client };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-referrer
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated referrer, which is "no-referrer", "client", or a URL. Unless stated otherwise it is
|
|
|
|
|
// "client".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
ReferrerType m_referrer { Referrer::Client };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-referrer-policy
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated referrer policy, which is a referrer policy. Unless stated otherwise it is the empty
|
|
|
|
|
// string.
|
2024-03-05 09:35:25 -07:00
|
|
|
|
ReferrerPolicy::ReferrerPolicy m_referrer_policy { ReferrerPolicy::ReferrerPolicy::EmptyString };
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-mode
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated mode, which is "same-origin", "cors", "no-cors", "navigate", or "websocket". Unless
|
|
|
|
|
// stated otherwise, it is "no-cors".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Mode m_mode { Mode::NoCORS };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#use-cors-preflight-flag
|
|
|
|
|
// A request has an associated use-CORS-preflight flag. Unless stated otherwise, it is unset.
|
|
|
|
|
bool m_use_cors_preflight { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-credentials-mode
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated credentials mode, which is "omit", "same-origin", or "include". Unless stated
|
|
|
|
|
// otherwise, it is "same-origin".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
CredentialsMode m_credentials_mode { CredentialsMode::SameOrigin };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag
|
|
|
|
|
// A request has an associated use-URL-credentials flag. Unless stated otherwise, it is unset.
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// NOTE: When this flag is set, when a request’s URL has a username and password, and there is an available
|
|
|
|
|
// authentication entry for the request, then the URL’s credentials are preferred over that of the
|
|
|
|
|
// authentication entry. Modern specifications avoid setting this flag, since putting credentials in URLs is
|
|
|
|
|
// discouraged, but some older features set it for compatibility reasons.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
bool m_use_url_credentials { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-cache-mode
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated cache mode, which is "default", "no-store", "reload", "no-cache", "force-cache", or
|
|
|
|
|
// "only-if-cached". Unless stated otherwise, it is "default".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
CacheMode m_cache_mode { CacheMode::Default };
|
|
|
|
|
|
2022-10-04 23:41:48 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-redirect-mode
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated redirect mode, which is "follow", "error", or "manual". Unless stated otherwise, it
|
|
|
|
|
// is "follow".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
RedirectMode m_redirect_mode { RedirectMode::Follow };
|
|
|
|
|
|
2022-10-04 23:41:48 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-integrity-metadata
|
2022-07-14 00:51:42 +01:00
|
|
|
|
// A request has associated integrity metadata (a string). Unless stated otherwise, it is the empty string.
|
2023-03-02 23:26:35 +00:00
|
|
|
|
String m_integrity_metadata;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2022-10-04 23:41:48 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-nonce-metadata
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has associated cryptographic nonce metadata (a string). Unless stated otherwise, it is the empty
|
|
|
|
|
// string.
|
2023-03-02 23:26:35 +00:00
|
|
|
|
String m_cryptographic_nonce_metadata;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
2022-10-04 23:41:48 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-parser-metadata
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has associated parser metadata which is the empty string, "parser-inserted", or
|
|
|
|
|
// "not-parser-inserted". Unless otherwise stated, it is the empty string.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
Optional<ParserMetadata> m_parser_metadata;
|
|
|
|
|
|
2022-10-04 23:41:48 +01:00
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-reload-navigation-flag
|
2022-07-14 00:51:42 +01:00
|
|
|
|
// A request has an associated reload-navigation flag. Unless stated otherwise, it is unset.
|
|
|
|
|
bool m_reload_navigation { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-history-navigation-flag
|
|
|
|
|
// A request has an associated history-navigation flag. Unless stated otherwise, it is unset.
|
|
|
|
|
bool m_history_navigation { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-user-activation
|
|
|
|
|
// A request has an associated boolean user-activation. Unless stated otherwise, it is false.
|
|
|
|
|
bool m_user_activation { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#request-render-blocking
|
|
|
|
|
// A request has an associated boolean render-blocking. Unless stated otherwise, it is false.
|
|
|
|
|
bool m_render_blocking { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-url-list
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated URL list (a list of one or more URLs). Unless stated otherwise, it is a list
|
|
|
|
|
// containing a copy of request’s URL.
|
2024-03-18 16:22:27 +13:00
|
|
|
|
Vector<URL::URL> m_url_list;
|
2022-07-14 00:51:42 +01:00
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-redirect-count
|
|
|
|
|
// A request has an associated redirect count. Unless stated otherwise, it is zero.
|
|
|
|
|
// NOTE: '4.4. HTTP-redirect fetch' infers a limit of 20.
|
|
|
|
|
u8 m_redirect_count { 0 };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#concept-request-response-tainting
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated response tainting, which is "basic", "cors", or "opaque". Unless stated otherwise,
|
|
|
|
|
// it is "basic".
|
2022-07-14 00:51:42 +01:00
|
|
|
|
ResponseTainting m_response_tainting { ResponseTainting::Basic };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#no-cache-prevent-cache-control
|
2022-10-30 14:41:36 +00:00
|
|
|
|
// A request has an associated prevent no-cache cache-control header modification flag. Unless stated otherwise, it
|
|
|
|
|
// is unset.
|
2022-07-14 00:51:42 +01:00
|
|
|
|
bool m_prevent_no_cache_cache_control_header_modification { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#done-flag
|
|
|
|
|
// A request has an associated done flag. Unless stated otherwise, it is unset.
|
|
|
|
|
bool m_done { false };
|
|
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#timing-allow-failed
|
|
|
|
|
// A request has an associated timing allow failed flag. Unless stated otherwise, it is unset.
|
|
|
|
|
bool m_timing_allow_failed { false };
|
2022-11-01 19:35:38 +00:00
|
|
|
|
|
|
|
|
|
// Non-standard
|
2024-11-15 04:01:23 +13:00
|
|
|
|
Vector<GC::Ref<Fetching::PendingResponse>> m_pending_responses;
|
2024-05-26 08:03:29 -04:00
|
|
|
|
|
|
|
|
|
BufferPolicy m_buffer_policy { BufferPolicy::BufferResponse };
|
2022-07-14 00:51:42 +01:00
|
|
|
|
};
|
|
|
|
|
|
2024-04-29 20:22:32 +01:00
|
|
|
|
StringView request_destination_to_string(Request::Destination);
|
2024-04-29 20:23:26 +01:00
|
|
|
|
StringView request_mode_to_string(Request::Mode);
|
2025-02-26 15:51:05 +00:00
|
|
|
|
FlyString initiator_type_to_string(Request::InitiatorType);
|
2024-04-29 20:22:32 +01:00
|
|
|
|
|
2024-05-27 09:45:56 +01:00
|
|
|
|
Optional<Request::Priority> request_priority_from_string(StringView);
|
|
|
|
|
|
2022-07-14 00:51:42 +01:00
|
|
|
|
}
|