summaryrefslogtreecommitdiff
path: root/content/fetchers/curl.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-05-28 00:38:40 +0100
committerVincent Sanders <vince@kyllikki.org>2019-05-28 11:16:49 +0100
commit13a5b8f74a9024953a27e4c34740d05e9a4e3e8e (patch)
treedb66040cf2fa471571aac2f1ff5533ddd66ca2a1 /content/fetchers/curl.c
parent57094c84edeb3540e13121dea742b1ae484d468b (diff)
downloadnetsurf-13a5b8f74a9024953a27e4c34740d05e9a4e3e8e.tar.gz
netsurf-13a5b8f74a9024953a27e4c34740d05e9a4e3e8e.tar.bz2
make curl fetcher log debug using NSLOG
stop curl fetcher logging being special case to standard error and use the fetch catagory at DEBUG level instead. The special suppress_curl_debug option is currently still obeyed
Diffstat (limited to 'content/fetchers/curl.c')
-rw-r--r--content/fetchers/curl.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 4602f6aea..63b9ea115 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -1,7 +1,7 @@
/*
- * Copyright 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
+ * Copyright 2006-2019 Daniel Silverstone <dsilvers@digital-scurf.org>
+ * Copyright 2010-2018 Vincent Sanders <vince@netsurf-browser.org>
* Copyright 2007 James Bursa <bursa@users.sourceforge.net>
- * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
*
* This file is part of NetSurf.
*
@@ -1282,16 +1282,28 @@ fetch_curl_progress(void *clientp,
/**
- * Ignore everything given to it.
- *
- * Used to ignore cURL debug.
+ * Format curl debug for nslog
*/
-static int fetch_curl_ignore_debug(CURL *handle,
- curl_infotype type,
- char *data,
- size_t size,
- void *userptr)
+static int
+fetch_curl_debug(CURL *handle,
+ curl_infotype type,
+ char *data,
+ size_t size,
+ void *userptr)
{
+ static const char s_infotype[CURLINFO_END][3] = {
+ "* ", "< ", "> ", "{ ", "} ", "{ ", "} "
+ };
+ switch(type) {
+ case CURLINFO_TEXT:
+ case CURLINFO_HEADER_OUT:
+ case CURLINFO_HEADER_IN:
+ NSLOG(fetch, DEBUG, "%s%.*s", s_infotype[type], (int)size - 1, data);
+ break;
+
+ default:
+ break;
+ }
return 0;
}
@@ -1510,14 +1522,12 @@ nserror fetch_curl_register(void)
if (code != CURLE_OK) \
goto curl_easy_setopt_failed;
- if (verbose_log) {
- SETOPT(CURLOPT_VERBOSE, 1);
- } else {
- SETOPT(CURLOPT_VERBOSE, 0);
- }
SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer);
+ SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_debug);
if (nsoption_bool(suppress_curl_debug)) {
- SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_ignore_debug);
+ SETOPT(CURLOPT_VERBOSE, 0);
+ } else {
+ SETOPT(CURLOPT_VERBOSE, 1);
}
/* Currently we explode if curl uses HTTP2, so force 1.1. */