LibWebView+RequestServer: Add a simple test mode for the HTTP disk cache

This mode allows us to test the HTTP disk cache with two mechanisms:

1. If RequestServer is launched with --http-disk-cache-mode=testing, it
   will cache requests with a X-Ladybird-Enable-Disk-Cache header.

2. In test mode, RS will include a X-Ladybird-Disk-Cache-Status response
   header indicating how the response was handled by the cache. There is
   no standard way for a web request to know what happened with respect
   to the disk cache, so this fills that hole for testing.

This mode is not exposed to users.
This commit is contained in:
Timothy Flynn 2025-11-18 10:18:40 -05:00 committed by Jelle Raaijmakers
parent a853bb43ef
commit b2c112c41a
Notes: github-actions[bot] 2025-11-20 08:35:41 +00:00
11 changed files with 107 additions and 28 deletions

View file

@ -213,8 +213,19 @@ ErrorOr<NonnullRefPtr<Requests::RequestClient>> launch_request_server_process()
for (auto const& certificate : request_server_options.certificates)
arguments.append(ByteString::formatted("--certificate={}", certificate));
if (request_server_options.enable_http_disk_cache == EnableHTTPDiskCache::Yes)
arguments.append("--enable-http-disk-cache"sv);
arguments.append("--http-disk-cache-mode"sv);
switch (request_server_options.http_disk_cache_mode) {
case HTTPDiskCacheMode::Disabled:
arguments.append("disabled"sv);
break;
case HTTPDiskCacheMode::Enabled:
arguments.append("enabled"sv);
break;
case HTTPDiskCacheMode::Testing:
arguments.append("testing"sv);
break;
}
if (auto server = mach_server_name(); server.has_value()) {
arguments.append("--mach-server-name"sv);