[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18423 - in libmicrohttpd: . src/examples
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18423 - in libmicrohttpd: . src/examples |
Date: |
Thu, 1 Dec 2011 15:24:24 +0100 |
Author: grothoff
Date: 2011-12-01 15:24:24 +0100 (Thu, 01 Dec 2011)
New Revision: 18423
Modified:
libmicrohttpd/AUTHORS
libmicrohttpd/ChangeLog
libmicrohttpd/src/examples/authorization_example.c
Log:
Hi there,
am I right in the assumption, that the documentation at
http://www.gnu.org/s/libmicrohttpd/tutorial.html#Supporting-basic-authentication
is newer than authorization_example.c in the src/examples/ subdirectory?
If so here is a patch to make authorization_example.c use the functions from
the tutorial instead of raw base64 strings.
Regards
Sven
-
Modified: libmicrohttpd/AUTHORS
===================================================================
--- libmicrohttpd/AUTHORS 2011-12-01 14:17:49 UTC (rev 18422)
+++ libmicrohttpd/AUTHORS 2011-12-01 14:24:24 UTC (rev 18423)
@@ -35,6 +35,7 @@
Jan Seeger <address@hidden>
Will Bryant <address@hidden>
LRN <address@hidden>
+Sven Geggus <address@hidden>
Documentation contributions also came from:
Marco Maggi <address@hidden>
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2011-12-01 14:17:49 UTC (rev 18422)
+++ libmicrohttpd/ChangeLog 2011-12-01 14:24:24 UTC (rev 18423)
@@ -1,3 +1,7 @@
+Thu Dec 1 15:22:57 CET 2011
+ Updated authorization_example.c to actually demonstrate the current
+ MHD API. -SG
+
Mon Nov 21 18:51:30 CET 2011
Added option to suppress generation of the 'Date:' header to be
used on embedded systems without RTC. Documented the new option
Modified: libmicrohttpd/src/examples/authorization_example.c
===================================================================
--- libmicrohttpd/src/examples/authorization_example.c 2011-12-01 14:17:49 UTC
(rev 18422)
+++ libmicrohttpd/src/examples/authorization_example.c 2011-12-01 14:24:24 UTC
(rev 18423)
@@ -44,8 +44,9 @@
const char *me = cls;
struct MHD_Response *response;
int ret;
- int code;
- const char *auth;
+ char *user;
+ char *pass;
+ int fail;
if (0 != strcmp (method, "GET"))
return MHD_NO; /* unexpected method */
@@ -56,28 +57,26 @@
return MHD_YES;
}
*ptr = NULL; /* reset when done */
- auth = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_AUTHORIZATION);
- if ((auth == NULL) ||
- (0 != strcmp (auth, "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")))
- {
- /* require: "Aladdin" with password "open sesame" */
+
+ /* require: "Aladdin" with password "open sesame" */
+ pass = NULL;
+ user = MHD_basic_auth_get_username_password (connection, &pass);
+ fail = ( (user == NULL) || (0 != strcmp (user, "Aladdin")) || (0 != strcmp
(pass, "open sesame") ) );
+ if (fail)
+ {
response = MHD_create_response_from_buffer (strlen (DENIED),
(void *) DENIED,
MHD_RESPMEM_PERSISTENT);
- MHD_add_response_header (response, MHD_HTTP_HEADER_WWW_AUTHENTICATE,
- "Basic realm=\"TestRealm\"");
- code = MHD_HTTP_UNAUTHORIZED;
+ ret = MHD_queue_basic_auth_fail_response
(connection,"TestRealm",response);
}
else
{
response = MHD_create_response_from_buffer (strlen (me),
(void *) me,
MHD_RESPMEM_PERSISTENT);
- code = MHD_HTTP_OK;
+ ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
}
- ret = MHD_queue_response (connection, code, response);
+
MHD_destroy_response (response);
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18423 - in libmicrohttpd: . src/examples,
gnunet <=