mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
RequestServer: Compute response ages without truncating sub-fractions
We can use Duration as-is without coercing values to seconds. This probably doesn't make much difference in real-world scenarios, but when we hammer the cache during tests, this truncation will cause flakey behavior.
This commit is contained in:
parent
44326c4d7f
commit
a580392109
Notes:
github-actions[bot]
2025-11-20 08:36:09 +00:00
Author: https://github.com/trflynn89
Commit: a580392109
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6861
Reviewed-by: https://github.com/gmta ✅
1 changed files with 4 additions and 4 deletions
|
|
@ -310,17 +310,17 @@ AK::Duration calculate_age(HTTP::HeaderMap const& headers, UnixDateTime request_
|
|||
// without it.
|
||||
auto date_value = parse_http_date(headers.get("Date"sv)).value_or(now);
|
||||
|
||||
auto apparent_age = max(0LL, (response_time - date_value).to_seconds());
|
||||
auto apparent_age = max(AK::Duration::zero(), (response_time - date_value));
|
||||
|
||||
auto response_delay = response_time - request_time;
|
||||
auto corrected_age_value = age_value + response_delay;
|
||||
|
||||
auto corrected_initial_age = max(apparent_age, corrected_age_value.to_seconds());
|
||||
auto corrected_initial_age = max(apparent_age, corrected_age_value);
|
||||
|
||||
auto resident_time = (now - response_time).to_seconds();
|
||||
auto resident_time = now - response_time;
|
||||
auto current_age = corrected_initial_age + resident_time;
|
||||
|
||||
return AK::Duration::from_seconds(current_age);
|
||||
return current_age;
|
||||
}
|
||||
|
||||
CacheLifetimeStatus cache_lifetime_status(HTTP::HeaderMap const& headers, AK::Duration freshness_lifetime, AK::Duration current_age)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue