[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r12843 - in libmicrohttpd/src: daemon examples include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r12843 - in libmicrohttpd/src: daemon examples include |
Date: |
Sat, 4 Sep 2010 21:55:40 +0200 |
Author: grothoff
Date: 2010-09-04 21:55:40 +0200 (Sat, 04 Sep 2010)
New Revision: 12843
Modified:
libmicrohttpd/src/daemon/digestauth.c
libmicrohttpd/src/examples/digest_auth_example.c
libmicrohttpd/src/include/microhttpd.h
Log:
fix parser issue, allow client to specify access-denied response body
Modified: libmicrohttpd/src/daemon/digestauth.c
===================================================================
--- libmicrohttpd/src/daemon/digestauth.c 2010-09-04 19:48:23 UTC (rev
12842)
+++ libmicrohttpd/src/daemon/digestauth.c 2010-09-04 19:55:40 UTC (rev
12843)
@@ -505,16 +505,13 @@
MHD_queue_auth_fail_response(struct MHD_Connection *connection,
const char *realm,
const char *opaque,
+ struct MHD_Response *response,
int signal_stale)
{
int ret;
size_t hlen;
char nonce[HASH_MD5_HEX_LEN + 9];
- struct MHD_Response *response;
- response = MHD_create_response_from_data(0, NULL, MHD_NO, MHD_NO);
- if (NULL == response)
- return MHD_NO;
/* Generating the server nonce */
calculate_nonce ((uint32_t) time(NULL),
@@ -549,7 +546,6 @@
ret = MHD_queue_response(connection,
MHD_HTTP_UNAUTHORIZED,
response);
- MHD_destroy_response(response);
return ret;
}
Modified: libmicrohttpd/src/examples/digest_auth_example.c
===================================================================
--- libmicrohttpd/src/examples/digest_auth_example.c 2010-09-04 19:48:23 UTC
(rev 12842)
+++ libmicrohttpd/src/examples/digest_auth_example.c 2010-09-04 19:55:40 UTC
(rev 12843)
@@ -26,8 +26,10 @@
#include <microhttpd.h>
#include <stdlib.h>
-#define PAGE "<html><head><title>libmicrohttpd
demo</title></head><body>libmicrohttpd demo</body></html>"
+#define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>Access
granted</body></html>"
+#define DENIED "<html><head><title>libmicrohttpd
demo</title></head><body>Access denied</body></html>"
+
#define OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4"
static int
@@ -46,20 +48,37 @@
username = MHD_digest_auth_get_username(connection);
if (username == NULL)
- return MHD_queue_auth_fail_response(connection, realm,
- OPAQUE,
- MHD_NO);
+ {
+ response = MHD_create_response_from_data(strlen (DENIED),
+ DENIED,
+ MHD_NO, MHD_NO);
+ ret = MHD_queue_auth_fail_response(connection, realm,
+ OPAQUE,
+ response,
+ MHD_NO);
+ MHD_destroy_response(response);
+ return ret;
+ }
ret = MHD_digest_auth_check(connection, realm,
username,
password,
300);
free(username);
- if (ret == MHD_INVALID_NONCE)
- return MHD_queue_auth_fail_response(connection, realm,
- OPAQUE, MHD_YES);
- if (ret == MHD_NO)
- return MHD_queue_auth_fail_response(connection, realm,
- OPAQUE, MHD_NO);
+ if ( (ret == MHD_INVALID_NONCE) ||
+ (ret == MHD_NO) )
+ {
+ response = MHD_create_response_from_data(strlen (DENIED),
+ DENIED,
+ MHD_NO, MHD_NO);
+ if (NULL == response)
+ return MHD_NO;
+ ret = MHD_queue_auth_fail_response(connection, realm,
+ OPAQUE,
+ response,
+ (ret == MHD_INVALID_NONCE) ? MHD_YES :
MHD_NO);
+ MHD_destroy_response(response);
+ return ret;
+ }
response = MHD_create_response_from_data(strlen(PAGE), PAGE,
MHD_NO, MHD_NO);
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h 2010-09-04 19:48:23 UTC (rev
12842)
+++ libmicrohttpd/src/include/microhttpd.h 2010-09-04 19:55:40 UTC (rev
12843)
@@ -1316,6 +1316,9 @@
* @param connection The MHD connection structure
* @param realm The realm presented to the client
* @param opaque string to user for opaque value
+ * @param response reply to send; should contain the "access denied"
+ * body; note that this function will set the "WWW Authenticate"
+ * header and that the caller should not do this
* @param signal_stale MHD_YES if the nonce is invalid to add
* 'stale=true' to the authentication header
* @return MHD_YES on success, MHD_NO otherwise
@@ -1324,6 +1327,7 @@
MHD_queue_auth_fail_response(struct MHD_Connection *connection,
const char *realm,
const char *opaque,
+ struct MHD_Response *response,
int signal_stale);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r12843 - in libmicrohttpd/src: daemon examples include,
gnunet <=