libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit bf92eff1f850b9d2ed436bc05f163457007cbdef
parent 5133b28b095aa37938ff6f7a82b4235918057d40
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 23 Aug 2012 12:36:18 +0000

close file, clarify license

Diffstat:
Mdoc/examples/basicauthentication.c | 3+++
Mdoc/examples/hellobrowser.c | 3+++
Mdoc/examples/largepost.c | 19+++++++++++++------
Mdoc/examples/logging.c | 3+++
Mdoc/examples/responseheaders.c | 3+++
Mdoc/examples/sessions.c | 25++-----------------------
Mdoc/examples/simplepost.c | 3+++
Mdoc/examples/tlsauthentication.c | 3+++
8 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/doc/examples/basicauthentication.c b/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/select.h> #include <sys/socket.h> diff --git a/doc/examples/hellobrowser.c b/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/select.h> #include <sys/socket.h> diff --git a/doc/examples/largepost.c b/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/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; } diff --git a/doc/examples/logging.c b/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/select.h> #include <sys/socket.h> diff --git a/doc/examples/responseheaders.c b/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/select.h> #include <sys/socket.h> diff --git a/doc/examples/sessions.c b/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 */ #define _GNU_SOURCE diff --git a/doc/examples/simplepost.c b/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/select.h> #include <sys/socket.h> diff --git a/doc/examples/tlsauthentication.c b/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/select.h> #include <sys/socket.h>