2020-06-01 21:58:29 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
2020-06-01 21:58:29 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-01 21:58:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-09-28 11:52:59 +02:00
|
|
|
#include <AK/ByteBuffer.h>
|
2021-09-11 21:15:15 -07:00
|
|
|
#include <AK/Time.h>
|
|
|
|
|
#include <LibCore/ElapsedTimer.h>
|
2025-11-26 14:13:23 -05:00
|
|
|
#include <LibHTTP/HeaderList.h>
|
2024-03-18 16:22:27 +13:00
|
|
|
#include <LibURL/URL.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2020-06-01 21:58:29 +02:00
|
|
|
#include <LibWeb/Forward.h>
|
2022-02-26 17:50:31 +01:00
|
|
|
#include <LibWeb/Page/Page.h>
|
2020-06-01 21:58:29 +02:00
|
|
|
|
|
|
|
|
namespace Web {
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API LoadRequest {
|
2020-06-01 21:58:29 +02:00
|
|
|
public:
|
2025-11-26 14:13:23 -05:00
|
|
|
explicit LoadRequest(NonnullRefPtr<HTTP::HeaderList> headers)
|
|
|
|
|
: m_headers(move(headers))
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-05-26 07:52:39 -04:00
|
|
|
|
2025-04-19 16:59:36 +12:00
|
|
|
Optional<URL::URL> const& url() const { return m_url; }
|
|
|
|
|
void set_url(Optional<URL::URL> url) { m_url = move(url); }
|
2020-06-01 21:58:29 +02:00
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString const& method() const { return m_method; }
|
|
|
|
|
void set_method(ByteString const& method) { m_method = method; }
|
2020-09-28 11:52:59 +02:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
ByteBuffer const& body() const { return m_body; }
|
2022-10-15 21:49:31 +02:00
|
|
|
void set_body(ByteBuffer body) { m_body = move(body); }
|
2020-09-28 11:52:59 +02:00
|
|
|
|
2025-08-23 03:49:58 -04:00
|
|
|
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; }
|
|
|
|
|
|
2023-07-07 22:48:11 -04:00
|
|
|
void start_timer() { m_load_timer.start(); }
|
2024-07-16 23:45:44 -06:00
|
|
|
AK::Duration load_time() const { return m_load_timer.elapsed_time(); }
|
2021-09-11 21:15:15 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<Page> page() const { return m_page.ptr(); }
|
2022-02-26 17:50:31 +01:00
|
|
|
void set_page(Page& page) { m_page = page; }
|
|
|
|
|
|
2025-11-26 14:13:23 -05:00
|
|
|
HTTP::HeaderList const& headers() const { return m_headers; }
|
2020-09-28 11:52:59 +02:00
|
|
|
|
2020-06-01 21:58:29 +02:00
|
|
|
private:
|
2025-04-19 16:59:36 +12:00
|
|
|
Optional<URL::URL> m_url;
|
2023-12-16 17:49:34 +03:30
|
|
|
ByteString m_method { "GET" };
|
2025-11-26 14:13:23 -05:00
|
|
|
NonnullRefPtr<HTTP::HeaderList> m_headers;
|
2020-09-28 11:52:59 +02:00
|
|
|
ByteBuffer m_body;
|
2021-09-11 21:15:15 -07:00
|
|
|
Core::ElapsedTimer m_load_timer;
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Root<Page> m_page;
|
2025-08-23 03:49:58 -04:00
|
|
|
bool m_store_set_cookie_headers { true };
|
2020-06-01 21:58:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|