summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d0bf11d)
raw | patch | inline | side by side (parent: d0bf11d)
author | Jeremy Katz <jeremy@katzbox.net> | |
Sun, 22 Sep 2013 19:50:05 +0000 (21:50 +0200) | ||
committer | Jeremy Katz <jeremy@katzbox.net> | |
Thu, 26 Sep 2013 14:29:15 +0000 (10:29 -0400) |
Make it possible to specify a custom user agent at compile time
and then use on all libcurl calls instead of just going with
PACKAGE_NAME/PACKAGE_VERSION
and then use on all libcurl calls instead of just going with
PACKAGE_NAME/PACKAGE_VERSION
configure.in | patch | blob | history | |
src/apache.c | patch | blob | history | |
src/ascent.c | patch | blob | history | |
src/bind.c | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/curl.c | patch | blob | history | |
src/curl_json.c | patch | blob | history | |
src/curl_xml.c | patch | blob | history | |
src/nginx.c | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index c23df178ca1ac0c9dd464894ca1fb407bd32fb78..e137dabd9eb1c4ed6f02fc890865deca63ed0001 100644 (file)
--- a/configure.in
+++ b/configure.in
AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
# }}}
+# --with-useragent {{{
+AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=OPTIONS@:>@], [User agent to use on http requests])],
+[
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"
+ then
+ AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
+ fi
+])
+
+# }}}
+
# --with-libdbi {{{
with_libdbi_cppflags=""
with_libdbi_ldflags=""
diff --git a/src/apache.c b/src/apache.c
index 8458ce15d1c9b58bdd8c9c24220e844242443f3a..c5f099f558a2b445e67becb84feeae2e3b95ed00 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
curl_easy_setopt (st->curl, CURLOPT_WRITEHEADER, st);
}
- curl_easy_setopt (st->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (st->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (st->curl, CURLOPT_ERRORBUFFER, st->apache_curl_error);
if (st->user != NULL)
diff --git a/src/ascent.c b/src/ascent.c
index 94a39386b0a45f74cba03ddd237588c3ba8edfb7..6809bac2be160406130c855f653e30700c10e6a0 100644 (file)
--- a/src/ascent.c
+++ b/src/ascent.c
curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ascent_curl_callback);
- curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, ascent_curl_error);
if (user != NULL)
diff --git a/src/bind.c b/src/bind.c
index ddde840a4813df60c4b49c1bc168a80689037c3f..2f990a21c0289c4f4b851a59e500fba575d54730 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
- curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
diff --git a/src/collectd.h b/src/collectd.h
index 7cb405c04bd43d25ec6b807f730419cbf39a93bb..969aedaa483c0f1bddcfe7baa2052096c05cc783 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
# define COLLECTD_DEFAULT_INTERVAL 10.0
#endif
+ #ifndef COLLECTD_USERAGENT
+ # define COLLECTD_USERAGENT PACKAGE_NAME"/"PACKAGE_VERSION
+ #endif
+
/* Remove GNU specific __attribute__ settings when using another compiler */
#if !__GNUC__
# define __attribute__(x) /**/
diff --git a/src/curl.c b/src/curl.c
index 280e61c8649ae70a0f2bc99658aeed5659e71e5a..59903686419d921346e764723ce367ac5b00fa29 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
curl_easy_setopt (wp->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (wp->curl, CURLOPT_WRITEFUNCTION, cc_curl_callback);
curl_easy_setopt (wp->curl, CURLOPT_WRITEDATA, wp);
- curl_easy_setopt (wp->curl, CURLOPT_USERAGENT,
- PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (wp->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (wp->curl, CURLOPT_ERRORBUFFER, wp->curl_errbuf);
curl_easy_setopt (wp->curl, CURLOPT_URL, wp->url);
curl_easy_setopt (wp->curl, CURLOPT_FOLLOWLOCATION, 1L);
diff --git a/src/curl_json.c b/src/curl_json.c
index 511863e39f12e98b3914f83ebc0ba446f5db4f20..251fee8563cb4e865dcb0021cb8d0acb8ec592e0 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cj_curl_callback);
curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
- curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
- PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (db->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (db->curl, CURLOPT_ERRORBUFFER, db->curl_errbuf);
curl_easy_setopt (db->curl, CURLOPT_URL, db->url);
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 5adaf067a157e44220655adb79855c6fee0d3b26..3554d7e5f081aa616482018f469c72680a1239cf 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cx_curl_callback);
curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
- curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
- PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (db->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (db->curl, CURLOPT_ERRORBUFFER, db->curl_errbuf);
curl_easy_setopt (db->curl, CURLOPT_URL, db->url);
diff --git a/src/nginx.c b/src/nginx.c
index de52262f4ec817b1b54ca876652b02e06a845252..c356353e3798ea3104625cb96c655e1271934eb8 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, nginx_curl_callback);
- curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, nginx_curl_error);
if (user != NULL)
diff --git a/src/write_http.c b/src/write_http.c
index 7f5943a2435f1f7c9dafa9221433dd2ef92f4e41..25133c39cd04ebdcaec852d2f824be304d46ec80 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
}
curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
+ curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
headers = NULL;
headers = curl_slist_append (headers, "Accept: */*");