1
+ #include < Geode/loader/Log.hpp>
1
2
#include < Geode/Result.hpp>
2
3
#include < Geode/utils/general.hpp>
3
4
#include < filesystem>
@@ -252,7 +253,8 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) {
252
253
// Init Curl
253
254
auto curl = curl_easy_init ();
254
255
if (!curl) {
255
- return impl->makeError (-1 , " Curl not initialized" );
256
+ log::error (" Failed to initialize cURL" );
257
+ return impl->makeError (-1 , " Failed to initialize curl" );
256
258
}
257
259
258
260
// todo: in the future, we might want to support downloading directly into
@@ -329,8 +331,8 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) {
329
331
}
330
332
331
333
// Cert verification
332
- curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, impl->m_certVerification ? 1 : 0 );
333
- curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2 );
334
+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, impl->m_certVerification ? 1L : 0L );
335
+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2L );
334
336
335
337
if (impl->m_certVerification ) {
336
338
curl_blob caBundleBlob = {};
@@ -399,7 +401,7 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) {
399
401
curl_easy_setopt (curl, CURLOPT_IGNORE_CONTENT_LENGTH, impl->m_ignoreContentLength ? 1L : 0L );
400
402
401
403
// Track progress
402
- curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0 );
404
+ curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0L );
403
405
404
406
// don't change the method from POST to GET when following a redirect
405
407
curl_easy_setopt (curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
@@ -476,10 +478,13 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) {
476
478
// Check if the request failed on curl's side or because of cancellation
477
479
if (curlResponse != CURLE_OK) {
478
480
if (hasBeenCancelled ()) {
481
+ log::debug (" Request cancelled" );
479
482
return WebTask::Cancel ();
480
483
}
481
484
else {
482
- return impl->makeError (-1 , " Curl failed: " + std::string (curl_easy_strerror (curlResponse)));
485
+ std::string const err = curl_easy_strerror (curlResponse);
486
+ log::error (" cURL failure, error: {}" , err);
487
+ return impl->makeError (-1 , " Curl failed: " + err);
483
488
}
484
489
}
485
490
@@ -490,7 +495,7 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) {
490
495
491
496
// Otherwise resolve with success :-)
492
497
return std::move (responseData.response );
493
- }, fmt::format (" {} request to {}" , method, url));
498
+ }, fmt::format (" {} {}" , method, url));
494
499
}
495
500
WebTask WebRequest::post (std::string_view url) {
496
501
return this ->send (" POST" , url);
0 commit comments