[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36008 - libmicrohttpd/src/examples
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36008 - libmicrohttpd/src/examples |
Date: |
Fri, 26 Jun 2015 23:18:13 +0200 |
Author: grothoff
Date: 2015-06-26 23:18:13 +0200 (Fri, 26 Jun 2015)
New Revision: 36008
Modified:
libmicrohttpd/src/examples/fileserver_example.c
Log:
-support HEAD in example
Modified: libmicrohttpd/src/examples/fileserver_example.c
===================================================================
--- libmicrohttpd/src/examples/fileserver_example.c 2015-06-26 16:57:21 UTC
(rev 36007)
+++ libmicrohttpd/src/examples/fileserver_example.c 2015-06-26 21:18:13 UTC
(rev 36008)
@@ -16,7 +16,6 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
-
/**
* @file fileserver_example.c
* @brief minimal example for how to use libmicrohttpd to serve files
@@ -29,8 +28,12 @@
#define PAGE "<html><head><title>File not found</title></head><body>File not
found</body></html>"
+
static ssize_t
-file_reader (void *cls, uint64_t pos, char *buf, size_t max)
+file_reader (void *cls,
+ uint64_t pos,
+ char *buf,
+ size_t max)
{
FILE *file = cls;
@@ -38,6 +41,7 @@
return fread (buf, 1, max, file);
}
+
static void
free_callback (void *cls)
{
@@ -45,6 +49,7 @@
fclose (file);
}
+
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
@@ -60,7 +65,8 @@
FILE *file;
struct stat buf;
- if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
+ if ( (0 != strcmp (method, MHD_HTTP_METHOD_GET)) &&
+ (0 != strcmp (method, MHD_HTTP_METHOD_HEAD)) )
return MHD_NO; /* unexpected method */
if (&aptr != *ptr)
{
@@ -73,7 +79,7 @@
file = fopen (&url[1], "rb");
else
file = NULL;
- if (file == NULL)
+ if (NULL == file)
{
response = MHD_create_response_from_buffer (strlen (PAGE),
(void *) PAGE,
@@ -87,7 +93,7 @@
&file_reader,
file,
&free_callback);
- if (response == NULL)
+ if (NULL == response)
{
fclose (file);
return MHD_NO;
@@ -98,6 +104,7 @@
return ret;
}
+
int
main (int argc, char *const *argv)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36008 - libmicrohttpd/src/examples,
gnunet <=