close file, clarify license

This commit is contained in:
Christian Grothoff
2012-08-23 12:36:18 +00:00
parent 5133b28b09
commit bf92eff1f8
8 changed files with 33 additions and 29 deletions
+3
View File
@@ -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/select.h>
#include <sys/socket.h>
+3
View File
@@ -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/select.h>
#include <sys/socket.h>
+13 -6
View File
@@ -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/select.h>
#include <sys/socket.h>
@@ -108,6 +111,7 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
return MHD_YES;
}
static void
request_completed (void *cls, struct MHD_Connection *connection,
void **con_cls, enum MHD_RequestTerminationCode toe)
@@ -200,29 +204,32 @@ answer_to_connection (void *cls, struct MHD_Connection *connection,
return MHD_YES;
}
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);
}
int
main ()
{
struct MHD_Daemon *daemon;
daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL,
&answer_to_connection, NULL,
MHD_OPTION_NOTIFY_COMPLETED, request_completed,
NULL, MHD_OPTION_END);
if (NULL == daemon)
return 1;
getchar ();
MHD_stop_daemon (daemon);
return 0;
}
+3
View File
@@ -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/select.h>
#include <sys/socket.h>
+3
View File
@@ -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/select.h>
#include <sys/socket.h>
+2 -23
View File
@@ -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 */
#define _GNU_SOURCE
+3
View File
@@ -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/select.h>
#include <sys/socket.h>
+3
View File
@@ -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/select.h>
#include <sys/socket.h>