mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
ProtocolServer: Use an empty Optional<IPC::File> to pass along "no fd"
Passing `-1` wouldn't work, as these are passed to `sendfd()'. Fixes #4706.
This commit is contained in:
parent
f2973875e3
commit
887a62582d
Notes:
sideshowbarker
2024-07-19 00:17:02 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/887a62582d7 Pull-request: https://github.com/SerenityOS/serenity/pull/4709 Issue: https://github.com/SerenityOS/serenity/issues/4706
3 changed files with 6 additions and 6 deletions
|
@ -57,9 +57,9 @@ RefPtr<Download> Client::start_download(const String& method, const String& url,
|
|||
|
||||
auto response = send_sync<Messages::ProtocolServer::StartDownload>(method, url, header_dictionary, ByteBuffer::copy(request_body));
|
||||
auto download_id = response->download_id();
|
||||
auto response_fd = response->response_fd().fd();
|
||||
if (download_id < 0 || response_fd < 0)
|
||||
if (download_id < 0 || !response->response_fd().has_value())
|
||||
return nullptr;
|
||||
auto response_fd = response->response_fd().value().fd();
|
||||
auto download = Download::create_from_id({}, *this, download_id);
|
||||
download->set_download_fd({}, response_fd);
|
||||
m_downloads.set(download_id, download);
|
||||
|
|
|
@ -62,13 +62,13 @@ OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle
|
|||
{
|
||||
URL url(message.url());
|
||||
if (!url.is_valid())
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, -1);
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
|
||||
auto* protocol = Protocol::find_by_name(url.protocol());
|
||||
if (!protocol)
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, -1);
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
|
||||
auto download = protocol->start_download(*this, message.method(), url, message.request_headers().entries(), message.request_body());
|
||||
if (!download)
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, -1);
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(-1, Optional<IPC::File> {});
|
||||
auto id = download->id();
|
||||
auto fd = download->download_fd();
|
||||
m_downloads.set(id, move(download));
|
||||
|
|
|
@ -7,7 +7,7 @@ endpoint ProtocolServer = 9
|
|||
IsSupportedProtocol(String protocol) => (bool supported)
|
||||
|
||||
// Download API
|
||||
StartDownload(String method, URL url, IPC::Dictionary request_headers, ByteBuffer request_body) => (i32 download_id, IPC::File response_fd)
|
||||
StartDownload(String method, URL url, IPC::Dictionary request_headers, ByteBuffer request_body) => (i32 download_id, Optional<IPC::File> response_fd)
|
||||
StopDownload(i32 download_id) => (bool success)
|
||||
SetCertificate(i32 download_id, String certificate, String key) => (bool success)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue