Print libcurl error buffer to stderr on client error

This commit is contained in:
Tamás Bálint Misius 2019-04-05 21:22:51 +02:00
parent e3fefe30d1
commit ff39c82e48
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
3 changed files with 11 additions and 0 deletions

View File

@ -159,6 +159,9 @@ namespace http
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(easy, CURLOPT_MAXREDIRS, 10L); curl_easy_setopt(easy, CURLOPT_MAXREDIRS, 10L);
curl_easy_setopt(easy, CURLOPT_ERRORBUFFER, error_buffer);
error_buffer[0] = 0;
curl_easy_setopt(easy, CURLOPT_TIMEOUT, timeout); curl_easy_setopt(easy, CURLOPT_TIMEOUT, timeout);
curl_easy_setopt(easy, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(easy, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(easy, CURLOPT_URL, uri.c_str()); curl_easy_setopt(easy, CURLOPT_URL, uri.c_str());

View File

@ -25,6 +25,7 @@ namespace http
ByteString response_body; ByteString response_body;
CURL *easy; CURL *easy;
char error_buffer[CURL_ERROR_SIZE];
volatile curl_off_t rm_total; volatile curl_off_t rm_total;
volatile curl_off_t rm_done; volatile curl_off_t rm_done;

View File

@ -3,6 +3,8 @@
#include "Config.h" #include "Config.h"
#include "Platform.h" #include "Platform.h"
#include <iostream>
const int curl_multi_wait_timeout_ms = 100; const int curl_multi_wait_timeout_ms = 100;
const long curl_max_host_connections = 6; const long curl_max_host_connections = 6;
@ -142,6 +144,11 @@ namespace http
break; break;
} }
if (finish_with >= 600)
{
std::cerr << request->error_buffer << std::endl;
}
request->status = finish_with; request->status = finish_with;
} }
}; };