Skip to content

Commit ff39c82

Browse files
committed
Print libcurl error buffer to stderr on client error
1 parent e3fefe3 commit ff39c82

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/client/http/Request.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ namespace http
159159
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
160160
curl_easy_setopt(easy, CURLOPT_MAXREDIRS, 10L);
161161

162+
curl_easy_setopt(easy, CURLOPT_ERRORBUFFER, error_buffer);
163+
error_buffer[0] = 0;
164+
162165
curl_easy_setopt(easy, CURLOPT_TIMEOUT, timeout);
163166
curl_easy_setopt(easy, CURLOPT_HTTPHEADER, headers);
164167
curl_easy_setopt(easy, CURLOPT_URL, uri.c_str());

src/client/http/Request.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace http
2525
ByteString response_body;
2626

2727
CURL *easy;
28+
char error_buffer[CURL_ERROR_SIZE];
2829

2930
volatile curl_off_t rm_total;
3031
volatile curl_off_t rm_done;

src/client/http/RequestManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "Config.h"
44
#include "Platform.h"
55

6+
#include <iostream>
7+
68
const int curl_multi_wait_timeout_ms = 100;
79
const long curl_max_host_connections = 6;
810

@@ -142,6 +144,11 @@ namespace http
142144
break;
143145
}
144146

147+
if (finish_with >= 600)
148+
{
149+
std::cerr << request->error_buffer << std::endl;
150+
}
151+
145152
request->status = finish_with;
146153
}
147154
};

0 commit comments

Comments
 (0)