From 39638b297d6522f4ba3655020e283c97f0eac06f Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 10 Sep 2010 14:46:04 +0000 Subject: [PATCH] added curl logger to integrate curl messages with gnunet log --- src/transport/plugin_transport_http.c | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 5c0708e38..2b52f37c4 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -53,7 +53,7 @@ #endif #define DEBUG_HTTP GNUNET_NO -#define DEBUG_CURL GNUNET_NO +#define DEBUG_CURL GNUNET_YES #define DEBUG_MHD GNUNET_NO #define DEBUG_CONNECTIONS GNUNET_NO #define DEBUG_SESSION_SELECTION GNUNET_NO @@ -1690,6 +1690,34 @@ static int curl_schedule(struct Plugin *plugin) return GNUNET_OK; } +/** + * Function to log curl debug messages with GNUNET_log + * @param curl handle + * @param type curl_infotype + * @param data data + * @param size size + * @param cls closure + * @return 0 + */ +int curl_logger (CURL * curl, curl_infotype type , char * data, size_t size , void * cls) +{ + char * text = GNUNET_malloc(size+2); + if (type == CURLINFO_TEXT) + { + memcpy(text,data,size); + if (text[size-1] == '\n') + text[size] = '\0'; + else + { + text[size] = '\n'; + text[size+1] = '\0'; + } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"CURL: Connection %X - %s", cls, text); + GNUNET_free(text); + } + return 0; +} + /** * Function setting up curl handle and selecting message to send * @@ -1718,6 +1746,8 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps) } #if DEBUG_CURL curl_easy_setopt(ps->recv_endpoint, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(ps->recv_endpoint, CURLOPT_DEBUGFUNCTION , &curl_logger); + curl_easy_setopt(ps->recv_endpoint, CURLOPT_DEBUGDATA , ps->recv_endpoint); #endif #if BUILD_HTTPS curl_easy_setopt (ps->recv_endpoint, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); @@ -1814,6 +1844,8 @@ static int send_check_connections (struct Plugin *plugin, struct Session *ps) #if DEBUG_CURL curl_easy_setopt(ps->send_endpoint, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(ps->send_endpoint, CURLOPT_DEBUGFUNCTION , &curl_logger); + curl_easy_setopt(ps->send_endpoint, CURLOPT_DEBUGDATA , ps->send_endpoint); #endif #if BUILD_HTTPS curl_easy_setopt (ps->send_endpoint, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); -- 2.25.1