gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11711 - in libmicrohttpd: . src/examples


From: gnunet
Subject: [GNUnet-SVN] r11711 - in libmicrohttpd: . src/examples
Date: Sun, 13 Jun 2010 11:04:38 +0200

Author: grothoff
Date: 2010-06-13 11:04:38 +0200 (Sun, 13 Jun 2010)
New Revision: 11711

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/examples/fileserver_example_dirs.c
Log:
better

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2010-06-13 08:51:33 UTC (rev 11710)
+++ libmicrohttpd/ChangeLog     2010-06-13 09:04:38 UTC (rev 11711)
@@ -1,3 +1,6 @@
+Sun Jun 13 10:52:34 CEST 2010
+       Cleaned up example code. -CG
+
 Fri Apr 23 09:56:37 CEST 2010
        Do not return HTTP headers for requests without version
        numbers.  Do return HTTP version 1.0 if client requested

Modified: libmicrohttpd/src/examples/fileserver_example_dirs.c
===================================================================
--- libmicrohttpd/src/examples/fileserver_example_dirs.c        2010-06-13 
08:51:33 UTC (rev 11710)
+++ libmicrohttpd/src/examples/fileserver_example_dirs.c        2010-06-13 
09:04:38 UTC (rev 11711)
@@ -101,7 +101,11 @@
       return MHD_YES;
     }
   *ptr = NULL;                  /* reset when done */
-  file = fopen (&url[1], "rb");
+  if ( (0 == stat (&url[1], &buf)) &&
+       (S_ISREG (buf.st_mode)) )
+    file = fopen (&url[1], "rb");
+  else
+    file = NULL;
   if (file == NULL)
     {
       dir = opendir (".");
@@ -140,11 +144,15 @@
     }
   else
     {
-      stat (&url[1], &buf);
       response = MHD_create_response_from_callback (buf.st_size, 32 * 1024,    
 /* 32k page size */
                                                     &file_reader,
                                                     file,
                                                     &file_free_callback);
+      if (response == NULL)
+       {
+         fclose (file);
+         return MHD_NO;
+       }
       ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
       MHD_destroy_response (response);
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]