mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 05:07:35 +00:00
LibRequests: Add hooks to handle RequestServer death
This commit is contained in:
parent
e421c233a6
commit
6f4be4791a
Notes:
github-actions[bot]
2025-08-10 09:04:18 +00:00
Author: https://github.com/trflynn89
Commit: 6f4be4791a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5796
3 changed files with 11 additions and 2 deletions
|
@ -20,6 +20,7 @@ enum class NetworkError {
|
||||||
SSLVerificationFailed,
|
SSLVerificationFailed,
|
||||||
MalformedUrl,
|
MalformedUrl,
|
||||||
InvalidContentEncoding,
|
InvalidContentEncoding,
|
||||||
|
RequestServerDied,
|
||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ constexpr StringView network_error_to_string(NetworkError network_error)
|
||||||
return "The URL is not formatted properly"sv;
|
return "The URL is not formatted properly"sv;
|
||||||
case NetworkError::InvalidContentEncoding:
|
case NetworkError::InvalidContentEncoding:
|
||||||
return "Response could not be decoded with its Content-Encoding"sv;
|
return "Response could not be decoded with its Content-Encoding"sv;
|
||||||
|
case NetworkError::RequestServerDied:
|
||||||
|
return "RequestServer is currently unavailable"sv;
|
||||||
case NetworkError::Unknown:
|
case NetworkError::Unknown:
|
||||||
return "An unexpected network error occurred"sv;
|
return "An unexpected network error occurred"sv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,12 @@ RequestClient::~RequestClient() = default;
|
||||||
|
|
||||||
void RequestClient::die()
|
void RequestClient::die()
|
||||||
{
|
{
|
||||||
// FIXME: Gracefully handle this, or relaunch and reconnect to RequestServer.
|
for (auto& [id, request] : m_requests) {
|
||||||
warnln("\033[31;1m {} Lost connection to RequestServer\033[0m", Core::System::getpid());
|
if (request)
|
||||||
|
request->did_finish({}, {}, {}, NetworkError::RequestServerDied);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_requests.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestClient::ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel cache_level)
|
void RequestClient::ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel cache_level)
|
||||||
|
|
|
@ -39,6 +39,8 @@ public:
|
||||||
bool stop_request(Badge<Request>, Request&);
|
bool stop_request(Badge<Request>, Request&);
|
||||||
bool set_certificate(Badge<Request>, Request&, ByteString, ByteString);
|
bool set_certificate(Badge<Request>, Request&, ByteString, ByteString);
|
||||||
|
|
||||||
|
Function<void()> on_request_server_died;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void die() override;
|
virtual void die() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue