ladybird/Libraries/LibWeb/Loader/LoadRequest.h
Timothy Flynn 9375660b64 LibHTTP+LibWeb+RequestServer: Move Fetch's HTTP header infra to LibHTTP
The end goal here is for LibHTTP to be the home of our RFC 9111 (HTTP
caching) implementation. We currently have one implementation in LibWeb
for our in-memory cache and another in RequestServer for our disk cache.

The implementations both largely revolve around interacting with HTTP
headers. But in LibWeb, we are using Fetch's header infra, and in RS we
are using are home-grown header infra from LibHTTP.

So to give these a common denominator, this patch replaces the LibHTTP
implementation with Fetch's infra. Our existing LibHTTP implementation
was not particularly compliant with any spec, so this at least gives us
a standards-based common implementation.

This migration also required moving a handful of other Fetch AOs over
to LibHTTP. (It turns out these AOs were all from the Fetch/Infra/HTTP
folder, so perhaps it makes sense for LibHTTP to be the implementation
of that entire set of facilities.)
2025-11-27 14:57:29 +01:00

57 lines
1.6 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/HeaderList.h>
#include <LibURL/URL.h>
#include <LibWeb/Export.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); }
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; }
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;
bool m_store_set_cookie_headers { true };
};
}