/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Web { class WEB_API LoadRequest { public: explicit LoadRequest(NonnullRefPtr headers) : m_headers(move(headers)) { } Optional const& url() const { return m_url; } void set_url(Optional 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; } HTTP::Cookie::IncludeCredentials include_credentials() const { return m_include_credentials; } void set_include_credentials(HTTP::Cookie::IncludeCredentials include_credentials) { m_include_credentials = include_credentials; } Optional const& initiator_type() const { return m_initiator_type; } void set_initiator_type(Optional 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() const { return m_page.ptr(); } void set_page(Page& page) { m_page = page; } HTTP::HeaderList const& headers() const { return m_headers; } private: Optional m_url; ByteString m_method { "GET" }; NonnullRefPtr m_headers; ByteBuffer m_body; Core::ElapsedTimer m_load_timer; GC::Root m_page; HTTP::CacheMode m_cache_mode { HTTP::CacheMode::Default }; HTTP::Cookie::IncludeCredentials m_include_credentials { HTTP::Cookie::IncludeCredentials::Yes }; Optional m_initiator_type; }; }