mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
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:
parent
a853bb43ef
commit
b2c112c41a
Notes:
github-actions[bot]
2025-11-20 08:35:41 +00:00
Author: https://github.com/trflynn89
Commit: b2c112c41a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6861
Reviewed-by: https://github.com/gmta ✅
11 changed files with 107 additions and 28 deletions
|
|
@ -34,13 +34,13 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
|||
|
||||
Vector<ByteString> certificates;
|
||||
StringView mach_server_name;
|
||||
bool enable_http_disk_cache = false;
|
||||
StringView http_disk_cache_mode;
|
||||
bool wait_for_debugger = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
|
||||
args_parser.add_option(mach_server_name, "Mach server name", "mach-server-name", 0, "mach_server_name");
|
||||
args_parser.add_option(enable_http_disk_cache, "Enable HTTP disk cache", "enable-http-disk-cache");
|
||||
args_parser.add_option(http_disk_cache_mode, "HTTP disk cache mode", "http-disk-cache-mode", 0, "mode");
|
||||
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
|
|
@ -58,8 +58,12 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
|||
Core::Platform::register_with_mach_server(mach_server_name);
|
||||
#endif
|
||||
|
||||
if (enable_http_disk_cache) {
|
||||
if (auto cache = RequestServer::DiskCache::create(); cache.is_error())
|
||||
if (http_disk_cache_mode.is_one_of("enabled"sv, "testing"sv)) {
|
||||
auto mode = http_disk_cache_mode == "enabled"sv
|
||||
? RequestServer::DiskCache::Mode::Normal
|
||||
: RequestServer::DiskCache::Mode::Testing;
|
||||
|
||||
if (auto cache = RequestServer::DiskCache::create(mode); cache.is_error())
|
||||
warnln("Unable to create disk cache: {}", cache.error());
|
||||
else
|
||||
RequestServer::g_disk_cache = cache.release_value();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue