mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb/Fetch: Return a cloned cached response body
Otherwise we will fully read from the cached response and invalidate it's stream, invalidating it for the next time it is read from. Fixes a crash when reloading linegoup.lol after two reloads.
This commit is contained in:
parent
7cd6ea6f33
commit
3913e9f948
Notes:
github-actions[bot]
2024-12-26 12:45:46 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/3913e9f9486 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3044
1 changed files with 3 additions and 3 deletions
|
@ -1351,7 +1351,7 @@ WebIDL::ExceptionOr<GC::Ptr<PendingResponse>> http_redirect_fetch(JS::Realm& rea
|
|||
class CachePartition : public RefCounted<CachePartition> {
|
||||
public:
|
||||
// https://httpwg.org/specs/rfc9111.html#constructing.responses.from.caches
|
||||
GC::Ptr<Infrastructure::Response> select_response(URL::URL const& url, ReadonlyBytes method, Vector<Infrastructure::Header> const& headers, Vector<GC::Ptr<Infrastructure::Response>>& initial_set_of_stored_responses) const
|
||||
GC::Ptr<Infrastructure::Response> select_response(JS::Realm& realm, URL::URL const& url, ReadonlyBytes method, Vector<Infrastructure::Header> const& headers, Vector<GC::Ptr<Infrastructure::Response>>& 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<GC::Ref<PendingResponse>> 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,
|
||||
|
|
Loading…
Add table
Reference in a new issue