[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated (d41ebab2 -> 1e7346ce)
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated (d41ebab2 -> 1e7346ce) |
Date: |
Sun, 30 Jan 2022 15:12:58 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a change to branch master
in repository libmicrohttpd.
from d41ebab2 Fixed code style in basicauth.c
new 4ec79163 test_{digestauth,quiesce}: added report for libcurl error
new 1a1e9a59 test_digestauth: added workaround for bug in old libcurl
new 1e7346ce test_digestauth: removed unneeded escaping in test URL
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/testcurl/test_digestauth.c | 104 +++++++++++++++++++++++++++++++++++------
src/testcurl/test_quiesce.c | 74 ++++++++++++++++++++++-------
2 files changed, 148 insertions(+), 30 deletions(-)
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index 93f79a6a..47d4f5d0 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -46,6 +46,22 @@
#include <wincrypt.h>
#endif
+#ifndef CURL_VERSION_BITS
+#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
+#endif /* ! CURL_VERSION_BITS */
+#ifndef CURL_AT_LEAST_VERSION
+#define CURL_AT_LEAST_VERSION(x,y,z) \
+ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
+#endif /* ! CURL_AT_LEAST_VERSION */
+
+#ifndef _MHD_INSTRMACRO
+/* Quoted macro parameter */
+#define _MHD_INSTRMACRO(a) #a
+#endif /* ! _MHD_INSTRMACRO */
+#ifndef _MHD_STRMACRO
+/* Quoted expanded macro parameter */
+#define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a)
+#endif /* ! _MHD_STRMACRO */
#if defined(HAVE___FUNC__)
#define externalErrorExit(ignore) \
@@ -60,6 +76,9 @@
_mhdErrorExit_func(NULL, __func__, __LINE__)
#define mhdErrorExitDesc(errDesc) \
_mhdErrorExit_func(errDesc, __func__, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \
+ __func__, __LINE__)
#elif defined(HAVE___FUNCTION__)
#define externalErrorExit(ignore) \
_externalErrorExit_func(NULL, __FUNCTION__, __LINE__)
@@ -73,6 +92,9 @@
_mhdErrorExit_func(NULL, __FUNCTION__, __LINE__)
#define mhdErrorExitDesc(errDesc) \
_mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \
+ __FUNCTION__, __LINE__)
#else
#define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__)
#define externalErrorExitDesc(errDesc) \
@@ -82,6 +104,8 @@
_libcurlErrorExit_func(errDesc, NULL, __LINE__)
#define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__)
#define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), NULL,
__LINE__)
#endif
@@ -125,8 +149,11 @@ _libcurlErrorExit_func (const char *errDesc, const char
*funcName, int lineNum)
fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
strerror (errno));
+#ifdef MHD_WINSOCK_SOCKETS
+ fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ());
+#endif /* MHD_WINSOCK_SOCKETS */
if (0 != libcurl_errbuf[0])
- fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf);
+ fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf);
fflush (stderr);
exit (99);
@@ -148,16 +175,48 @@ _mhdErrorExit_func (const char *errDesc, const char
*funcName, int lineNum)
fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
strerror (errno));
+#ifdef MHD_WINSOCK_SOCKETS
+ fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ());
+#endif /* MHD_WINSOCK_SOCKETS */
fflush (stderr);
exit (8);
}
+static void
+_checkCURLE_OK_func (CURLcode code, const char *curlFunc,
+ const char *funcName, int lineNum)
+{
+ if (CURLE_OK == code)
+ return;
+
+ fflush (stdout);
+ if ((NULL != curlFunc) && (0 != curlFunc[0]))
+ fprintf (stderr, "'%s' resulted in '%s'", curlFunc,
+ curl_easy_strerror (code));
+ else
+ fprintf (stderr, "libcurl function call resulted in '%s'",
+ curl_easy_strerror (code));
+ if ((NULL != funcName) && (0 != funcName[0]))
+ fprintf (stderr, " in %s", funcName);
+ if (0 < lineNum)
+ fprintf (stderr, " at line %d", lineNum);
+
+ fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
+ strerror (errno));
+ if (0 != libcurl_errbuf[0])
+ fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf);
+
+ fflush (stderr);
+ exit (9);
+}
+
+
/* Could be increased to facilitate debugging */
#define TIMEOUTS_VAL 5
-#define MHD_URI_BASE_PATH "/bar%%20foo%%3Fkey%%3Dvalue"
+#define MHD_URI_BASE_PATH "/bar%20foo%3Fkey%3Dvalue"
#define PAGE \
"<html><head><title>libmicrohttpd demo</title></head><body>Access
granted</body></html>"
@@ -285,27 +344,44 @@ static CURL *
setupCURL (void *cbc, int port)
{
CURL *c;
+ char url[512];
+
+ if (1)
+ {
+ int res;
+ /* A workaround for some old libcurl versions, which ignore the specified
+ * port by CURLOPT_PORT when digest authorisation is used. */
+ res = snprintf (url, (sizeof(url) / sizeof(url[0])),
+ "http://127.0.0.1:%d%s", port, MHD_URI_BASE_PATH);
+ if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res))
+ externalErrorExitDesc ("Cannot form request URL");
+ }
c = curl_easy_init ();
if (NULL == c)
libcurlErrorExitDesc ("curl_easy_init() failed");
if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) ||
- (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL,
- "http://127.0.0.1" MHD_URI_BASE_PATH)) ||
- (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) ||
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER,
+ libcurl_errbuf)) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION,
©Buffer)) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT,
- (long) TIMEOUTS_VAL)) ||
+ ((long) TIMEOUTS_VAL))) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT,
- (long) TIMEOUTS_VAL)) ||
- (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER,
- libcurl_errbuf)) ||
- (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) ||
+ ((long) TIMEOUTS_VAL))) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION,
- CURL_HTTP_VERSION_1_1)))
+ CURL_HTTP_VERSION_1_1)) ||
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) ||
+#if CURL_AT_LEAST_VERSION (7, 19, 4)
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) ||
+#endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */
+#if CURL_AT_LEAST_VERSION (7, 45, 0)
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) ||
+#endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port))) ||
+ (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, url)))
libcurlErrorExitDesc ("curl_easy_setopt() failed");
if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST)) ||
(CURLE_OK != curl_easy_setopt (c, CURLOPT_USERPWD,
@@ -319,7 +395,6 @@ static int
testDigestAuth ()
{
CURL *c;
- CURLcode errornum;
struct MHD_Daemon *d;
struct CBC cbc;
char buf[2048];
@@ -393,8 +468,9 @@ testDigestAuth ()
port = (int) dinfo->port;
}
c = setupCURL (&cbc, port);
- if (CURLE_OK != (errornum = curl_easy_perform (c)))
- mhdErrorExitDesc ("curl_easy_perform() failed");
+
+ checkCURLE_OK (curl_easy_perform (c));
+
curl_easy_cleanup (c);
MHD_stop_daemon (d);
if (cbc.pos != strlen (PAGE))
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c
index f9bca831..1ea194b9 100644
--- a/src/testcurl/test_quiesce.c
+++ b/src/testcurl/test_quiesce.c
@@ -52,6 +52,15 @@
#endif
+#ifndef _MHD_INSTRMACRO
+/* Quoted macro parameter */
+#define _MHD_INSTRMACRO(a) #a
+#endif /* ! _MHD_INSTRMACRO */
+#ifndef _MHD_STRMACRO
+/* Quoted expanded macro parameter */
+#define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a)
+#endif /* ! _MHD_STRMACRO */
+
#if defined(HAVE___FUNC__)
#define externalErrorExit(ignore) \
_externalErrorExit_func(NULL, __func__, __LINE__)
@@ -65,6 +74,9 @@
_mhdErrorExit_func(NULL, __func__, __LINE__)
#define mhdErrorExitDesc(errDesc) \
_mhdErrorExit_func(errDesc, __func__, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \
+ __func__, __LINE__)
#elif defined(HAVE___FUNCTION__)
#define externalErrorExit(ignore) \
_externalErrorExit_func(NULL, __FUNCTION__, __LINE__)
@@ -78,6 +90,9 @@
_mhdErrorExit_func(NULL, __FUNCTION__, __LINE__)
#define mhdErrorExitDesc(errDesc) \
_mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \
+ __FUNCTION__, __LINE__)
#else
#define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__)
#define externalErrorExitDesc(errDesc) \
@@ -87,12 +102,15 @@
_libcurlErrorExit_func(errDesc, NULL, __LINE__)
#define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__)
#define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__)
+#define checkCURLE_OK(libcurlcall) \
+ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), NULL,
__LINE__)
#endif
_MHD_NORETURN static void
_externalErrorExit_func (const char *errDesc, const char *funcName, int
lineNum)
{
+ fflush (stdout);
if ((NULL != errDesc) && (0 != errDesc[0]))
fprintf (stderr, "%s", errDesc);
else
@@ -117,6 +135,7 @@ static char libcurl_errbuf[CURL_ERROR_SIZE] = "";
_MHD_NORETURN static void
_libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
{
+ fflush (stdout);
if ((NULL != errDesc) && (0 != errDesc[0]))
fprintf (stderr, "%s", errDesc);
else
@@ -128,8 +147,11 @@ _libcurlErrorExit_func (const char *errDesc, const char
*funcName, int lineNum)
fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
strerror (errno));
+#ifdef MHD_WINSOCK_SOCKETS
+ fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ());
+#endif /* MHD_WINSOCK_SOCKETS */
if (0 != libcurl_errbuf[0])
- fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf);
+ fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf);
fflush (stderr);
exit (99);
@@ -139,6 +161,7 @@ _libcurlErrorExit_func (const char *errDesc, const char
*funcName, int lineNum)
_MHD_NORETURN static void
_mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
{
+ fflush (stdout);
if ((NULL != errDesc) && (0 != errDesc[0]))
fprintf (stderr, "%s", errDesc);
else
@@ -150,12 +173,44 @@ _mhdErrorExit_func (const char *errDesc, const char
*funcName, int lineNum)
fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
strerror (errno));
+#ifdef MHD_WINSOCK_SOCKETS
+ fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ());
+#endif /* MHD_WINSOCK_SOCKETS */
fflush (stderr);
exit (8);
}
+static void
+_checkCURLE_OK_func (CURLcode code, const char *curlFunc,
+ const char *funcName, int lineNum)
+{
+ if (CURLE_OK == code)
+ return;
+
+ fflush (stdout);
+ if ((NULL != curlFunc) && (0 != curlFunc[0]))
+ fprintf (stderr, "'%s' resulted in '%s'", curlFunc,
+ curl_easy_strerror (code));
+ else
+ fprintf (stderr, "libcurl function call resulted in '%s'",
+ curl_easy_strerror (code));
+ if ((NULL != funcName) && (0 != funcName[0]))
+ fprintf (stderr, " in %s", funcName);
+ if (0 < lineNum)
+ fprintf (stderr, " at line %d", lineNum);
+
+ fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno,
+ strerror (errno));
+ if (0 != libcurl_errbuf[0])
+ fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf);
+
+ fflush (stderr);
+ exit (9);
+}
+
+
/* Could be increased to facilitate debugging */
#define TIMEOUTS_VAL 4
@@ -347,7 +402,6 @@ testGet (int type, int pool_count, int poll_flag)
CURL *c;
char buf[2048];
struct CBC cbc;
- CURLcode errornum;
MHD_socket fd;
pthread_t thrd;
const char *thrdRet;
@@ -387,13 +441,7 @@ testGet (int type, int pool_count, int poll_flag)
c = setupCURL (&cbc);
- if (CURLE_OK != (errornum = curl_easy_perform (c)))
- {
- fprintf (stderr,
- "curl_easy_perform() failed: '%s'. ",
- curl_easy_strerror (errornum));
- libcurlErrorExit ();
- }
+ checkCURLE_OK (curl_easy_perform (c));
if (cbc.pos != strlen (MHD_URI_BASE_PATH))
{
@@ -421,13 +469,7 @@ testGet (int type, int pool_count, int poll_flag)
/* No need for the thread sync as socket is already listening,
* so libcurl may start connecting before MHD is started in another thread */
cbc.pos = 0;
- if (CURLE_OK != (errornum = curl_easy_perform (c)))
- {
- fprintf (stderr,
- "curl_easy_perform() failed: `%s'\n",
- curl_easy_strerror (errornum));
- mhdErrorExit ();
- }
+ checkCURLE_OK (curl_easy_perform (c));
if (cbc.pos != strlen (MHD_URI_BASE_PATH))
{
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (d41ebab2 -> 1e7346ce),
gnunet <=