Skip to content

Commit

Permalink
Print libcurl error buffer to stderr on client error
Browse files Browse the repository at this point in the history
  • Loading branch information
LBPHacker committed Apr 5, 2019
1 parent e3fefe3 commit ff39c82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client/http/Request.cpp
Expand Up @@ -159,6 +159,9 @@ namespace http
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
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_HTTPHEADER, headers);
curl_easy_setopt(easy, CURLOPT_URL, uri.c_str());
Expand Down
1 change: 1 addition & 0 deletions src/client/http/Request.h
Expand Up @@ -25,6 +25,7 @@ namespace http
ByteString response_body;

CURL *easy;
char error_buffer[CURL_ERROR_SIZE];

volatile curl_off_t rm_total;
volatile curl_off_t rm_done;
Expand Down
7 changes: 7 additions & 0 deletions src/client/http/RequestManager.cpp
Expand Up @@ -3,6 +3,8 @@
#include "Config.h"
#include "Platform.h"

#include <iostream>

const int curl_multi_wait_timeout_ms = 100;
const long curl_max_host_connections = 6;

Expand Down Expand Up @@ -142,6 +144,11 @@ namespace http
break;
}

if (finish_with >= 600)
{
std::cerr << request->error_buffer << std::endl;
}

request->status = finish_with;
}
};
Expand Down

0 comments on commit ff39c82

Please sign in to comment.