Przeglądaj źródła

close file, clarify license

Christian Grothoff 13 lat temu
rodzic
commit
bf92eff1f8

+ 3 - 0
doc/examples/basicauthentication.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>

+ 3 - 0
doc/examples/hellobrowser.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>

+ 13 - 6
doc/examples/largepost.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
@@ -108,6 +111,7 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
   return MHD_YES;
   return MHD_YES;
 }
 }
 
 
+
 static void
 static void
 request_completed (void *cls, struct MHD_Connection *connection,
 request_completed (void *cls, struct MHD_Connection *connection,
                    void **con_cls, enum MHD_RequestTerminationCode toe)
                    void **con_cls, enum MHD_RequestTerminationCode toe)
@@ -200,29 +204,32 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
           return MHD_YES;
           return MHD_YES;
         }
         }
       else
       else
-        return send_page (connection, con_info->answerstring,
-                          con_info->answercode);
+	{
+	  if (NULL != con_info->fp)
+	    fclose (con_info->fp);
+	  /* Now it is safe to open and inspect the file before calling send_page with a response */
+	  return send_page (connection, con_info->answerstring,
+			    con_info->answercode);
+	}
+
     }
     }
 
 
   return send_page (connection, errorpage, MHD_HTTP_BAD_REQUEST);
   return send_page (connection, errorpage, MHD_HTTP_BAD_REQUEST);
 }
 }
 
 
+
 int
 int
 main ()
 main ()
 {
 {
   struct MHD_Daemon *daemon;
   struct MHD_Daemon *daemon;
 
 
-
   daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL,
   daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL,
                              &answer_to_connection, NULL,
                              &answer_to_connection, NULL,
                              MHD_OPTION_NOTIFY_COMPLETED, request_completed,
                              MHD_OPTION_NOTIFY_COMPLETED, request_completed,
                              NULL, MHD_OPTION_END);
                              NULL, MHD_OPTION_END);
   if (NULL == daemon)
   if (NULL == daemon)
     return 1;
     return 1;
-
   getchar ();
   getchar ();
-
   MHD_stop_daemon (daemon);
   MHD_stop_daemon (daemon);
-
   return 0;
   return 0;
 }
 }

+ 3 - 0
doc/examples/logging.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>

+ 3 - 0
doc/examples/responseheaders.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>

+ 2 - 23
doc/examples/sessions.c

@@ -1,26 +1,5 @@
-/*
-     This file is part of libmicrohttpd
-     (C) 2011 Christian Grothoff (and other contributing authors)
-
-     This library is free software; you can redistribute it and/or
-     modify it under the terms of the GNU Lesser General Public
-     License as published by the Free Software Foundation; either
-     version 2.1 of the License, or (at your option) any later version.
-
-     This library is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     Lesser General Public License for more details.
-
-     You should have received a copy of the GNU Lesser General Public
-     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 post_example.c
- * @brief example for processing POST requests using libmicrohttpd
- * @author Christian Grothoff
- */
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
 
 
 /* needed for asprintf */
 /* needed for asprintf */
 #define _GNU_SOURCE
 #define _GNU_SOURCE

+ 3 - 0
doc/examples/simplepost.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>

+ 3 - 0
doc/examples/tlsauthentication.c

@@ -1,3 +1,6 @@
+/* Feel free to use this example code in any way
+   you see fit (Public Domain) */
+
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/socket.h>