mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 10:20:22 +00:00
If the cache mode is no-store, we must not interact with the cache at all. If the cache mode is reload, we must not use any cached response. If the cache-mode is only-if-cached or force-cache, we are permitted to respond with stale cache responses. Note that we currently cannot test only-if-cached in test-web. Setting this mode also requires setting the cors mode to same-origin, but our http-test-server infra requires setting the cors mode to cors.
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
#include <AK/Time.h>
|
|
#include <LibCore/ElapsedTimer.h>
|
|
#include <LibHTTP/Cache/CacheMode.h>
|
|
#include <LibHTTP/HeaderList.h>
|
|
#include <LibURL/URL.h>
|
|
#include <LibWeb/Export.h>
|
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Page/Page.h>
|
|
|
|
namespace Web {
|
|
|
|
class WEB_API LoadRequest {
|
|
public:
|
|
explicit LoadRequest(NonnullRefPtr<HTTP::HeaderList> headers)
|
|
: m_headers(move(headers))
|
|
{
|
|
}
|
|
|
|
Optional<URL::URL> const& url() const { return m_url; }
|
|
void set_url(Optional<URL::URL> url) { m_url = move(url); }
|
|
|
|
ByteString const& method() const { return m_method; }
|
|
void set_method(ByteString const& method) { m_method = method; }
|
|
|
|
ByteBuffer const& body() const { return m_body; }
|
|
void set_body(ByteBuffer body) { m_body = move(body); }
|
|
|
|
HTTP::CacheMode cache_mode() const { return m_cache_mode; }
|
|
void set_cache_mode(HTTP::CacheMode cache_mode) { m_cache_mode = cache_mode; }
|
|
|
|
bool store_set_cookie_headers() const { return m_store_set_cookie_headers; }
|
|
void set_store_set_cookie_headers(bool store_set_cookie_headers) { m_store_set_cookie_headers = store_set_cookie_headers; }
|
|
|
|
Optional<Fetch::Infrastructure::Request::InitiatorType> const& initiator_type() const { return m_initiator_type; }
|
|
void set_initiator_type(Optional<Fetch::Infrastructure::Request::InitiatorType> initiator_type) { m_initiator_type = move(initiator_type); }
|
|
|
|
void start_timer() { m_load_timer.start(); }
|
|
AK::Duration load_time() const { return m_load_timer.elapsed_time(); }
|
|
|
|
GC::Ptr<Page> page() const { return m_page.ptr(); }
|
|
void set_page(Page& page) { m_page = page; }
|
|
|
|
HTTP::HeaderList const& headers() const { return m_headers; }
|
|
|
|
private:
|
|
Optional<URL::URL> m_url;
|
|
ByteString m_method { "GET" };
|
|
NonnullRefPtr<HTTP::HeaderList> m_headers;
|
|
ByteBuffer m_body;
|
|
Core::ElapsedTimer m_load_timer;
|
|
GC::Root<Page> m_page;
|
|
HTTP::CacheMode m_cache_mode { HTTP::CacheMode::Default };
|
|
bool m_store_set_cookie_headers { true };
|
|
Optional<Fetch::Infrastructure::Request::InitiatorType> m_initiator_type;
|
|
};
|
|
|
|
}
|