diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 40fac6b051e..463e6fa3bac 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -1351,7 +1351,7 @@ WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm& rea class CachePartition : public RefCounted { public: // https://httpwg.org/specs/rfc9111.html#constructing.responses.from.caches - GC::Ptr select_response(URL::URL const& url, ReadonlyBytes method, Vector const& headers, Vector>& initial_set_of_stored_responses) const + GC::Ptr select_response(JS::Realm& realm, URL::URL const& url, ReadonlyBytes method, Vector const& headers, Vector>& initial_set_of_stored_responses) const { // When presented with a request, a cache MUST NOT reuse a stored response unless: @@ -1383,7 +1383,7 @@ public: dbgln("\033[32;1mHTTP CACHE HIT!\033[0m {}", url); - return cached_response.ptr(); + return cached_response->clone(realm); } void store_response(JS::Realm& realm, Infrastructure::Request const& http_request, Infrastructure::Response const& response) @@ -1939,7 +1939,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re // validation, as per the "Constructing Responses from Caches" chapter of HTTP Caching [HTTP-CACHING], // if any. // NOTE: As mandated by HTTP, this still takes the `Vary` header into account. - stored_response = http_cache->select_response(http_request->current_url(), http_request->method(), *http_request->header_list(), initial_set_of_stored_responses); + stored_response = http_cache->select_response(realm, http_request->current_url(), http_request->method(), *http_request->header_list(), initial_set_of_stored_responses); // 2. If storedResponse is non-null, then: if (stored_response) { // 1. If cache mode is "default", storedResponse is a stale-while-revalidate response,