diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi index a14c28d3..46eed3b0 100644 --- a/doc/libmicrohttpd.texi +++ b/doc/libmicrohttpd.texi @@ -3302,6 +3302,14 @@ ahc_echo (void *cls, const char *password = "testpass"; const char *realm = "test@@example.com"; int ret; + static int already_called_marker; + + if (&already_called_marker != *req_cls) + @{ /* Called for the first time, request not fully read yet */ + *req_cls = &already_called_marker; + /* Wait for complete request */ + return MHD_YES; + @} username = MHD_digest_auth_get_username (connection); if (username == NULL) diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c index 44faefeb..ea3da19a 100644 --- a/src/examples/digest_auth_example.c +++ b/src/examples/digest_auth_example.c @@ -48,6 +48,7 @@ ahc_echo (void *cls, const char *realm = "test@example.com"; int res; enum MHD_Result ret; + static int already_called_marker; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) method; /* Unused. Silent compiler warning. */ @@ -56,6 +57,13 @@ ahc_echo (void *cls, (void) upload_data_size; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ + if (&already_called_marker != *req_cls) + { /* Called for the first time, request not fully read yet */ + *req_cls = &already_called_marker; + /* Wait for complete request */ + return MHD_YES; + } + username = MHD_digest_auth_get_username (connection); if (NULL == username) { diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c index 13c9c826..5dd9d466 100644 --- a/src/testcurl/test_digestauth.c +++ b/src/testcurl/test_digestauth.c @@ -94,10 +94,18 @@ ahc_echo (void *cls, const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; + static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ + if (&already_called_marker != *req_cls) + { /* Called for the first time, request not fully read yet */ + *req_cls = &already_called_marker; + /* Wait for complete request */ + return MHD_YES; + } + username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) diff --git a/src/testcurl/test_digestauth_sha256.c b/src/testcurl/test_digestauth_sha256.c index 7f8ebcd5..fff3a1d7 100644 --- a/src/testcurl/test_digestauth_sha256.c +++ b/src/testcurl/test_digestauth_sha256.c @@ -95,10 +95,18 @@ ahc_echo (void *cls, const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; + static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ + if (&already_called_marker != *req_cls) + { /* Called for the first time, request not fully read yet */ + *req_cls = &already_called_marker; + /* Wait for complete request */ + return MHD_YES; + } + username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c index ce4b8970..91f2dd67 100644 --- a/src/testcurl/test_digestauth_with_arguments.c +++ b/src/testcurl/test_digestauth_with_arguments.c @@ -88,10 +88,18 @@ ahc_echo (void *cls, const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; + static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ + if (&already_called_marker != *req_cls) + { /* Called for the first time, request not fully read yet */ + *req_cls = &already_called_marker; + /* Wait for complete request */ + return MHD_YES; + } + username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) )