summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c6037f4)
raw | patch | inline | side by side (parent: c6037f4)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 6 Aug 2014 13:24:33 +0000 (15:24 +0200) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 6 Aug 2014 13:24:33 +0000 (15:24 +0200) |
CURLOPT_USERNAME and CURLOPT_PASSWORD were introduced in curl 7.19.1.
They supersed CURLOPT_USERPWD which couldn't handle colons in the
username or password.
They supersed CURLOPT_USERPWD which couldn't handle colons in the
username or password.
configure.ac | patch | blob | history | |
src/curl.c | patch | blob | history | |
src/curl_json.c | patch | blob | history | |
src/curl_xml.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 1757e2fa21c3228cc1b7c99c0c5e7144be1a8cb3..c843d31e838ac9e1c965623e858ce3f8295e970a 100644 (file)
--- a/configure.ac
+++ b/configure.ac
[with_libcurl="yes"],
[with_libcurl="no (symbol 'curl_easy_init' not found)"],
[$with_curl_libs])
+ AC_CHECK_DECL(CURLOPT_USERNAME,
+ [have_curlopt_username="yes"],
+ [have_curlopt_username="no"],
+ [[#include <curl/curl.h>]])
fi
fi
if test "x$with_libcurl" = "xyes"
BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
+
+ if test "x$have_curlopt_username" = "xyes"
+ then
+ AC_DEFINE(HAVE_CURLOPT_USERNAME, 1, [Define if libcurl supports CURLOPT_USERNAME option.])
+ fi
fi
AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
# }}}
diff --git a/src/curl.c b/src/curl.c
index 0e6596d490a2d8699dad8f054615ffefc29c7d4a..c188c717b1b61657ca7c0f4aca5c5bf348aed3a2 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
if (wp->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (wp->curl, CURLOPT_USERNAME, wp->user);
+ curl_easy_setopt (wp->curl, CURLOPT_PASSWORD,
+ (wp->pass == NULL) ? "" : wp->pass);
+#else
size_t credentials_size;
credentials_size = strlen (wp->user) + 2;
ssnprintf (wp->credentials, credentials_size, "%s:%s",
wp->user, (wp->pass == NULL) ? "" : wp->pass);
curl_easy_setopt (wp->curl, CURLOPT_USERPWD, wp->credentials);
+#endif
if (wp->digest)
curl_easy_setopt (wp->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
diff --git a/src/curl_json.c b/src/curl_json.c
index 58f0b35c10d84c63aa1b2b52f6a2f6c237196ab1..860de6163a8675281e3494cc77f9938d5265862c 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
if (db->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (db->curl, CURLOPT_USERNAME, db->user);
+ curl_easy_setopt (db->curl, CURLOPT_PASSWORD,
+ (db->pass == NULL) ? "" : db->pass);
+#else
size_t credentials_size;
credentials_size = strlen (db->user) + 2;
ssnprintf (db->credentials, credentials_size, "%s:%s",
db->user, (db->pass == NULL) ? "" : db->pass);
curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
+#endif
if (db->digest)
curl_easy_setopt (db->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 850a4aa582c756dd0c2310bb8bb3bd32c62488e7..bbcbc04d225b06dfb67beafebd1f96eceed16990 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
if (db->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (db->curl, CURLOPT_USERNAME, db->user);
+ curl_easy_setopt (db->curl, CURLOPT_PASSWORD,
+ (db->pass == NULL) ? "" : db->pass);
+#else
size_t credentials_size;
credentials_size = strlen (db->user) + 2;
ssnprintf (db->credentials, credentials_size, "%s:%s",
db->user, (db->pass == NULL) ? "" : db->pass);
curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
+#endif
if (db->digest)
curl_easy_setopt (db->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);