libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 6ed5b52d3e41a706904e05277afad92087a54784
parent 84a92e8a7130c351b200dedc41b317e8a75ffcac
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 18 Jan 2022 15:56:09 +0300

Fixed early response with digest auth in tests, examples, and documentation

Diffstat:
Mdoc/libmicrohttpd.texi | 8++++++++
Msrc/examples/digest_auth_example.c | 8++++++++
Msrc/testcurl/test_digestauth.c | 8++++++++
Msrc/testcurl/test_digestauth_sha256.c | 8++++++++
Msrc/testcurl/test_digestauth_with_arguments.c | 8++++++++
5 files changed, 40 insertions(+), 0 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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")) )