Skip to content
Snippets Groups Projects
Commit 3fb00b27 authored by Joe Donofry's avatar Joe Donofry
Browse files

Merge branch 'verbose_logging' into 'master'

Add client verbose logging support

See merge request !5
parents d9268930 28d81e47
No related branches found
No related tags found
1 merge request!5Add client verbose logging support
Pipeline #4829 passed
......@@ -141,6 +141,13 @@ struct Client {
/// @sa set_verify_peer
bool does_verify_peer() { return this->verify_peer_; }
//! Set whether or not to log curl requests verbosely.
/// @sa verbose and also CURLOPT_VERBOSE
void verbose(bool verbose) { this->verbose_logging_ = verbose; }
/// @brief Query whether verbose logging is enabled or not
/// @sa verbose(bool)
bool verbose() { return this->verbose_logging_; }
//! Timeout connection after the specified amount of seconds, if the server
//! stops sending acks.
void connection_timeout(long t) { connection_timeout_ = t; }
......@@ -191,6 +198,7 @@ struct Client {
std::atomic<bool> stopped{false};
std::atomic<bool> prevent_new_requests{false};
bool verify_peer_ = true;
bool verbose_logging_ = false;
long connection_timeout_ = 0;
......
......@@ -133,21 +133,16 @@ void Client::cancel_requests_cb(evutil_socket_t, short, void *userp) {
Client *g = (Client *)userp;
// prevent new requests from being added
{
g->prevent_new_requests = true;
}
// safe to access now, since we are running on the worker thread and only
// there running_requests is modified
while (!g->running_requests.empty())
g->remove_request(g->running_requests.back().get());
// prevent new requests from being added
{ g->prevent_new_requests = true; }
// Allow for new requests
{
g->prevent_new_requests = false;
}
// safe to access now, since we are running on the worker thread and only
// there running_requests is modified
while (!g->running_requests.empty())
g->remove_request(g->running_requests.back().get());
// Allow for new requests
{ g->prevent_new_requests = false; }
CURLMcode rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
......@@ -393,8 +388,8 @@ void Client::delete_(std::string url, std::function<void(const Request &)> callb
this->submit_request(std::move(req));
}
void Client::delete_(std::string url, std::string request_body, std::string mimetype, std::function<void(const Request &)> callback, const Headers &headers,
long max_redirects) {
void Client::delete_(std::string url, std::string request_body, std::string mimetype,
std::function<void(const Request &)> callback, const Headers &headers, long max_redirects) {
auto req = std::make_shared<Request>(this, Request::Method::Delete, std::move(url));
req->request(request_body, mimetype);
......
#include <coeurl/errors.hpp>
const char* coeurl::to_string(CURLcode c) {
return curl_easy_strerror(c);
}
const char *coeurl::to_string(CURLcode c) { return curl_easy_strerror(c); }
//const char* coeurl::to_string(CURLUcode c) {
// return curl_url_strerror(c);
//}
// const char* coeurl::to_string(CURLUcode c) {
// return curl_url_strerror(c);
// }
const char* coeurl::to_string(CURLMcode c) {
return curl_multi_strerror(c);
}
const char *coeurl::to_string(CURLMcode c) { return curl_multi_strerror(c); }
const char* coeurl::to_string(CURLSHcode c) {
return curl_share_strerror(c);
}
const char *coeurl::to_string(CURLSHcode c) { return curl_share_strerror(c); }
......@@ -118,20 +118,22 @@ Request::Request(Client *client, Method m, std::string url__) : url_(std::move(u
curl_easy_setopt(this->easy, CURLOPT_WRITEDATA, this);
curl_easy_setopt(this->easy, CURLOPT_HEADERFUNCTION, header_cb);
curl_easy_setopt(this->easy, CURLOPT_HEADERDATA, this);
// curl_easy_setopt(this->easy, CURLOPT_VERBOSE, 1L);
if (this->global->verbose()) {
curl_easy_setopt(this->easy, CURLOPT_VERBOSE, 1L);
}
curl_easy_setopt(this->easy, CURLOPT_ERRORBUFFER, this->error);
curl_easy_setopt(this->easy, CURLOPT_PRIVATE, this);
curl_easy_setopt(this->easy, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(this->easy, CURLOPT_XFERINFOFUNCTION, prog_cb);
curl_easy_setopt(this->easy, CURLOPT_XFERINFODATA, this);
#if CURL_AT_LEAST_VERSION(7, 85, 0)
#if CURL_AT_LEAST_VERSION(7, 85, 0)
curl_easy_setopt(this->easy, CURLOPT_PROTOCOLS_STR, "HTTPS,HTTP");
#else
#else
curl_easy_setopt(this->easy, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
#endif
#endif
// enable altsvc support, which allows us to switch to http3
curl_easy_setopt(this->easy, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1|CURLALTSVC_H2|CURLALTSVC_H3);
curl_easy_setopt(this->easy, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1 | CURLALTSVC_H2 | CURLALTSVC_H3);
curl_easy_setopt(this->easy, CURLOPT_ALTSVC, client->alt_svc_cache_path().c_str());
// default to all supported encodings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment