/* * Copyright (c) 2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace HTTP { class MemoryCache : public RefCounted { public: struct Entry { u32 status_code { 0 }; ByteString reason_phrase; NonnullRefPtr response_headers; ByteBuffer response_body; }; static NonnullRefPtr create(); Optional open_entry(URL::URL const&, StringView method, HeaderList const& request_headers) const; void create_entry(URL::URL const&, StringView method, u32 status_code, ByteString reason_phrase, HeaderList const& response_headers); void finalize_entry(URL::URL const&, StringView method, ByteBuffer response_body); private: HashMap m_pending_entries; HashMap m_complete_entries; }; }