This commit is contained in:
MihailRis 2026-09-10 20:38:50 +03:00
parent 9226f362a7
commit 946728e54e
3 changed files with 28 additions and 2 deletions

View file

@ -80,6 +80,9 @@ public:
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/7.81.0");
#ifndef NDEBUG
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#endif
if (request.maxSize == 0) {
curl_easy_setopt(
curl, CURLOPT_MAXFILESIZE, std::numeric_limits<long>::max()
@ -119,7 +122,8 @@ public:
if(msg->msg == CURLMSG_DONE) {
curl_multi_remove_handle(multiHandle, curl);
}
int response;
int response = -1;
CURLcode result = msg->data.result;
curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &response);
if (response == HTTP_OK) {
long size;
@ -133,6 +137,11 @@ public:
if (onResponse) {
onResponse(std::move(buffer));
}
} else if (response == 0) {
logger.error() << curl_easy_strerror(result) << " (" << url << ")";
if (onReject) {
onReject(response, {});
}
} else {
logger.error()
<< "response code " << response << " (" << url << ")"