mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
RequestServer: Use CURLOPT_PRIVATE to store pointer to our own data
This is a lot nicer than scanning through our list of requests. :^)
This commit is contained in:
parent
6f34758947
commit
3e6448efcf
Notes:
github-actions[bot]
2024-09-19 09:46:13 +00:00
Author: https://github.com/awesomekling
Commit: 3e6448efcf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1439
1 changed files with 5 additions and 9 deletions
|
@ -273,6 +273,8 @@ void ConnectionFromClient::start_request(i32 request_id, ByteString const& metho
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
set_option(CURLOPT_PRIVATE, request.ptr());
|
||||||
|
|
||||||
if (!g_default_certificate_path.is_empty())
|
if (!g_default_certificate_path.is_empty())
|
||||||
set_option(CURLOPT_CAINFO, g_default_certificate_path.characters());
|
set_option(CURLOPT_CAINFO, g_default_certificate_path.characters());
|
||||||
|
|
||||||
|
@ -317,20 +319,14 @@ void ConnectionFromClient::start_request(i32 request_id, ByteString const& metho
|
||||||
|
|
||||||
void ConnectionFromClient::check_active_requests()
|
void ConnectionFromClient::check_active_requests()
|
||||||
{
|
{
|
||||||
auto request_from_easy_handle = [this](CURL* easy) -> ActiveRequest* {
|
|
||||||
for (auto& it : m_active_requests) {
|
|
||||||
if (it.value->easy == easy)
|
|
||||||
return it.value.ptr();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
int msgs_in_queue = 0;
|
int msgs_in_queue = 0;
|
||||||
while (auto* msg = curl_multi_info_read(m_curl_multi, &msgs_in_queue)) {
|
while (auto* msg = curl_multi_info_read(m_curl_multi, &msgs_in_queue)) {
|
||||||
if (msg->msg != CURLMSG_DONE)
|
if (msg->msg != CURLMSG_DONE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto* request = request_from_easy_handle(msg->easy_handle);
|
ActiveRequest* request = nullptr;
|
||||||
|
auto result = curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &request);
|
||||||
|
VERIFY(result == CURLE_OK);
|
||||||
request->flush_headers_if_needed();
|
request->flush_headers_if_needed();
|
||||||
|
|
||||||
async_request_finished(request->request_id, msg->data.result == CURLE_OK, request->downloaded_so_far);
|
async_request_finished(request->request_id, msg->data.result == CURLE_OK, request->downloaded_so_far);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue