├── .gitignore ├── LICENSE ├── Makefile.am ├── Makefile.in ├── README.md ├── aclocal.m4 ├── config.h.in ├── configure ├── configure.ac ├── doc ├── playback_architecture.graffle └── playback_architecture.png ├── install-sh ├── missing ├── src ├── Makefile.am ├── Makefile.in └── mysql_slowlogd.c └── vendor ├── boyer-moore-horspool └── StreamBoyerMooreHorspool.h └── libmicrohttpd ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── MHD_config.h.in ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── acinclude.m4 ├── aclocal.m4 ├── compile ├── config.guess ├── config.sub ├── configure ├── configure.ac ├── contrib ├── Makefile.am ├── Makefile.in ├── ascebc ├── mhd.png ├── mhd.svg ├── mhd_logo.png └── xcc ├── depcomp ├── doc ├── Doxyfile ├── Makefile.am ├── Makefile.in ├── chapters │ ├── basicauthentication.inc │ ├── bibliography.inc │ ├── exploringrequests.inc │ ├── hellobrowser.inc │ ├── introduction.inc │ ├── largerpost.inc │ ├── processingpost.inc │ ├── responseheaders.inc │ ├── sessions.inc │ └── tlsauthentication.inc ├── ecos.texi ├── examples │ ├── basicauthentication.c │ ├── hellobrowser.c │ ├── largepost.c │ ├── logging.c │ ├── responseheaders.c │ ├── sessions.c │ ├── simplepost.c │ └── tlsauthentication.c ├── fdl-1.3.texi ├── lgpl.texi ├── libmicrohttpd.3 ├── mdate-sh ├── microhttpd-tutorial.info ├── microhttpd-tutorial.texi ├── microhttpd.info ├── microhttpd.texi ├── texinfo.tex └── version.texi ├── install-sh ├── libmicrohttpd.pc.in ├── ltmain.sh ├── m4 ├── Makefile.am ├── Makefile.in ├── libcurl.m4 ├── libgcrypt.m4 ├── libtool.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 └── lt~obsolete.m4 ├── missing └── src ├── Makefile.am ├── Makefile.in ├── daemon ├── EXPORT.sym ├── Makefile.am ├── Makefile.in ├── base64.c ├── base64.h ├── basicauth.c ├── connection.c ├── connection.h ├── connection_https.c ├── connection_https.h ├── daemon.c ├── daemon_test.c ├── digestauth.c ├── internal.c ├── internal.h ├── md5.c ├── md5.h ├── memorypool.c ├── memorypool.h ├── postprocessor.c ├── postprocessor_large_test.c ├── postprocessor_test.c ├── reason_phrase.c ├── reason_phrase.h ├── response.c └── response.h ├── examples ├── Makefile.am ├── Makefile.in ├── authorization_example.c ├── digest_auth_example.c ├── dual_stack_example.c ├── fileserver_example.c ├── fileserver_example_dirs.c ├── fileserver_example_external_select.c ├── https_fileserver_example.c ├── minimal_example.c ├── minimal_example_comet.c ├── post_example.c ├── querystring_example.c └── refuse_post_example.c ├── include ├── Makefile.am ├── Makefile.in ├── microhttpd.h ├── platform.h └── plibc │ ├── Makefile.am │ ├── Makefile.in │ └── plibc.h ├── testcurl ├── Makefile.am ├── Makefile.in ├── curl_version_check.c ├── daemon_options_test.c ├── daemontest_digestauth.c ├── daemontest_digestauth_with_arguments.c ├── daemontest_get.c ├── daemontest_get_chunked.c ├── daemontest_get_response_cleanup.c ├── daemontest_get_sendfile.c ├── daemontest_iplimit.c ├── daemontest_large_put.c ├── daemontest_long_header.c ├── daemontest_parse_cookies.c ├── daemontest_post.c ├── daemontest_post_loop.c ├── daemontest_postform.c ├── daemontest_process_arguments.c ├── daemontest_process_headers.c ├── daemontest_put.c ├── daemontest_put_chunked.c ├── daemontest_termination.c ├── daemontest_timeout.c ├── daemontest_urlparse.c ├── gauger.h ├── https │ ├── Makefile.am │ ├── Makefile.in │ ├── cert.pem │ ├── key.pem │ ├── mhds_get_test.c │ ├── mhds_get_test_select.c │ ├── mhds_multi_daemon_test.c │ ├── mhds_session_info_test.c │ ├── tls_authentication_test.c │ ├── tls_daemon_options_test.c │ ├── tls_multi_thread_mode_test.c │ ├── tls_session_time_out_test.c │ ├── tls_test_common.c │ ├── tls_test_common.h │ ├── tls_test_keys.h │ └── tls_thread_mode_test.c ├── perf_get.c ├── perf_get_concurrent.c ├── test_callback.c └── test_start_stop.c └── testzzuf ├── Makefile.am ├── Makefile.in ├── README ├── daemontest_get.c ├── daemontest_get_chunked.c ├── daemontest_large_put.c ├── daemontest_long_header.c ├── daemontest_post.c ├── daemontest_postform.c ├── daemontest_put.c ├── daemontest_put_chunked.c └── socat.c /.gitignore: -------------------------------------------------------------------------------- 1 | # autoconf 2 | .deps/ 3 | .libs/ 4 | a.out.dSYM/ 5 | autom4te.cache/ 6 | config.h 7 | config.log 8 | config.status 9 | libtool 10 | Makefile 11 | stamp-* 12 | vendor/libmicrohttpd/MHD_config.h 13 | *~ 14 | 15 | # build output 16 | *.pc 17 | *.o 18 | *.lo 19 | *.la 20 | src/mysql_slowlogd 21 | vendor/libmicrohttpd/src/examples/*_example 22 | vendor/libmicrohttpd/src/examples/fileserver_example_dirs 23 | vendor/libmicrohttpd/src/examples/fileserver_example_external_select 24 | vendor/libmicrohttpd/src/examples/minimal_example_comet 25 | vendor/libmicrohttpd/src/testcurl/daemon_options_test 26 | vendor/libmicrohttpd/src/testcurl/libcurl_version_check.a 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Groupon, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | - Neither the name of Groupon nor the names of its contributors 17 | may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012, Groupon, Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # 8 | # - Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # - Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following 13 | # disclaimer in the documentation and/or other materials provided 14 | # with the distribution. 15 | # 16 | # - Neither the name of Groupon nor the names of its contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | # OF THE POSSIBILITY OF SUCH DAMAGE. 32 | SUBDIRS = src 33 | dist_doc_DATA = README.md 34 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_FCNTL_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_GETOPT_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_INTTYPES_H 11 | 12 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 13 | to 0 otherwise. */ 14 | #undef HAVE_MALLOC 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #undef HAVE_MEMORY_H 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #undef HAVE_SIGNAL_H 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #undef HAVE_STDINT_H 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #undef HAVE_STDIO_H 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #undef HAVE_STDLIB_H 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #undef HAVE_STRINGS_H 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #undef HAVE_STRING_H 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #undef HAVE_SYSLOG_H 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #undef HAVE_SYS_SELECT_H 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #undef HAVE_SYS_SOCKET_H 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #undef HAVE_SYS_STAT_H 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #undef HAVE_SYS_TYPES_H 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #undef HAVE_TIME_H 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #undef HAVE_UNISTD_H 57 | 58 | /* Name of package */ 59 | #undef PACKAGE 60 | 61 | /* Define to the address where bug reports for this package should be sent. */ 62 | #undef PACKAGE_BUGREPORT 63 | 64 | /* Define to the full name of this package. */ 65 | #undef PACKAGE_NAME 66 | 67 | /* Define to the full name and version of this package. */ 68 | #undef PACKAGE_STRING 69 | 70 | /* Define to the one symbol short name of this package. */ 71 | #undef PACKAGE_TARNAME 72 | 73 | /* Define to the home page for this package. */ 74 | #undef PACKAGE_URL 75 | 76 | /* Define to the version of this package. */ 77 | #undef PACKAGE_VERSION 78 | 79 | /* Define to 1 if you have the ANSI C header files. */ 80 | #undef STDC_HEADERS 81 | 82 | /* Version number of package */ 83 | #undef VERSION 84 | 85 | /* Define to empty if `const' does not conform to ANSI C. */ 86 | #undef const 87 | 88 | /* Define to rpl_malloc if the replacement function should be used. */ 89 | #undef malloc 90 | 91 | /* Define to `int' if does not define. */ 92 | #undef pid_t 93 | 94 | /* Define to `unsigned int' if does not define. */ 95 | #undef size_t 96 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl -*- Autoconf -*- 2 | dnl This file is part of mysql_slowlogd. 3 | dnl (C) 2012 Groupon, Inc. 4 | dnl 5 | dnl Process this file with autoconf to produce a configure script. 6 | dnl 7 | AC_PREREQ(2.57) 8 | AC_INIT([mysql_slowlogd], [1.0]) 9 | AM_INIT_AUTOMAKE([-Wall -Werror no-dependencies foreign]) 10 | AC_CONFIG_SRCDIR([src/mysql_slowlogd.c]) 11 | AC_CONFIG_HEADER([config.h]) 12 | 13 | dnl ==== Check for programs ==================================================== 14 | CFLAGS="${CFLAGS=}" 15 | CFLAGS="$CFLAGS -Wall -Werror -g" 16 | AC_PROG_CC 17 | 18 | dnl ==== Configure vendor libraries ============================================ 19 | if test -d "$srcdir/vendor/libmicrohttpd"; then 20 | AC_CONFIG_SUBDIRS([vendor/libmicrohttpd]) 21 | fi 22 | 23 | dnl ==== Check for headers ===================================================== 24 | AC_HEADER_STDC 25 | AC_CHECK_HEADERS([sys/types.h sys/select.h sys/socket.h sys/stat.h stdlib.h fcntl.h unistd.h stdio.h string.h time.h signal.h getopt.h syslog.h],,AC_MSG_ERROR([Compiling mysql_slowlogd requires standard UNIX headers files])) 26 | 27 | dnl ==== Check for typedefs, structures, and compiler characteristics ========== 28 | AC_C_CONST 29 | AC_TYPE_PID_T 30 | AC_TYPE_SIZE_T 31 | 32 | dnl ==== Check for library functions = ========================================= 33 | AC_FUNC_MALLOC 34 | 35 | dnl ==== Output =============================================================== 36 | dnl Output 37 | AC_CONFIG_FILES([ 38 | Makefile 39 | src/Makefile 40 | ]) 41 | AC_OUTPUT 42 | -------------------------------------------------------------------------------- /doc/playback_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupon/mysql_slowlogd/8611dbfea4b51b9e698298bcf2f1f87568223142/doc/playback_architecture.png -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012, Groupon, Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # 8 | # - Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 11 | # - Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following 13 | # disclaimer in the documentation and/or other materials provided 14 | # with the distribution. 15 | # 16 | # - Neither the name of Groupon nor the names of its contributors 17 | # may be used to endorse or promote products derived from this 18 | # software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | # OF THE POSSIBILITY OF SUCH DAMAGE. 32 | SUBDIRS = ../vendor/libmicrohttpd 33 | AM_CPPFLAGS = -I$(srcdir)/../vendor/libmicrohttpd/src/include -I$(srcdir)/../vendor/boyer-moore-horspool 34 | bin_PROGRAMS = mysql_slowlogd 35 | mysql_slowlogd_SOURCES = mysql_slowlogd.c 36 | mysql_slowlogd_LDADD = -L../vendor/libmicrohttpd/src/daemon/.libs -lmicrohttpd 37 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/AUTHORS: -------------------------------------------------------------------------------- 1 | Primary developers: 2 | Christian Grothoff (maintainer) 3 | Nils Durner (W32 port) 4 | Sagie Amir (TLS/SSL support using GNUtls) 5 | Richard Alimi (performance) 6 | Amr Ali (digest authentication) 7 | Matthieu Speder (basic authentication, client certificates) 8 | 9 | Code contributions also came from: 10 | Chris GauthierDickey 11 | Elliot Glaysher 12 | Daniel Pittman 13 | John Popplewell 14 | Heikki Lindholm 15 | Alex Sadovsky 16 | Greg Schohn 17 | Thomas Martin 18 | Peter Ross 19 | RuXu W 20 | Matthew Moore 21 | Colin Caughie 22 | David Carvalho 23 | David Reiss 24 | Mika Raento 25 | Mike Crowe 26 | John Muth 27 | Geoffrey McRae 28 | Piotr Grzybowski 29 | Gerrit Telkamp 30 | Erik Slagter 31 | Andreas Wehrmann 32 | Eivind Sarto 33 | Thomas Stalder 34 | Zhimin Huang 35 | Jan Seeger 36 | Will Bryant 37 | LRN 38 | Sven Geggus 39 | Steve Wolf 40 | Brecht Sanders 41 | 42 | Documentation contributions also came from: 43 | Marco Maggi 44 | Sebastian Gerhardt 45 | 46 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = contrib src doc m4 . 3 | EXTRA_DIST = acinclude.m4 libmicrohttpd.pc.in 4 | 5 | pkgconfigdir = $(libdir)/pkgconfig 6 | pkgconfig_DATA = libmicrohttpd.pc 7 | 8 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/NEWS: -------------------------------------------------------------------------------- 1 | Tue Jan 9 20:52:48 MST 2007 2 | Project posted. 3 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/README: -------------------------------------------------------------------------------- 1 | About 2 | ===== 3 | 4 | libmicrohttpd is a GNU library (part of the GNU project) written in C 5 | that provides a compact API and implementation of an HTTP 1.1 web 6 | server (HTTP 1.0 is also supported). libmicrohttpd only implements 7 | the HTTP 1.1 protocol. The main application must still provide the 8 | content. 9 | 10 | 11 | Installation 12 | ============ 13 | 14 | If you are using Subversion, run "autoreconf -fi" to create configure. 15 | 16 | In order to run the testcases, you need a recent version of libcurl. 17 | libcurl is not required if you just want to install the library. 18 | 19 | Especially for development, do use the MHD_USE_DEBUG option to get 20 | error messages. 21 | 22 | 23 | Configure options 24 | ================= 25 | 26 | 27 | If you are concerned about space, you should set "CFLAGS" to "-Os 28 | -fomit-frame-pointer" to have gcc generate tight code. 29 | 30 | You can use the following options to disable certain MHD features: 31 | 32 | --disable-https: no HTTPS / TLS / SSL support (significant reduction) 33 | --disable-messages: no error messages (they take space!) 34 | --disable-postprocessor: no MHD_PostProcessor API 35 | --disable-dauth: no digest authentication API 36 | 37 | The resulting binary should be about 30-40k depending on the platform. 38 | 39 | 40 | Portability 41 | =========== 42 | 43 | The latest version of libmicrohttpd will try to avoid SIGPIPE on its 44 | sockets. This should work on OS X, Linux and recent BSD systems (at 45 | least). On other systems that may trigger a SIGPIPE on send/recv, the 46 | main application should install a signal handler to handle SIGPIPE. 47 | 48 | libmicrohttpd should work well on GNU/Linux, BSD, OS X, W32 and z/OS. 49 | Note that HTTPS is not supported on z/OS (yet). We also have reports 50 | of users using it on vxWorks and Symbian. Note that on platforms 51 | where the compiler does not support the "constructor" attribute, you 52 | must call "MHD_init" before using any MHD functions and "MHD_fini" 53 | after you are done using MHD. 54 | 55 | 56 | Notes on compiling on z/OS: 57 | --------------------------- 58 | 59 | After extracting the archive, run 60 | 61 | iconv -f UTF-8 -t IBM-1047 contrib/ascebc > /tmp/ascebc.sh 62 | chmod +x /tmp/ascebc.sh 63 | for n in `find * -type f` 64 | do 65 | /tmp/ascebc.sh $n 66 | done 67 | 68 | to convert all source files to EBCDIC. Note that you must run 69 | "configure" from the directory where the configure script is 70 | located. Otherwise, configure will fail to find the 71 | "contrib/xcc" script (which is a wrapper around the z/OS c89 72 | compiler). 73 | 74 | 75 | Development Status 76 | ================== 77 | 78 | This is a beta release. Below we list things that should be 79 | implemented (in order of importance) before we can claim to be 80 | reasonably complete. 81 | 82 | 83 | Untested features: 84 | ================== 85 | - add testcases for http/1.1 pipelining (need 86 | to figure out how to ensure curl pipelines 87 | -- and it seems libcurl has issues with pipelining, 88 | see http://curl.haxx.se/mail/lib-2007-12/0248.html) 89 | - add testcases for resource limit enforcement 90 | - add testcases for client queuing early response, 91 | suppressing 100 CONTINUE 92 | - extend testcase for chunked encoding to validate 93 | handling of footers 94 | - more testing for SSL support 95 | - MHD basic and digest authentication 96 | 97 | 98 | Functions not covered by "make check": 99 | ====================================== 100 | - mhd_panic_std (daemon.c); special case (abort) 101 | - parse_options (daemon.c) 102 | - MHD_set_panic_func (daemon.c) 103 | - MHD_get_version (daemon.c) 104 | 105 | 106 | Missing documentation: 107 | ====================== 108 | 109 | - manual: 110 | * document configuration options 111 | * document details on porting MHD (plibc, z/OS) 112 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/acinclude.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([CHECK_PLIBC], 2 | [ 3 | # On windows machines, check if PlibC is available. First try without -plibc 4 | AC_TRY_LINK( 5 | [ 6 | #include 7 | ],[ 8 | plibc_init("", ""); 9 | ],[ 10 | AC_MSG_RESULT(yes) 11 | PLIBC_CPPFLAGS= 12 | PLIBC_LDFLAGS= 13 | PLIBC_LIBS= 14 | ],[ 15 | 16 | # now with -plibc 17 | AC_CHECK_LIB(plibc,plibc_init, 18 | [ 19 | PLIBC_CPPFLAGS= 20 | PLIBC_LDFLAGS= 21 | PLIBC_LIBS=-lplibc 22 | ],[ 23 | AC_MSG_CHECKING(if PlibC is installed) 24 | save_CPPFLAGS="$CPPFLAGS" 25 | CPPFLAGS="$CPPFLAGS -lplibc" 26 | AC_TRY_LINK( 27 | [ 28 | #include 29 | ],[ 30 | plibc_init("", ""); 31 | ],[ 32 | AC_MSG_RESULT(yes) 33 | PLIBC_CPPFLAGS=-lplibc 34 | PLIBC_LDFLAGS=-lplibc 35 | PLIBC_LIBS= 36 | ],[ 37 | AC_MSG_ERROR([PlibC is not available on your windows machine!]) 38 | ]) 39 | ]) 40 | ]) 41 | CPPFLAGS="$save_CPPFLAGS" 42 | ]) 43 | 44 | # See: http://gcc.gnu.org/ml/gcc/2000-05/msg01141.html 45 | AC_DEFUN([CHECK_PTHREAD], 46 | [ 47 | # first try without -pthread 48 | AC_TRY_LINK( 49 | [ 50 | #include 51 | ],[ 52 | pthread_create(0,0,0,0); 53 | ],[ 54 | AC_MSG_RESULT(yes) 55 | PTHREAD_CPPFLAGS= 56 | PTHREAD_LDFLAGS= 57 | PTHREAD_LIBS= 58 | ],[ 59 | 60 | # now with -pthread 61 | AC_CHECK_LIB(pthread,pthread_create, 62 | [ 63 | PTHREAD_CPPFLAGS= 64 | PTHREAD_LDFLAGS= 65 | PTHREAD_LIBS=-lpthread 66 | ],[ 67 | AC_MSG_CHECKING(if compiler supports -pthread) 68 | save_CPPFLAGS="$CPPFLAGS" 69 | CPPFLAGS="$CPPFLAGS -pthread" 70 | AC_TRY_LINK( 71 | [ 72 | #include 73 | ],[ 74 | pthread_create(0,0,0,0); 75 | ],[ 76 | AC_MSG_RESULT(yes) 77 | PTHREAD_CPPFLAGS=-pthread 78 | PTHREAD_LDFLAGS=-pthread 79 | PTHREAD_LIBS= 80 | ],[ 81 | AC_MSG_RESULT(no) 82 | AC_MSG_CHECKING(if compiler supports -pthreads) 83 | save_CPPFLAGS="$CPPFLAGS" 84 | CPPFLAGS="$save_CPPFLAGS -pthreads" 85 | AC_TRY_LINK( 86 | [ 87 | #include 88 | ],[ 89 | pthread_create(0,0,0,0); 90 | ],[ 91 | AC_MSG_RESULT(yes) 92 | PTHREAD_CPPFLAGS=-pthreads 93 | PTHREAD_LDFLAGS=-pthreads 94 | PTHREAD_LIBS= 95 | ],[ 96 | AC_MSG_RESULT(no) 97 | AC_MSG_CHECKING(if compiler supports -threads) 98 | save_CPPFLAGS="$CPPFLAGS" 99 | CPPFLAGS="$save_CPPFLAGS -threads" 100 | AC_TRY_LINK( 101 | [ 102 | #include 103 | ],[ 104 | pthread_create(0,0,0,0); 105 | ],[ 106 | AC_MSG_RESULT(yes) 107 | PTHREAD_CPPFLAGS=-threads 108 | PTHREAD_LDFLAGS=-threads 109 | PTHREAD_LIBS= 110 | ],[ 111 | AC_MSG_ERROR([Your system is not supporting pthreads!]) 112 | ]) 113 | ]) 114 | ]) 115 | CPPFLAGS="$save_CPPFLAGS" 116 | ]) 117 | ]) 118 | ]) 119 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = xcc ascebc mhd.png mhd.svg mhd_logo.png 2 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/ascebc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | iconv -f UTF-8 -t IBM-1047 $1 > temp.file 3 | if test -x $1 4 | then 5 | rm $1 6 | mv temp.file $1 7 | chmod +x $1 8 | else 9 | rm $1 10 | mv temp.file $1 11 | fi 12 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/mhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupon/mysql_slowlogd/8611dbfea4b51b9e698298bcf2f1f87568223142/vendor/libmicrohttpd/contrib/mhd.png -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/mhd.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 77 | 80 | MHD 92 | GNU 104 | 105 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/mhd_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupon/mysql_slowlogd/8611dbfea4b51b9e698298bcf2f1f87568223142/vendor/libmicrohttpd/contrib/mhd_logo.png -------------------------------------------------------------------------------- /vendor/libmicrohttpd/contrib/xcc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | c89 -Wc,'LANGLVL(EXTENDED),XPLINK' -Wl,'XPLINK' -D__STRING_CODE_SET__="ISO8859-1" -Wc,"ASCII" $@ 3 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS = libmicrohttpd.3 2 | EXTRA_DIST = $(man_MANS) Doxyfile 3 | 4 | DISTCLEANFILES = \ 5 | microhttpd.cps \ 6 | microhttpd.dvi \ 7 | microhttpd-tutorial.cps \ 8 | microhttpd-tutorial.dvi 9 | info_TEXINFOS = \ 10 | microhttpd.texi \ 11 | microhttpd-tutorial.texi 12 | microhttpd_TEXINFOS = \ 13 | chapters/basicauthentication.inc \ 14 | chapters/bibliography.inc \ 15 | chapters/exploringrequests.inc \ 16 | chapters/hellobrowser.inc \ 17 | chapters/introduction.inc \ 18 | chapters/largerpost.inc \ 19 | chapters/processingpost.inc \ 20 | chapters/responseheaders.inc \ 21 | chapters/tlsauthentication.inc \ 22 | chapters/sessions.inc \ 23 | examples/basicauthentication.c \ 24 | examples/hellobrowser.c \ 25 | examples/largepost.c \ 26 | examples/logging.c \ 27 | examples/responseheaders.c \ 28 | examples/simplepost.c \ 29 | examples/tlsauthentication.c \ 30 | examples/sessions.c \ 31 | fdl-1.3.texi \ 32 | lgpl.texi \ 33 | ecos.texi 34 | 35 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/chapters/bibliography.inc: -------------------------------------------------------------------------------- 1 | @heading API reference 2 | @itemize @bullet 3 | @item 4 | The @emph{GNU libmicrohttpd} manual by Marco Maggi and Christian Grothoff 2008 5 | @uref{http://gnunet.org/libmicrohttpd/microhttpd.html} 6 | 7 | @item 8 | All referenced RFCs can be found on the website of @emph{The Internet Engineering Task Force} 9 | @uref{http://www.ietf.org/} 10 | 11 | @item 12 | @emph{RFC 2616}: Fielding, R., Gettys, J., Mogul, J., Frystyk, H., and T. Berners-Lee, 13 | "Hypertext Transfer Protocol -- HTTP/1.1", RFC 2016, January 1997. 14 | 15 | @item 16 | @emph{RFC 2617}: Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., Leach, P., 17 | Luotonen, A., and L. Stewart, "HTTP Authentication: Basic and Digest Access Authentication", RFC 2617, June 1999. 18 | 19 | 20 | @item 21 | A well--structured @emph{HTML} reference can be found on 22 | @uref{http://www.echoecho.com/html.htm} 23 | 24 | For those readers understanding German or French, there is an excellent document both for learning 25 | @emph{HTML} and for reference, whose English version unfortunately has been discontinued. 26 | @uref{http://de.selfhtml.org/} and @uref{http://fr.selfhtml.org/} 27 | 28 | 29 | @end itemize 30 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/chapters/introduction.inc: -------------------------------------------------------------------------------- 1 | This tutorial is for developers who want to learn how they can add HTTP serving 2 | capabilities to their applications with the @emph{GNU libmicrohttpd} library, 3 | abbreviated @emph{MHD}. The reader will learn how to 4 | implement basic HTTP functions from simple executable 5 | sample programs that implement various features. 6 | 7 | The text is supposed to be a supplement to the API reference manual of 8 | @emph{GNU libmicrohttpd} and for that reason does not explain many of the parameters. 9 | Therefore, the reader should always consult the manual to find the exact meaning 10 | of the functions used in the tutorial. Furthermore, the reader is 11 | encouraged to study the relevant @emph{RFCs}, which document the HTTP standard. 12 | 13 | @emph{GNU libmicrohttpd} is assumed to be already installed. This tutorial 14 | is written for version @value{VERSION}. At the time being, 15 | this tutorial has only been tested on @emph{GNU/Linux} machines even though 16 | efforts were made not to rely on anything that would prevent the samples from being 17 | built on similar systems. 18 | 19 | @section History 20 | 21 | This tutorial was originally written by Sebastian Gerhardt for MHD 22 | 0.4.0. It was slighly polished and updated to MHD 0.9.0 by Christian 23 | Grothoff. -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/chapters/sessions.inc: -------------------------------------------------------------------------------- 1 | This chapter discusses how one should manage sessions, that is, share state between multiple 2 | HTTP requests from the same user. We use a simple example where the user submits multiple 3 | forms and the server is supposed to accumulate state from all of these forms. Naturally, as 4 | this is a network protocol, our session mechanism must support having many users with 5 | many concurrent sessions at the same time. 6 | 7 | In order to track users, we use a simple session cookie. A session cookie expires when the 8 | user closes the browser. Changing from session cookies to persistent cookies only requires 9 | adding an expiration time to the cookie. The server creates a fresh session cookie whenever 10 | a request without a cookie is received, or if the supplied session cookie is not known to 11 | the server. 12 | 13 | @heading Looking up the cookie 14 | 15 | Since MHD parses the HTTP cookie header for us, looking up an existing cookie 16 | is straightforward: 17 | 18 | @verbatim 19 | FIXME. 20 | @end verbatim 21 | 22 | Here, FIXME is the name we chose for our session cookie. 23 | 24 | 25 | @heading Setting the cookie header 26 | 27 | MHD requires the user to provide the full cookie format string in order to set 28 | cookies. In order to generate a unique cookie, our example creates a random 29 | 64-character text string to be used as the value of the cookie: 30 | 31 | @verbatim 32 | FIXME. 33 | @end verbatim 34 | 35 | Given this cookie value, we can then set the cookie header in our HTTP response 36 | as follows: 37 | 38 | @verbatim 39 | FIXME. 40 | @end verbatim 41 | 42 | 43 | @heading Remark: Session expiration 44 | 45 | It is of course possible that clients stop their interaction with the 46 | server at any time. In order to avoid using too much storage, the 47 | server must thus discard inactive sessions at some point. Our example 48 | implements this by discarding inactive sessions after a certain amount 49 | of time. Alternatively, the implementation may limit the total number 50 | of active sessions. Which bounds are used for idle sessions or the 51 | total number of sessions obviously depends largely on the type of 52 | the application and available server resources. 53 | 54 | @heading Example code 55 | 56 | A sample application implementing a website with multiple 57 | forms (which are dynamically created using values from previous 58 | POST requests from the same session) is available 59 | as the example @code{sessions.c}. 60 | 61 | Note that the example uses a simple, $O(n)$ linked list traversal to 62 | look up sessions and to expire old sessions. Using a hash table and a 63 | heap would be more appropriate if a large number of concurrent 64 | sessions is expected. 65 | 66 | @heading Remarks 67 | 68 | Naturally, it is quite conceivable to store session data in a database 69 | instead of in memory. Still, having mechanisms to expire data 70 | associated with long-time idle sessions (where the business process 71 | has still not finished) is likely a good idea. 72 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/examples/basicauthentication.c: -------------------------------------------------------------------------------- 1 | /* Feel free to use this example code in any way 2 | you see fit (Public Domain) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define PORT 8888 14 | 15 | 16 | static int 17 | answer_to_connection (void *cls, struct MHD_Connection *connection, 18 | const char *url, const char *method, 19 | const char *version, const char *upload_data, 20 | size_t *upload_data_size, void **con_cls) 21 | { 22 | char *user; 23 | char *pass; 24 | int fail; 25 | int ret; 26 | struct MHD_Response *response; 27 | 28 | if (0 != strcmp (method, "GET")) 29 | return MHD_NO; 30 | if (NULL == *con_cls) 31 | { 32 | *con_cls = connection; 33 | return MHD_YES; 34 | } 35 | pass = NULL; 36 | user = MHD_basic_auth_get_username_password (connection, &pass); 37 | fail = ( (user == NULL) || 38 | (0 != strcmp (user, "root")) || 39 | (0 != strcmp (pass, "pa$$w0rd") ) ); 40 | if (user != NULL) free (user); 41 | if (pass != NULL) free (pass); 42 | if (fail) 43 | { 44 | const char *page = "Go away."; 45 | response = 46 | MHD_create_response_from_buffer (strlen (page), (void *) page, 47 | MHD_RESPMEM_PERSISTENT); 48 | ret = MHD_queue_basic_auth_fail_response (connection, 49 | "my realm", 50 | response); 51 | } 52 | else 53 | { 54 | const char *page = "A secret."; 55 | response = 56 | MHD_create_response_from_buffer (strlen (page), (void *) page, 57 | MHD_RESPMEM_PERSISTENT); 58 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 59 | } 60 | MHD_destroy_response (response); 61 | return ret; 62 | } 63 | 64 | 65 | int 66 | main () 67 | { 68 | struct MHD_Daemon *daemon; 69 | 70 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 71 | &answer_to_connection, NULL, MHD_OPTION_END); 72 | if (NULL == daemon) 73 | return 1; 74 | 75 | getchar (); 76 | 77 | MHD_stop_daemon (daemon); 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/examples/hellobrowser.c: -------------------------------------------------------------------------------- 1 | /* Feel free to use this example code in any way 2 | you see fit (Public Domain) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define PORT 8888 12 | 13 | static int 14 | answer_to_connection (void *cls, struct MHD_Connection *connection, 15 | const char *url, const char *method, 16 | const char *version, const char *upload_data, 17 | size_t *upload_data_size, void **con_cls) 18 | { 19 | const char *page = "Hello, browser!"; 20 | struct MHD_Response *response; 21 | int ret; 22 | 23 | response = 24 | MHD_create_response_from_buffer (strlen (page), (void *) page, 25 | MHD_RESPMEM_PERSISTENT); 26 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 27 | MHD_destroy_response (response); 28 | 29 | return ret; 30 | } 31 | 32 | int 33 | main () 34 | { 35 | struct MHD_Daemon *daemon; 36 | 37 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 38 | &answer_to_connection, NULL, MHD_OPTION_END); 39 | if (NULL == daemon) 40 | return 1; 41 | 42 | getchar (); 43 | 44 | MHD_stop_daemon (daemon); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/examples/logging.c: -------------------------------------------------------------------------------- 1 | /* Feel free to use this example code in any way 2 | you see fit (Public Domain) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define PORT 8888 11 | 12 | 13 | static int 14 | print_out_key (void *cls, enum MHD_ValueKind kind, const char *key, 15 | const char *value) 16 | { 17 | printf ("%s: %s\n", key, value); 18 | return MHD_YES; 19 | } 20 | 21 | static int 22 | answer_to_connection (void *cls, struct MHD_Connection *connection, 23 | const char *url, const char *method, 24 | const char *version, const char *upload_data, 25 | size_t *upload_data_size, void **con_cls) 26 | { 27 | printf ("New %s request for %s using version %s\n", method, url, version); 28 | 29 | MHD_get_connection_values (connection, MHD_HEADER_KIND, print_out_key, 30 | NULL); 31 | 32 | return MHD_NO; 33 | } 34 | 35 | int 36 | main () 37 | { 38 | struct MHD_Daemon *daemon; 39 | 40 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 41 | &answer_to_connection, NULL, MHD_OPTION_END); 42 | if (NULL == daemon) 43 | return 1; 44 | 45 | getchar (); 46 | 47 | MHD_stop_daemon (daemon); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/examples/responseheaders.c: -------------------------------------------------------------------------------- 1 | /* Feel free to use this example code in any way 2 | you see fit (Public Domain) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define PORT 8888 15 | #define FILENAME "picture.png" 16 | #define MIMETYPE "image/png" 17 | 18 | static int 19 | answer_to_connection (void *cls, struct MHD_Connection *connection, 20 | const char *url, const char *method, 21 | const char *version, const char *upload_data, 22 | size_t *upload_data_size, void **con_cls) 23 | { 24 | struct MHD_Response *response; 25 | int fd; 26 | int ret; 27 | struct stat sbuf; 28 | 29 | if (0 != strcmp (method, "GET")) 30 | return MHD_NO; 31 | 32 | if ( (-1 == (fd = open (FILENAME, O_RDONLY))) || 33 | (0 != fstat (fd, &sbuf)) ) 34 | { 35 | /* error accessing file */ 36 | if (fd != -1) close (fd); 37 | const char *errorstr = 38 | "An internal server error has occured!\ 39 | "; 40 | response = 41 | MHD_create_response_from_buffer (strlen (errorstr), 42 | (void *) errorstr, 43 | MHD_RESPMEM_PERSISTENT); 44 | if (NULL != response) 45 | { 46 | ret = 47 | MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, 48 | response); 49 | MHD_destroy_response (response); 50 | 51 | return ret; 52 | } 53 | else 54 | return MHD_NO; 55 | } 56 | response = 57 | MHD_create_response_from_fd_at_offset (sbuf.st_size, fd, 0); 58 | MHD_add_response_header (response, "Content-Type", MIMETYPE); 59 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 60 | MHD_destroy_response (response); 61 | 62 | return ret; 63 | } 64 | 65 | 66 | int 67 | main () 68 | { 69 | struct MHD_Daemon *daemon; 70 | 71 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 72 | &answer_to_connection, NULL, MHD_OPTION_END); 73 | if (NULL == daemon) 74 | return 1; 75 | 76 | getchar (); 77 | 78 | MHD_stop_daemon (daemon); 79 | 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/examples/simplepost.c: -------------------------------------------------------------------------------- 1 | /* Feel free to use this example code in any way 2 | you see fit (Public Domain) */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PORT 8888 13 | #define POSTBUFFERSIZE 512 14 | #define MAXNAMESIZE 20 15 | #define MAXANSWERSIZE 512 16 | 17 | #define GET 0 18 | #define POST 1 19 | 20 | struct connection_info_struct 21 | { 22 | int connectiontype; 23 | char *answerstring; 24 | struct MHD_PostProcessor *postprocessor; 25 | }; 26 | 27 | const char *askpage = "\ 28 | What's your name, Sir?
\ 29 |
\ 30 |
\ 32 | "; 33 | 34 | const char *greetingpage = 35 | "

Welcome, %s!

"; 36 | 37 | const char *errorpage = 38 | "This doesn't seem to be right."; 39 | 40 | 41 | static int 42 | send_page (struct MHD_Connection *connection, const char *page) 43 | { 44 | int ret; 45 | struct MHD_Response *response; 46 | 47 | 48 | response = 49 | MHD_create_response_from_buffer (strlen (page), (void *) page, 50 | MHD_RESPMEM_PERSISTENT); 51 | if (!response) 52 | return MHD_NO; 53 | 54 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 55 | MHD_destroy_response (response); 56 | 57 | return ret; 58 | } 59 | 60 | 61 | static int 62 | iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, 63 | const char *filename, const char *content_type, 64 | const char *transfer_encoding, const char *data, uint64_t off, 65 | size_t size) 66 | { 67 | struct connection_info_struct *con_info = coninfo_cls; 68 | 69 | if (0 == strcmp (key, "name")) 70 | { 71 | if ((size > 0) && (size <= MAXNAMESIZE)) 72 | { 73 | char *answerstring; 74 | answerstring = malloc (MAXANSWERSIZE); 75 | if (!answerstring) 76 | return MHD_NO; 77 | 78 | snprintf (answerstring, MAXANSWERSIZE, greetingpage, data); 79 | con_info->answerstring = answerstring; 80 | } 81 | else 82 | con_info->answerstring = NULL; 83 | 84 | return MHD_NO; 85 | } 86 | 87 | return MHD_YES; 88 | } 89 | 90 | static void 91 | request_completed (void *cls, struct MHD_Connection *connection, 92 | void **con_cls, enum MHD_RequestTerminationCode toe) 93 | { 94 | struct connection_info_struct *con_info = *con_cls; 95 | 96 | if (NULL == con_info) 97 | return; 98 | 99 | if (con_info->connectiontype == POST) 100 | { 101 | MHD_destroy_post_processor (con_info->postprocessor); 102 | if (con_info->answerstring) 103 | free (con_info->answerstring); 104 | } 105 | 106 | free (con_info); 107 | *con_cls = NULL; 108 | } 109 | 110 | 111 | static int 112 | answer_to_connection (void *cls, struct MHD_Connection *connection, 113 | const char *url, const char *method, 114 | const char *version, const char *upload_data, 115 | size_t *upload_data_size, void **con_cls) 116 | { 117 | if (NULL == *con_cls) 118 | { 119 | struct connection_info_struct *con_info; 120 | 121 | con_info = malloc (sizeof (struct connection_info_struct)); 122 | if (NULL == con_info) 123 | return MHD_NO; 124 | con_info->answerstring = NULL; 125 | 126 | if (0 == strcmp (method, "POST")) 127 | { 128 | con_info->postprocessor = 129 | MHD_create_post_processor (connection, POSTBUFFERSIZE, 130 | iterate_post, (void *) con_info); 131 | 132 | if (NULL == con_info->postprocessor) 133 | { 134 | free (con_info); 135 | return MHD_NO; 136 | } 137 | 138 | con_info->connectiontype = POST; 139 | } 140 | else 141 | con_info->connectiontype = GET; 142 | 143 | *con_cls = (void *) con_info; 144 | 145 | return MHD_YES; 146 | } 147 | 148 | if (0 == strcmp (method, "GET")) 149 | { 150 | return send_page (connection, askpage); 151 | } 152 | 153 | if (0 == strcmp (method, "POST")) 154 | { 155 | struct connection_info_struct *con_info = *con_cls; 156 | 157 | if (*upload_data_size != 0) 158 | { 159 | MHD_post_process (con_info->postprocessor, upload_data, 160 | *upload_data_size); 161 | *upload_data_size = 0; 162 | 163 | return MHD_YES; 164 | } 165 | else if (NULL != con_info->answerstring) 166 | return send_page (connection, con_info->answerstring); 167 | } 168 | 169 | return send_page (connection, errorpage); 170 | } 171 | 172 | int 173 | main () 174 | { 175 | struct MHD_Daemon *daemon; 176 | 177 | daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, 178 | &answer_to_connection, NULL, 179 | MHD_OPTION_NOTIFY_COMPLETED, request_completed, 180 | NULL, MHD_OPTION_END); 181 | if (NULL == daemon) 182 | return 1; 183 | 184 | getchar (); 185 | 186 | MHD_stop_daemon (daemon); 187 | 188 | return 0; 189 | } 190 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/libmicrohttpd.3: -------------------------------------------------------------------------------- 1 | .TH LIBMICROHTTPD "3" "10 Jan 2011 "libmicrohttpd" 2 | .SH "NAME" 3 | GNU libmicrohttpd \- library for embedding HTTP servers 4 | .SH "SYNOPSIS" 5 | 6 | \fB#include 7 | 8 | .SH "DESCRIPTION" 9 | .P 10 | GNU libmicrohttpd (short MHD) allows applications to easily integrate the functionality of a simple HTTP server. MHD is a GNU package. 11 | .P 12 | The details of the API are described in comments in the header file, a detailed reference documentation and in brief on the MHD webpage. 13 | .P 14 | .SH "SEE ALSO" 15 | \fBcurl\fP(1), \fBlibcurl\fP(3) 16 | 17 | .SH "LEGAL NOTICE" 18 | libmicrohttpd is released under both the LGPL Version 2.1 or higher and the GNU GPL with eCos extension. For details on both licenses please read the respective appendix in the manual. 19 | 20 | .SH "FILES" 21 | .TP 22 | microhttpd.h 23 | libmicrohttpd include file 24 | .TP 25 | libmicrohttpd.so 26 | libmicrohttpd library 27 | 28 | .SH "REPORTING BUGS" 29 | Report bugs by using mantis . 30 | 31 | .SH "AUTHORS" 32 | GNU libmicrohttpd was originally designed by Christian Grothoff and Chris GauthierDickey . The original implementation was done by Daniel Pittman and Christian Grothoff. SSL/TLS support was added by Sagie Amir using code from GnuTLS. See the AUTHORS file in the distribution for a more detailed list of contributors. 33 | 34 | .SH "AVAILABILITY" 35 | You can obtain the latest version from http://www.gnu.org/software/libmicrohttpd/. 36 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/microhttpd-tutorial.texi: -------------------------------------------------------------------------------- 1 | \input texinfo @c -*-texinfo-*- 2 | @finalout 3 | @setfilename microhttpd-tutorial.info 4 | @set UPDATED 2 Nov 2011 5 | @set UPDATED-MONTH Nov 2011 6 | @set EDITION 0.9.16 7 | @set VERSION 0.9.16 8 | @settitle A tutorial for GNU libmicrohttpd 9 | 10 | @dircategory GNU Libraries 11 | @direntry 12 | * libmicrohttpdtutorial: (microhttpd). A tutorial for GNU libmicrohttpd. 13 | @end direntry 14 | 15 | @copying 16 | This tutorial documents GNU libmicrohttpd version @value{VERSION}, last 17 | updated @value{UPDATED}. 18 | 19 | Copyright (c) 2008 Sebastian Gerhardt. 20 | 21 | Copyright (c) 2010, 2011 Christian Grothoff. 22 | @quotation 23 | Permission is granted to copy, distribute and/or modify this document 24 | under the terms of the GNU Free Documentation License, Version 1.3 25 | or any later version published by the Free Software Foundation; 26 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 27 | Texts. A copy of the license is included in the section entitled "GNU 28 | Free Documentation License". 29 | @end quotation 30 | @end copying 31 | 32 | @titlepage 33 | @title A Tutorial for GNU libmicrohttpd 34 | @subtitle Version @value{VERSION} 35 | @subtitle @value{UPDATED} 36 | @author Sebastian Gerhardt (@email{sebgerhardt@@gmx.net}) 37 | @author Christian Grothoff (@email{christian@@grothoff.org}) 38 | @author Matthieu Speder (@email{mspeder@@users.sourceforge.net}) 39 | 40 | @page 41 | @vskip 0pt plus 1filll 42 | @insertcopying 43 | @end titlepage 44 | 45 | 46 | 47 | @contents 48 | 49 | @ifnottex 50 | @node Top 51 | @top Top 52 | @end ifnottex 53 | 54 | @menu 55 | * Introduction:: 56 | * Hello browser example:: 57 | * Exploring requests:: 58 | * Response headers:: 59 | * Supporting basic authentication:: 60 | * Processing POST data:: 61 | * Improved processing of POST data:: 62 | * Session management:: 63 | * Adding a layer of security:: 64 | * Bibliography:: 65 | * License text:: 66 | * Example programs:: 67 | @end menu 68 | 69 | @node Introduction 70 | @chapter Introduction 71 | @include chapters/introduction.inc 72 | 73 | @node Hello browser example 74 | @chapter Hello browser example 75 | @include chapters/hellobrowser.inc 76 | 77 | @node Exploring requests 78 | @chapter Exploring requests 79 | @include chapters/exploringrequests.inc 80 | 81 | @node Response headers 82 | @chapter Response headers 83 | @include chapters/responseheaders.inc 84 | 85 | @node Supporting basic authentication 86 | @chapter Supporting basic authentication 87 | @include chapters/basicauthentication.inc 88 | 89 | @node Processing POST data 90 | @chapter Processing POST data 91 | @include chapters/processingpost.inc 92 | 93 | @node Improved processing of POST data 94 | @chapter Improved processing of POST data 95 | @include chapters/largerpost.inc 96 | 97 | @node Session management 98 | @chapter Session management 99 | @include chapters/sessions.inc 100 | 101 | @node Adding a layer of security 102 | @chapter Adding a layer of security 103 | @include chapters/tlsauthentication.inc 104 | 105 | @node Bibliography 106 | @appendix Bibliography 107 | @include chapters/bibliography.inc 108 | 109 | @node License text 110 | @appendix GNU Free Documentation License 111 | @include fdl-1.3.texi 112 | 113 | @node Example programs 114 | @appendix Example programs 115 | @menu 116 | * hellobrowser.c:: 117 | * logging.c:: 118 | * responseheaders.c:: 119 | * basicauthentication.c:: 120 | * simplepost.c:: 121 | * largepost.c:: 122 | * sessions.c:: 123 | * tlsauthentication.c:: 124 | @end menu 125 | 126 | @node hellobrowser.c 127 | @section hellobrowser.c 128 | @smalldisplay 129 | @verbatiminclude examples/hellobrowser.c 130 | @end smalldisplay 131 | 132 | @node logging.c 133 | @section logging.c 134 | @smalldisplay 135 | @verbatiminclude examples/logging.c 136 | @end smalldisplay 137 | 138 | @node responseheaders.c 139 | @section responseheaders.c 140 | @smalldisplay 141 | @verbatiminclude examples/responseheaders.c 142 | @end smalldisplay 143 | 144 | @node basicauthentication.c 145 | @section basicauthentication.c 146 | @smalldisplay 147 | @verbatiminclude examples/basicauthentication.c 148 | @end smalldisplay 149 | 150 | @node simplepost.c 151 | @section simplepost.c 152 | @smalldisplay 153 | @verbatiminclude examples/simplepost.c 154 | @end smalldisplay 155 | 156 | @node largepost.c 157 | @section largepost.c 158 | @smalldisplay 159 | @verbatiminclude examples/largepost.c 160 | @end smalldisplay 161 | 162 | @node sessions.c 163 | @section sessions.c 164 | @smalldisplay 165 | @verbatiminclude examples/sessions.c 166 | @end smalldisplay 167 | 168 | @node tlsauthentication.c 169 | @section tlsauthentication.c 170 | @smalldisplay 171 | @verbatiminclude examples/tlsauthentication.c 172 | @end smalldisplay 173 | 174 | @bye 175 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/doc/version.texi: -------------------------------------------------------------------------------- 1 | @set UPDATED 17 July 2012 2 | @set UPDATED-MONTH July 2012 3 | @set EDITION 0.9.22 4 | @set VERSION 0.9.22 5 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/libmicrohttpd.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libmicrohttpd 7 | Description: A library for creating an embedded HTTP server 8 | Version: @VERSION@ 9 | Requires: 10 | Conflicts: 11 | Libs: -L${libdir} -lmicrohttpd 12 | Libs.private: @MHD_LIBDEPS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/m4/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = libcurl.m4 2 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/m4/libgcrypt.m4: -------------------------------------------------------------------------------- 1 | dnl Autoconf macros for libgcrypt 2 | dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc. 3 | dnl 4 | dnl This file is free software; as a special exception the author gives 5 | dnl unlimited permission to copy and/or distribute it, with or without 6 | dnl modifications, as long as this notice is preserved. 7 | dnl 8 | dnl This file is distributed in the hope that it will be useful, but 9 | dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 10 | dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | 13 | dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, 14 | dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) 15 | dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. 16 | dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed 17 | dnl with the API version to also check the API compatibility. Example: 18 | dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed 19 | dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using 20 | dnl this features allows to prevent build against newer versions of libgcrypt 21 | dnl with a changed API. 22 | dnl 23 | AC_DEFUN([AM_PATH_LIBGCRYPT], 24 | [ AC_ARG_WITH(libgcrypt-prefix, 25 | AC_HELP_STRING([--with-libgcrypt-prefix=PFX], 26 | [prefix where LIBGCRYPT is installed (optional)]), 27 | libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") 28 | if test x$libgcrypt_config_prefix != x ; then 29 | if test x${LIBGCRYPT_CONFIG+set} != xset ; then 30 | LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config 31 | fi 32 | fi 33 | 34 | AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no) 35 | tmp=ifelse([$1], ,1:1.2.0,$1) 36 | if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then 37 | req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` 38 | min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` 39 | else 40 | req_libgcrypt_api=0 41 | min_libgcrypt_version="$tmp" 42 | fi 43 | 44 | AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) 45 | ok=no 46 | if test "$LIBGCRYPT_CONFIG" != "no" ; then 47 | req_major=`echo $min_libgcrypt_version | \ 48 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` 49 | req_minor=`echo $min_libgcrypt_version | \ 50 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` 51 | req_micro=`echo $min_libgcrypt_version | \ 52 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` 53 | libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` 54 | major=`echo $libgcrypt_config_version | \ 55 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` 56 | minor=`echo $libgcrypt_config_version | \ 57 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` 58 | micro=`echo $libgcrypt_config_version | \ 59 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` 60 | if test "$major" -gt "$req_major"; then 61 | ok=yes 62 | else 63 | if test "$major" -eq "$req_major"; then 64 | if test "$minor" -gt "$req_minor"; then 65 | ok=yes 66 | else 67 | if test "$minor" -eq "$req_minor"; then 68 | if test "$micro" -ge "$req_micro"; then 69 | ok=yes 70 | fi 71 | fi 72 | fi 73 | fi 74 | fi 75 | fi 76 | if test $ok = yes; then 77 | AC_MSG_RESULT([yes ($libgcrypt_config_version)]) 78 | else 79 | AC_MSG_RESULT(no) 80 | fi 81 | if test $ok = yes; then 82 | # If we have a recent libgcrypt, we should also check that the 83 | # API is compatible 84 | if test "$req_libgcrypt_api" -gt 0 ; then 85 | tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` 86 | if test "$tmp" -gt 0 ; then 87 | AC_MSG_CHECKING([LIBGCRYPT API version]) 88 | if test "$req_libgcrypt_api" -eq "$tmp" ; then 89 | AC_MSG_RESULT([okay]) 90 | else 91 | ok=no 92 | AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) 93 | fi 94 | fi 95 | fi 96 | fi 97 | if test $ok = yes; then 98 | LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` 99 | LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` 100 | ifelse([$2], , :, [$2]) 101 | else 102 | LIBGCRYPT_CFLAGS="" 103 | LIBGCRYPT_LIBS="" 104 | ifelse([$3], , :, [$3]) 105 | fi 106 | AC_SUBST(LIBGCRYPT_CFLAGS) 107 | AC_SUBST(LIBGCRYPT_LIBS) 108 | ]) 109 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/Makefile.am: -------------------------------------------------------------------------------- 1 | if HAVE_CURL 2 | curltests = testcurl 3 | if HAVE_ZZUF 4 | if HAVE_SOCAT 5 | zzuftests = testzzuf 6 | endif 7 | endif 8 | endif 9 | SUBDIRS = include daemon examples $(curltests) $(zzuftests) . 10 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/EXPORT.sym: -------------------------------------------------------------------------------- 1 | MHD_start_daemon 2 | MHD_start_daemon_va 3 | MHD_stop_daemon 4 | MHD_get_fdset 5 | MHD_get_timeout 6 | MHD_run 7 | MHD_get_connection_values 8 | MHD_set_connection_value 9 | MHD_lookup_connection_value 10 | MHD_queue_response 11 | MHD_create_response_from_callback 12 | MHD_create_response_from_data 13 | MHD_create_response_from_fd 14 | MHD_create_response_from_fd_at_offset 15 | MHD_create_response_from_buffer 16 | MHD_destroy_response 17 | MHD_add_response_header 18 | MHD_add_response_footer 19 | MHD_del_response_header 20 | MHD_get_response_headers 21 | MHD_get_response_header 22 | MHD_create_post_processor 23 | MHD_post_process 24 | MHD_destroy_post_processor 25 | MHD_get_daemon_info 26 | MHD_get_connection_info 27 | MHD_set_panic_func 28 | MHD_get_version 29 | MHD_digest_auth_get_username 30 | MHD_digest_auth_check 31 | MHD_queue_auth_fail_response 32 | MHD_basic_auth_get_username_password 33 | MHD_queue_basic_auth_fail_response 34 | MHD_add_connection 35 | MHD_set_connection_option 36 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/Makefile.am: -------------------------------------------------------------------------------- 1 | if USE_PRIVATE_PLIBC_H 2 | PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc 3 | endif 4 | 5 | AM_CPPFLAGS = \ 6 | $(PLIBC_INCLUDE) \ 7 | -I$(top_srcdir)/src/include \ 8 | -I$(top_srcdir)/src/daemon \ 9 | @LIBGCRYPT_CFLAGS@ 10 | 11 | EXTRA_DIST = EXPORT.sym 12 | 13 | lib_LTLIBRARIES = \ 14 | libmicrohttpd.la 15 | 16 | 17 | libmicrohttpd_la_SOURCES = \ 18 | connection.c connection.h \ 19 | reason_phrase.c reason_phrase.h \ 20 | daemon.c \ 21 | internal.c internal.h \ 22 | memorypool.c memorypool.h \ 23 | response.c response.h 24 | libmicrohttpd_la_LDFLAGS = \ 25 | $(MHD_LIB_LDFLAGS) \ 26 | -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ 27 | 28 | if USE_COVERAGE 29 | AM_CFLAGS = --coverage 30 | endif 31 | 32 | if HAVE_POSTPROCESSOR 33 | libmicrohttpd_la_SOURCES += \ 34 | postprocessor.c 35 | endif 36 | 37 | if ENABLE_DAUTH 38 | libmicrohttpd_la_SOURCES += \ 39 | digestauth.c \ 40 | md5.c md5.h 41 | endif 42 | 43 | if ENABLE_BAUTH 44 | libmicrohttpd_la_SOURCES += \ 45 | basicauth.c \ 46 | base64.c base64.h 47 | endif 48 | 49 | if ENABLE_HTTPS 50 | libmicrohttpd_la_SOURCES += \ 51 | connection_https.c connection_https.h 52 | libmicrohttpd_la_LIBADD = -lgnutls @LIBGCRYPT_LIBS@ 53 | endif 54 | 55 | 56 | 57 | check_PROGRAMS = \ 58 | daemon_test 59 | 60 | if HAVE_POSTPROCESSOR 61 | check_PROGRAMS += \ 62 | postprocessor_test \ 63 | postprocessor_large_test 64 | endif 65 | 66 | TESTS = $(check_PROGRAMS) 67 | 68 | daemon_test_SOURCES = \ 69 | daemon_test.c 70 | daemon_test_LDADD = \ 71 | $(top_builddir)/src/daemon/libmicrohttpd.la 72 | 73 | postprocessor_test_SOURCES = \ 74 | postprocessor_test.c 75 | postprocessor_test_LDADD = \ 76 | $(top_builddir)/src/daemon/libmicrohttpd.la 77 | 78 | postprocessor_large_test_SOURCES = \ 79 | postprocessor_large_test.c 80 | postprocessor_large_test_LDADD = \ 81 | $(top_builddir)/src/daemon/libmicrohttpd.la 82 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/base64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code implements the BASE64 algorithm. 3 | * This code is in the public domain; do with it what you wish. 4 | * 5 | * @file base64.c 6 | * @brief This code implements the BASE64 algorithm 7 | * @author Matthieu Speder 8 | */ 9 | #include "base64.h" 10 | 11 | static const char base64_chars[] = 12 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 13 | 14 | static const char base64_digits[] = 15 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 18 | 0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 19 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 20 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 21 | 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 27 | 28 | 29 | char * 30 | BASE64Decode(const char* src) 31 | { 32 | size_t in_len = strlen (src); 33 | char* dest; 34 | char* result; 35 | 36 | if (in_len % 4) 37 | { 38 | /* Wrong base64 string length */ 39 | return NULL; 40 | } 41 | result = dest = malloc(in_len / 4 * 3 + 1); 42 | if (result == NULL) 43 | return NULL; /* out of memory */ 44 | while (*src) { 45 | char a = base64_digits[(unsigned char)*(src++)]; 46 | char b = base64_digits[(unsigned char)*(src++)]; 47 | char c = base64_digits[(unsigned char)*(src++)]; 48 | char d = base64_digits[(unsigned char)*(src++)]; 49 | *(dest++) = (a << 2) | ((b & 0x30) >> 4); 50 | if (c == (char)-1) 51 | break; 52 | *(dest++) = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); 53 | if (d == (char)-1) 54 | break; 55 | *(dest++) = ((c & 0x03) << 6) | d; 56 | } 57 | *dest = 0; 58 | return result; 59 | } 60 | 61 | 62 | /* end of base64.c */ 63 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code implements the BASE64 algorithm. 3 | * This code is in the public domain; do with it what you wish. 4 | * 5 | * @file base64.c 6 | * @brief This code implements the BASE64 algorithm 7 | * @author Matthieu Speder 8 | */ 9 | #ifndef BASE64_H 10 | #define BASE64_H 11 | 12 | #include "platform.h" 13 | 14 | char * 15 | BASE64Decode(const char* src); 16 | 17 | #endif /* !BASE64_H */ 18 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/basicauth.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2010, 2011, 2012 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file basicauth.c 21 | * @brief Implements HTTP basic authentication methods 22 | * @author Amr Ali 23 | * @author Matthieu Speder 24 | */ 25 | #include "platform.h" 26 | #include 27 | #include "internal.h" 28 | #include "base64.h" 29 | 30 | /** 31 | * Beginning string for any valid Basic authentication header. 32 | */ 33 | #define _BASIC_BASE "Basic " 34 | 35 | 36 | /** 37 | * Get the username and password from the basic authorization header sent by the client 38 | * 39 | * @param connection The MHD connection structure 40 | * @param password a pointer for the password 41 | * @return NULL if no username could be found, a pointer 42 | * to the username if found 43 | */ 44 | char * 45 | MHD_basic_auth_get_username_password(struct MHD_Connection *connection, 46 | char** password) 47 | { 48 | const char *header; 49 | char *decode; 50 | const char *separator; 51 | char *user; 52 | 53 | if ( (NULL == (header = MHD_lookup_connection_value (connection, 54 | MHD_HEADER_KIND, 55 | MHD_HTTP_HEADER_AUTHORIZATION))) || 56 | (0 != strncmp (header, _BASIC_BASE, strlen(_BASIC_BASE))) ) 57 | return NULL; 58 | header += strlen (_BASIC_BASE); 59 | if (NULL == (decode = BASE64Decode (header))) 60 | { 61 | #if HAVE_MESSAGES 62 | MHD_DLOG (connection->daemon, 63 | "Error decoding basic authentication\n"); 64 | #endif 65 | return NULL; 66 | } 67 | /* Find user:password pattern */ 68 | if (NULL == (separator = strchr (decode, ':'))) 69 | { 70 | #if HAVE_MESSAGES 71 | MHD_DLOG(connection->daemon, 72 | "Basic authentication doesn't contain ':' separator\n"); 73 | #endif 74 | free (decode); 75 | return NULL; 76 | } 77 | if (NULL == (user = strdup (decode))) 78 | { 79 | free (decode); 80 | return NULL; 81 | } 82 | user[separator - decode] = '\0'; /* cut off at ':' */ 83 | if (NULL != password) 84 | { 85 | *password = strdup (separator + 1); 86 | if (NULL == *password) 87 | { 88 | #if HAVE_MESSAGES 89 | MHD_DLOG(connection->daemon, 90 | "Failed to allocate memory for password\n"); 91 | #endif 92 | free (decode); 93 | free (user); 94 | return NULL; 95 | } 96 | } 97 | free (decode); 98 | return user; 99 | } 100 | 101 | 102 | /** 103 | * Queues a response to request basic authentication from the client 104 | * 105 | * @param connection The MHD connection structure 106 | * @param realm the realm presented to the client 107 | * @return MHD_YES on success, MHD_NO otherwise 108 | */ 109 | int 110 | MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, 111 | const char *realm, 112 | struct MHD_Response *response) 113 | { 114 | int ret; 115 | size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1; 116 | char header[hlen]; 117 | 118 | snprintf (header, 119 | sizeof (header), 120 | "Basic realm=\"%s\"", 121 | realm); 122 | ret = MHD_add_response_header (response, 123 | MHD_HTTP_HEADER_WWW_AUTHENTICATE, 124 | header); 125 | if (MHD_YES == ret) 126 | ret = MHD_queue_response (connection, 127 | MHD_HTTP_UNAUTHORIZED, 128 | response); 129 | return ret; 130 | } 131 | 132 | /* end of basicauth.c */ 133 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/connection.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file connection.h 22 | * @brief Methods for managing connections 23 | * @author Daniel Pittman 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #ifndef CONNECTION_H 28 | #define CONNECTION_H 29 | 30 | #include "internal.h" 31 | 32 | 33 | /** 34 | * Obtain the select sets for this connection. The given 35 | * sets (and the maximum) are updated and must have 36 | * already been initialized. 37 | * 38 | * @param connection connetion to get select sets for 39 | * @param read_fd_set read set to initialize 40 | * @param write_fd_set write set to initialize 41 | * @param except_fd_set except set to initialize (never changed) 42 | * @param max_fd where to store largest FD put into any set 43 | * @return MHD_YES on success 44 | */ 45 | int 46 | MHD_connection_get_fdset (struct MHD_Connection *connection, 47 | fd_set * read_fd_set, 48 | fd_set * write_fd_set, 49 | fd_set * except_fd_set, int *max_fd); 50 | 51 | 52 | /** 53 | * Obtain the pollfd for this connection. The poll interface allows large 54 | * file descriptors. Select goes stupid when the fd overflows fdset (which 55 | * is fixed). 56 | * 57 | * @param connection connetion to get poll set for 58 | * @param p where to store the polling information 59 | */ 60 | int 61 | MHD_connection_get_pollfd (struct MHD_Connection *connection, 62 | struct MHD_Pollfd *p); 63 | 64 | 65 | /** 66 | * Set callbacks for this connection to those for HTTP. 67 | * 68 | * @param connection connection to initialize 69 | */ 70 | void 71 | MHD_set_http_callbacks_ (struct MHD_Connection *connection); 72 | 73 | 74 | /** 75 | * This function handles a particular connection when it has been 76 | * determined that there is data to be read off a socket. All 77 | * implementations (multithreaded, external select, internal select) 78 | * call this function to handle reads. 79 | * 80 | * @param connection connection to handle 81 | * @return always MHD_YES (we should continue to process the 82 | * connection) 83 | */ 84 | int 85 | MHD_connection_handle_read (struct MHD_Connection *connection); 86 | 87 | 88 | /** 89 | * This function was created to handle writes to sockets when it has 90 | * been determined that the socket can be written to. All 91 | * implementations (multithreaded, external select, internal select) 92 | * call this function 93 | * 94 | * @param connection connection to handle 95 | * @return always MHD_YES (we should continue to process the 96 | * connection) 97 | */ 98 | int 99 | MHD_connection_handle_write (struct MHD_Connection *connection); 100 | 101 | 102 | /** 103 | * This function was created to handle per-connection processing that 104 | * has to happen even if the socket cannot be read or written to. All 105 | * implementations (multithreaded, external select, internal select) 106 | * call this function. 107 | * 108 | * @param connection connection to handle 109 | * @return MHD_YES if we should continue to process the 110 | * connection (not dead yet), MHD_NO if it died 111 | */ 112 | int 113 | MHD_connection_handle_idle (struct MHD_Connection *connection); 114 | 115 | 116 | /** 117 | * Close the given connection and give the 118 | * specified termination code to the user. 119 | * 120 | * @param connection connection to close 121 | * @param termination_code termination reason to give 122 | */ 123 | void 124 | MHD_connection_close (struct MHD_Connection *connection, 125 | enum MHD_RequestTerminationCode termination_code); 126 | 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/connection_https.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2008 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file connection_https.h 22 | * @brief Methods for managing connections 23 | * @author Christian Grothoff 24 | */ 25 | 26 | #ifndef CONNECTION_HTTPS_H 27 | #define CONNECTION_HTTPS_H 28 | 29 | #include "internal.h" 30 | 31 | #if HTTPS_SUPPORT 32 | void MHD_set_https_callbacks (struct MHD_Connection *connection); 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/daemon_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file daemon_test.c 23 | * @brief Testcase for libmicrohttpd starts and stops 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #include "platform.h" 28 | #include "platform.h" 29 | #include "microhttpd.h" 30 | #include 31 | #include 32 | #include 33 | 34 | #ifndef WINDOWS 35 | #include 36 | #endif 37 | 38 | 39 | static int 40 | testStartError () 41 | { 42 | struct MHD_Daemon *d; 43 | 44 | d = MHD_start_daemon (MHD_USE_DEBUG, 0, NULL, NULL, NULL, NULL); 45 | if (d != NULL) 46 | return 1; 47 | return 0; 48 | } 49 | 50 | static int 51 | apc_nothing (void *cls, const struct sockaddr *addr, socklen_t addrlen) 52 | { 53 | return MHD_NO; 54 | } 55 | 56 | static int 57 | apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) 58 | { 59 | return MHD_YES; 60 | } 61 | 62 | static int 63 | ahc_nothing (void *cls, 64 | struct MHD_Connection *connection, 65 | const char *url, 66 | const char *method, 67 | const char *version, 68 | const char *upload_data, size_t *upload_data_size, 69 | void **unused) 70 | { 71 | return MHD_NO; 72 | } 73 | 74 | static int 75 | testStartStop () 76 | { 77 | struct MHD_Daemon *d; 78 | 79 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, 80 | 1080, 81 | &apc_nothing, 82 | NULL, &ahc_nothing, NULL, MHD_OPTION_END); 83 | if (d == NULL) 84 | return 2; 85 | MHD_stop_daemon (d); 86 | return 0; 87 | } 88 | 89 | static int 90 | testExternalRun () 91 | { 92 | struct MHD_Daemon *d; 93 | fd_set rs; 94 | int maxfd; 95 | int i; 96 | 97 | d = MHD_start_daemon (MHD_USE_DEBUG, 98 | 1081, 99 | &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END); 100 | 101 | if (d == NULL) 102 | return 4; 103 | i = 0; 104 | while (i < 15) 105 | { 106 | maxfd = 0; 107 | FD_ZERO (&rs); 108 | if (MHD_YES != MHD_get_fdset (d, &rs, &rs, &rs, &maxfd)) 109 | { 110 | MHD_stop_daemon (d); 111 | return 256; 112 | } 113 | if (MHD_run (d) == MHD_NO) 114 | { 115 | MHD_stop_daemon (d); 116 | return 8; 117 | } 118 | i++; 119 | } 120 | MHD_stop_daemon (d); 121 | return 0; 122 | } 123 | 124 | static int 125 | testThread () 126 | { 127 | struct MHD_Daemon *d; 128 | d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SELECT_INTERNALLY, 129 | 1082, 130 | &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END); 131 | 132 | if (d == NULL) 133 | return 16; 134 | if (MHD_run (d) != MHD_NO) 135 | return 32; 136 | MHD_stop_daemon (d); 137 | return 0; 138 | } 139 | 140 | static int 141 | testMultithread () 142 | { 143 | struct MHD_Daemon *d; 144 | d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_THREAD_PER_CONNECTION, 145 | 1083, 146 | &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END); 147 | 148 | if (d == NULL) 149 | return 64; 150 | if (MHD_run (d) != MHD_NO) 151 | return 128; 152 | MHD_stop_daemon (d); 153 | return 0; 154 | } 155 | 156 | int 157 | main (int argc, char *const *argv) 158 | { 159 | int errorCount = 0; 160 | errorCount += testStartError (); 161 | errorCount += testStartStop (); 162 | errorCount += testExternalRun (); 163 | errorCount += testThread (); 164 | errorCount += testMultithread (); 165 | if (errorCount != 0) 166 | fprintf (stderr, "Error (code: %u)\n", errorCount); 167 | return errorCount != 0; /* 0 == pass */ 168 | } 169 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/internal.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file internal.h 22 | * @brief internal shared structures 23 | * @author Daniel Pittman 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #include "internal.h" 28 | 29 | #if HAVE_MESSAGES 30 | #if DEBUG_STATES 31 | /** 32 | * State to string dictionary. 33 | */ 34 | const char * 35 | MHD_state_to_string (enum MHD_CONNECTION_STATE state) 36 | { 37 | switch (state) 38 | { 39 | case MHD_CONNECTION_INIT: 40 | return "connection init"; 41 | case MHD_CONNECTION_URL_RECEIVED: 42 | return "connection url received"; 43 | case MHD_CONNECTION_HEADER_PART_RECEIVED: 44 | return "header partially received"; 45 | case MHD_CONNECTION_HEADERS_RECEIVED: 46 | return "headers received"; 47 | case MHD_CONNECTION_HEADERS_PROCESSED: 48 | return "headers processed"; 49 | case MHD_CONNECTION_CONTINUE_SENDING: 50 | return "continue sending"; 51 | case MHD_CONNECTION_CONTINUE_SENT: 52 | return "continue sent"; 53 | case MHD_CONNECTION_BODY_RECEIVED: 54 | return "body received"; 55 | case MHD_CONNECTION_FOOTER_PART_RECEIVED: 56 | return "footer partially received"; 57 | case MHD_CONNECTION_FOOTERS_RECEIVED: 58 | return "footers received"; 59 | case MHD_CONNECTION_HEADERS_SENDING: 60 | return "headers sending"; 61 | case MHD_CONNECTION_HEADERS_SENT: 62 | return "headers sent"; 63 | case MHD_CONNECTION_NORMAL_BODY_READY: 64 | return "normal body ready"; 65 | case MHD_CONNECTION_NORMAL_BODY_UNREADY: 66 | return "normal body unready"; 67 | case MHD_CONNECTION_CHUNKED_BODY_READY: 68 | return "chunked body ready"; 69 | case MHD_CONNECTION_CHUNKED_BODY_UNREADY: 70 | return "chunked body unready"; 71 | case MHD_CONNECTION_BODY_SENT: 72 | return "body sent"; 73 | case MHD_CONNECTION_FOOTERS_SENDING: 74 | return "footers sending"; 75 | case MHD_CONNECTION_FOOTERS_SENT: 76 | return "footers sent"; 77 | case MHD_CONNECTION_CLOSED: 78 | return "closed"; 79 | case MHD_TLS_CONNECTION_INIT: 80 | return "secure connection init"; 81 | default: 82 | return "unrecognized connection state"; 83 | } 84 | } 85 | #endif 86 | #endif 87 | 88 | #if HAVE_MESSAGES 89 | /** 90 | * fprintf-like helper function for logging debug 91 | * messages. 92 | */ 93 | void 94 | MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) 95 | { 96 | va_list va; 97 | 98 | if ((daemon->options & MHD_USE_DEBUG) == 0) 99 | return; 100 | va_start (va, format); 101 | daemon->custom_error_log (daemon->custom_error_log_cls, format, va); 102 | va_end (va); 103 | } 104 | #endif 105 | 106 | 107 | /** 108 | * Process escape sequences ('+'=space, %HH) Updates val in place; the 109 | * result should be UTF-8 encoded and cannot be larger than the input. 110 | * The result must also still be 0-terminated. 111 | * 112 | * @param cls closure (use NULL) 113 | * @param connection handle to connection, not used 114 | * @return length of the resulting val (strlen(val) maybe 115 | * shorter afterwards due to elimination of escape sequences) 116 | */ 117 | size_t 118 | MHD_http_unescape (void *cls, 119 | struct MHD_Connection *connection, 120 | char *val) 121 | { 122 | char *rpos = val; 123 | char *wpos = val; 124 | char *end; 125 | unsigned int num; 126 | char buf3[3]; 127 | 128 | while ('\0' != *rpos) 129 | { 130 | switch (*rpos) 131 | { 132 | case '+': 133 | *wpos = ' '; 134 | wpos++; 135 | rpos++; 136 | break; 137 | case '%': 138 | buf3[0] = rpos[1]; 139 | buf3[1] = rpos[2]; 140 | buf3[2] = '\0'; 141 | num = strtoul (buf3, &end, 16); 142 | if ('\0' == *end) 143 | { 144 | *wpos = (unsigned char) num; 145 | wpos++; 146 | rpos += 3; 147 | break; 148 | } 149 | /* intentional fall through! */ 150 | default: 151 | *wpos = *rpos; 152 | wpos++; 153 | rpos++; 154 | } 155 | } 156 | *wpos = '\0'; /* add 0-terminator */ 157 | return wpos - val; /* = strlen(val) */ 158 | } 159 | 160 | time_t MHD_monotonic_time(void) 161 | { 162 | #ifdef HAVE_CLOCK_GETTIME 163 | struct timespec ts; 164 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 165 | return ts.tv_sec; 166 | #endif 167 | return time(NULL); 168 | } 169 | 170 | /* end of internal.c */ 171 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code implements the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | * 12 | * To compute the message digest of a chunk of bytes, declare an 13 | * MD5Context structure, pass it to MD5Init, call MD5Update as 14 | * needed on buffers full of bytes, and then call MD5Final, which 15 | * will fill a supplied 16-byte array with the digest. 16 | */ 17 | 18 | /* Brutally hacked by John Walker back from ANSI C to K&R (no 19 | prototypes) to maintain the tradition that Netfone will compile 20 | with Sun's original "cc". */ 21 | 22 | #ifndef MD5_H 23 | #define MD5_H 24 | 25 | #include "platform.h" 26 | #ifdef WORDS_BIGENDIAN 27 | #define HIGHFIRST 28 | #endif 29 | 30 | #define MD5_DIGEST_SIZE 16 31 | 32 | struct MD5Context 33 | { 34 | uint32_t buf[4]; 35 | uint32_t bits[2]; 36 | unsigned char in[64]; 37 | }; 38 | 39 | 40 | void 41 | MD5Init(struct MD5Context *ctx); 42 | 43 | void 44 | MD5Update(struct MD5Context *ctx, 45 | const void *buf, 46 | unsigned len); 47 | 48 | void MD5Final(unsigned char digest[MD5_DIGEST_SIZE], 49 | struct MD5Context *ctx); 50 | 51 | #endif /* !MD5_H */ 52 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/memorypool.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2009 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file memorypool.h 22 | * @brief memory pool; mostly used for efficient (de)allocation 23 | * for each connection and bounding memory use for each 24 | * request 25 | * @author Christian Grothoff 26 | */ 27 | 28 | #ifndef MEMORYPOOL_H 29 | #define MEMORYPOOL_H 30 | 31 | #include "internal.h" 32 | 33 | /** 34 | * Opaque handle for a memory pool. 35 | * Pools are not reentrant and must not be used 36 | * by multiple threads. 37 | */ 38 | struct MemoryPool; 39 | 40 | /** 41 | * Create a memory pool. 42 | * 43 | * @param max maximum size of the pool 44 | */ 45 | struct MemoryPool *MHD_pool_create (size_t max); 46 | 47 | /** 48 | * Destroy a memory pool. 49 | */ 50 | void MHD_pool_destroy (struct MemoryPool *pool); 51 | 52 | /** 53 | * Allocate size bytes from the pool. 54 | * 55 | * @param from_end allocate from end of pool (set to MHD_YES); 56 | * use this for small, persistent allocations that 57 | * will never be reallocated 58 | * @return NULL if the pool cannot support size more 59 | * bytes 60 | */ 61 | void *MHD_pool_allocate (struct MemoryPool *pool, 62 | size_t size, int from_end); 63 | 64 | /** 65 | * Reallocate a block of memory obtained from the pool. 66 | * This is particularly efficient when growing or 67 | * shrinking the block that was last (re)allocated. 68 | * If the given block is not the most recenlty 69 | * (re)allocated block, the memory of the previous 70 | * allocation may be leaked until the pool is 71 | * destroyed (and copying the data maybe required). 72 | * 73 | * @param old the existing block 74 | * @param old_size the size of the existing block 75 | * @param new_size the new size of the block 76 | * @return new address of the block, or 77 | * NULL if the pool cannot support new_size 78 | * bytes (old continues to be valid for old_size) 79 | */ 80 | void *MHD_pool_reallocate (struct MemoryPool *pool, 81 | void *old, 82 | size_t old_size, 83 | size_t new_size); 84 | 85 | /** 86 | * Clear all entries from the memory pool except 87 | * for "keep" of the given "size". 88 | * 89 | * @param keep pointer to the entry to keep (maybe NULL) 90 | * @param size how many bytes need to be kept at this address 91 | * @return addr new address of "keep" (if it had to change) 92 | */ 93 | void *MHD_pool_reset (struct MemoryPool *pool, 94 | void *keep, 95 | size_t size); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/postprocessor_large_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2008 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file postprocessor_large_test.c 23 | * @brief Testcase with very large input for postprocessor 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | #include "internal.h" 30 | 31 | #ifndef WINDOWS 32 | #include 33 | #endif 34 | 35 | static int 36 | value_checker (void *cls, 37 | enum MHD_ValueKind kind, 38 | const char *key, 39 | const char *filename, 40 | const char *content_type, 41 | const char *transfer_encoding, 42 | const char *data, uint64_t off, size_t size) 43 | { 44 | unsigned int *pos = cls; 45 | #if 0 46 | fprintf (stderr, 47 | "VC: %llu %u `%s' `%s' `%s' `%s' `%.*s'\n", 48 | off, size, 49 | key, filename, content_type, transfer_encoding, size, data); 50 | #endif 51 | if (size == 0) 52 | return MHD_YES; 53 | *pos += size; 54 | return MHD_YES; 55 | 56 | } 57 | 58 | 59 | static int 60 | test_simple_large () 61 | { 62 | struct MHD_Connection connection; 63 | struct MHD_HTTP_Header header; 64 | struct MHD_PostProcessor *pp; 65 | int i; 66 | int delta; 67 | size_t size; 68 | char data[102400]; 69 | unsigned int pos; 70 | 71 | pos = 0; 72 | memset (data, 'A', sizeof (data)); 73 | memcpy (data, "key=", 4); 74 | data[sizeof (data) - 1] = '\0'; 75 | memset (&connection, 0, sizeof (struct MHD_Connection)); 76 | memset (&header, 0, sizeof (struct MHD_HTTP_Header)); 77 | connection.headers_received = &header; 78 | header.header = MHD_HTTP_HEADER_CONTENT_TYPE; 79 | header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; 80 | header.kind = MHD_HEADER_KIND; 81 | pp = MHD_create_post_processor (&connection, 1024, &value_checker, &pos); 82 | i = 0; 83 | size = strlen (data); 84 | while (i < size) 85 | { 86 | delta = 1 + RANDOM () % (size - i); 87 | MHD_post_process (pp, &data[i], delta); 88 | i += delta; 89 | } 90 | MHD_destroy_post_processor (pp); 91 | if (pos != sizeof (data) - 5) /* minus 0-termination and 'key=' */ 92 | return 1; 93 | return 0; 94 | } 95 | 96 | int 97 | main (int argc, char *const *argv) 98 | { 99 | unsigned int errorCount = 0; 100 | 101 | errorCount += test_simple_large (); 102 | if (errorCount != 0) 103 | fprintf (stderr, "Error (code: %u)\n", errorCount); 104 | return errorCount != 0; /* 0 == pass */ 105 | } 106 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/reason_phrase.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2011 Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | */ 20 | 21 | /** 22 | * @file reason_phrase.c 23 | * @brief Tables of the string response phrases 24 | * @author Elliot Glaysher 25 | * @author Christian Grothoff (minor code clean up) 26 | */ 27 | 28 | #include "reason_phrase.h" 29 | 30 | #ifndef NULL 31 | #define NULL (void*)0 32 | #endif 33 | 34 | static const char *invalid_hundred[] = { NULL }; 35 | 36 | static const char *one_hundred[] = { 37 | "Continue", 38 | "Switching Protocols", 39 | "Processing" 40 | }; 41 | 42 | static const char *two_hundred[] = { 43 | "OK", 44 | "Created", 45 | "Accepted", 46 | "Non-Authoritative Information", 47 | "No Content", 48 | "Reset Content", 49 | "Partial Content", 50 | "Multi Status" 51 | }; 52 | 53 | static const char *three_hundred[] = { 54 | "Multiple Choices", 55 | "Moved Permanently", 56 | "Moved Temporarily", 57 | "See Other", 58 | "Not Modified", 59 | "Use Proxy", 60 | "Switch Proxy", 61 | "Temporary Redirect" 62 | }; 63 | 64 | static const char *four_hundred[] = { 65 | "Bad Request", 66 | "Unauthorized", 67 | "Payment Required", 68 | "Forbidden", 69 | "Not Found", 70 | "Method Not Allowed", 71 | "Not Acceptable", 72 | "Proxy Authentication Required", 73 | "Request Time-out", 74 | "Conflict", 75 | "Gone", 76 | "Length Required", 77 | "Precondition Failed", 78 | "Request Entity Too Large", 79 | "Request-URI Too Large", 80 | "Unsupported Media Type", 81 | "Requested Range Not Satisfiable", 82 | "Expectation Failed", 83 | "Unknown", 84 | "Unknown", 85 | "Unknown", /* 420 */ 86 | "Unknown", 87 | "Unprocessable Entity", 88 | "Locked", 89 | "Failed Dependency", 90 | "Unordered Collection", 91 | "Upgrade Required", 92 | "Unknown", 93 | "Unknown", 94 | "Unknown", 95 | "Unknown", /* 430 */ 96 | "Unknown", 97 | "Unknown", 98 | "Unknown", 99 | "Unknown", 100 | "Unknown", /* 435 */ 101 | "Unknown", 102 | "Unknown", 103 | "Unknown", 104 | "Unknown", 105 | "Unknown", /* 440 */ 106 | "Unknown", 107 | "Unknown", 108 | "Unknown", 109 | "No Response", 110 | "Unknown", /* 445 */ 111 | "Unknown", 112 | "Unknown", 113 | "Unknown", 114 | "Retry With", 115 | "Blocked by Windows Parental Controls", /* 450 */ 116 | "Unavailable For Legal Reasons" 117 | }; 118 | 119 | static const char *five_hundred[] = { 120 | "Internal Server Error", 121 | "Not Implemented", 122 | "Bad Gateway", 123 | "Service Unavailable", 124 | "Gateway Time-out", 125 | "HTTP Version not supported", 126 | "Variant Also Negotiates", 127 | "Insufficient Storage", 128 | "Unknown", 129 | "Bandwidth Limit Exceeded", 130 | "Not Extended" 131 | }; 132 | 133 | 134 | struct MHD_Reason_Block 135 | { 136 | unsigned int max; 137 | const char **data; 138 | }; 139 | 140 | #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m } 141 | 142 | static const struct MHD_Reason_Block reasons[] = { 143 | BLOCK (invalid_hundred), 144 | BLOCK (one_hundred), 145 | BLOCK (two_hundred), 146 | BLOCK (three_hundred), 147 | BLOCK (four_hundred), 148 | BLOCK (five_hundred), 149 | }; 150 | 151 | const char * 152 | MHD_get_reason_phrase_for (unsigned int code) 153 | { 154 | if ( (code >= 100) && 155 | (code < 600) && 156 | (reasons[code / 100].max > (code % 100)) ) 157 | return reasons[code / 100].data[code % 100]; 158 | return "Unknown"; 159 | } 160 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/reason_phrase.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Lymba 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file reason_phrase.c 22 | * @brief Tables of the string response phrases 23 | * @author Elliot Glaysher 24 | */ 25 | 26 | #ifndef REASON_PHRASE_H 27 | #define REASON_PHRASE_H 28 | 29 | /** 30 | * Returns the string reason phrase for a response code. 31 | * 32 | * If we don't have a string for a status code, we give the first 33 | * message in that status code class. 34 | */ 35 | const char *MHD_get_reason_phrase_for (unsigned int code); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/daemon/response.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Daniel Pittman and Christian Grothoff 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file response.h 22 | * @brief Methods for managing response objects 23 | * @author Daniel Pittman 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #ifndef RESPONSE_H 28 | #define RESPONSE_H 29 | 30 | /** 31 | * Increment response RC. Should this be part of the 32 | * public API? 33 | */ 34 | void MHD_increment_response_rc (struct MHD_Response *response); 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = . 2 | 3 | if USE_PRIVATE_PLIBC_H 4 | PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc 5 | endif 6 | 7 | AM_CPPFLAGS = \ 8 | $(PLIBC_INCLUDE) \ 9 | -I$(top_srcdir)/src/include \ 10 | @LIBGCRYPT_CFLAGS@ 11 | 12 | if USE_COVERAGE 13 | AM_CFLAGS = --coverage 14 | endif 15 | 16 | # example programs 17 | noinst_PROGRAMS = \ 18 | minimal_example \ 19 | dual_stack_example \ 20 | minimal_example_comet \ 21 | querystring_example \ 22 | fileserver_example \ 23 | fileserver_example_dirs \ 24 | fileserver_example_external_select \ 25 | refuse_post_example 26 | 27 | if ENABLE_HTTPS 28 | noinst_PROGRAMS += https_fileserver_example 29 | endif 30 | if HAVE_POSTPROCESSOR 31 | noinst_PROGRAMS += post_example 32 | endif 33 | 34 | if ENABLE_DAUTH 35 | noinst_PROGRAMS += \ 36 | digest_auth_example 37 | endif 38 | 39 | if ENABLE_BAUTH 40 | noinst_PROGRAMS += \ 41 | authorization_example 42 | endif 43 | 44 | if HAVE_W32 45 | IBERTY=-liberty 46 | endif 47 | 48 | minimal_example_SOURCES = \ 49 | minimal_example.c 50 | minimal_example_LDADD = \ 51 | $(top_builddir)/src/daemon/libmicrohttpd.la 52 | 53 | dual_stack_example_SOURCES = \ 54 | dual_stack_example.c 55 | dual_stack_example_LDADD = \ 56 | $(top_builddir)/src/daemon/libmicrohttpd.la 57 | 58 | post_example_SOURCES = \ 59 | post_example.c 60 | post_example_LDADD = \ 61 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 62 | $(IBERTY) 63 | 64 | minimal_example_comet_SOURCES = \ 65 | minimal_example_comet.c 66 | minimal_example_comet_LDADD = \ 67 | $(top_builddir)/src/daemon/libmicrohttpd.la 68 | 69 | authorization_example_SOURCES = \ 70 | authorization_example.c 71 | authorization_example_LDADD = \ 72 | $(top_builddir)/src/daemon/libmicrohttpd.la 73 | 74 | digest_auth_example_SOURCES = \ 75 | digest_auth_example.c 76 | digest_auth_example_LDADD = \ 77 | $(top_builddir)/src/daemon/libmicrohttpd.la 78 | 79 | refuse_post_example_SOURCES = \ 80 | refuse_post_example.c 81 | refuse_post_example_LDADD = \ 82 | $(top_builddir)/src/daemon/libmicrohttpd.la 83 | 84 | querystring_example_SOURCES = \ 85 | querystring_example.c 86 | querystring_example_LDADD = \ 87 | $(top_builddir)/src/daemon/libmicrohttpd.la 88 | 89 | fileserver_example_SOURCES = \ 90 | fileserver_example.c 91 | fileserver_example_LDADD = \ 92 | $(top_builddir)/src/daemon/libmicrohttpd.la 93 | 94 | fileserver_example_dirs_SOURCES = \ 95 | fileserver_example_dirs.c 96 | fileserver_example_dirs_LDADD = \ 97 | $(top_builddir)/src/daemon/libmicrohttpd.la 98 | 99 | fileserver_example_external_select_SOURCES = \ 100 | fileserver_example_external_select.c 101 | fileserver_example_external_select_LDADD = \ 102 | $(top_builddir)/src/daemon/libmicrohttpd.la 103 | 104 | https_fileserver_example_SOURCES = \ 105 | https_fileserver_example.c 106 | https_fileserver_example_LDADD = \ 107 | $(top_builddir)/src/daemon/libmicrohttpd.la 108 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/authorization_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file authorization_example.c 22 | * @brief example for how to use libmicrohttpd with HTTP authentication 23 | * @author Christian Grothoff 24 | */ 25 | 26 | #include "platform.h" 27 | #include 28 | 29 | #define PAGE "libmicrohttpd demolibmicrohttpd demo" 30 | 31 | #define DENIED "Access deniedAccess denied" 32 | 33 | 34 | 35 | static int 36 | ahc_echo (void *cls, 37 | struct MHD_Connection *connection, 38 | const char *url, 39 | const char *method, 40 | const char *version, 41 | const char *upload_data, size_t *upload_data_size, void **ptr) 42 | { 43 | static int aptr; 44 | const char *me = cls; 45 | struct MHD_Response *response; 46 | int ret; 47 | char *user; 48 | char *pass; 49 | int fail; 50 | 51 | if (0 != strcmp (method, "GET")) 52 | return MHD_NO; /* unexpected method */ 53 | if (&aptr != *ptr) 54 | { 55 | /* do never respond on first call */ 56 | *ptr = &aptr; 57 | return MHD_YES; 58 | } 59 | *ptr = NULL; /* reset when done */ 60 | 61 | /* require: "Aladdin" with password "open sesame" */ 62 | pass = NULL; 63 | user = MHD_basic_auth_get_username_password (connection, &pass); 64 | fail = ( (user == NULL) || (0 != strcmp (user, "Aladdin")) || (0 != strcmp (pass, "open sesame") ) ); 65 | if (fail) 66 | { 67 | response = MHD_create_response_from_buffer (strlen (DENIED), 68 | (void *) DENIED, 69 | MHD_RESPMEM_PERSISTENT); 70 | ret = MHD_queue_basic_auth_fail_response (connection,"TestRealm",response); 71 | } 72 | else 73 | { 74 | response = MHD_create_response_from_buffer (strlen (me), 75 | (void *) me, 76 | MHD_RESPMEM_PERSISTENT); 77 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 78 | } 79 | 80 | MHD_destroy_response (response); 81 | return ret; 82 | } 83 | 84 | int 85 | main (int argc, char *const *argv) 86 | { 87 | struct MHD_Daemon *d; 88 | 89 | if (argc != 3) 90 | { 91 | printf ("%s PORT SECONDS-TO-RUN\n", argv[0]); 92 | return 1; 93 | } 94 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 95 | atoi (argv[1]), 96 | NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 97 | if (d == NULL) 98 | return 1; 99 | sleep (atoi (argv[2])); 100 | MHD_stop_daemon (d); 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/digest_auth_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2010 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file digest_auth_example.c 21 | * @brief minimal example for how to use digest auth with libmicrohttpd 22 | * @author Amr Ali 23 | */ 24 | 25 | #include "platform.h" 26 | #include 27 | #include 28 | 29 | #define PAGE "libmicrohttpd demoAccess granted" 30 | 31 | #define DENIED "libmicrohttpd demoAccess denied" 32 | 33 | #define OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" 34 | 35 | static int 36 | ahc_echo (void *cls, 37 | struct MHD_Connection *connection, 38 | const char *url, 39 | const char *method, 40 | const char *version, 41 | const char *upload_data, size_t *upload_data_size, void **ptr) 42 | { 43 | struct MHD_Response *response; 44 | char *username; 45 | const char *password = "testpass"; 46 | const char *realm = "test@example.com"; 47 | int ret; 48 | 49 | username = MHD_digest_auth_get_username(connection); 50 | if (username == NULL) 51 | { 52 | response = MHD_create_response_from_buffer(strlen (DENIED), 53 | DENIED, 54 | MHD_RESPMEM_PERSISTENT); 55 | ret = MHD_queue_auth_fail_response(connection, realm, 56 | OPAQUE, 57 | response, 58 | MHD_NO); 59 | MHD_destroy_response(response); 60 | return ret; 61 | } 62 | ret = MHD_digest_auth_check(connection, realm, 63 | username, 64 | password, 65 | 300); 66 | free(username); 67 | if ( (ret == MHD_INVALID_NONCE) || 68 | (ret == MHD_NO) ) 69 | { 70 | response = MHD_create_response_from_buffer(strlen (DENIED), 71 | DENIED, 72 | MHD_RESPMEM_PERSISTENT); 73 | if (NULL == response) 74 | return MHD_NO; 75 | ret = MHD_queue_auth_fail_response(connection, realm, 76 | OPAQUE, 77 | response, 78 | (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO); 79 | MHD_destroy_response(response); 80 | return ret; 81 | } 82 | response = MHD_create_response_from_buffer(strlen(PAGE), PAGE, 83 | MHD_RESPMEM_PERSISTENT); 84 | ret = MHD_queue_response(connection, MHD_HTTP_OK, response); 85 | MHD_destroy_response(response); 86 | return ret; 87 | } 88 | 89 | int 90 | main (int argc, char *const *argv) 91 | { 92 | int fd; 93 | char rnd[8]; 94 | size_t len; 95 | size_t off; 96 | struct MHD_Daemon *d; 97 | 98 | if (argc != 2) 99 | { 100 | printf ("%s PORT\n", argv[0]); 101 | return 1; 102 | } 103 | fd = open("/dev/urandom", O_RDONLY); 104 | if (-1 == fd) 105 | { 106 | fprintf (stderr, "Failed to open `%s': %s\n", 107 | "/dev/urandom", 108 | strerror (errno)); 109 | return 1; 110 | } 111 | off = 0; 112 | while (off < 8) 113 | { 114 | len = read(fd, rnd, 8); 115 | if (len == -1) 116 | { 117 | fprintf (stderr, "Failed to read `%s': %s\n", 118 | "/dev/urandom", 119 | strerror (errno)); 120 | (void) close (fd); 121 | return 1; 122 | } 123 | off += len; 124 | } 125 | (void) close(fd); 126 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 127 | atoi (argv[1]), 128 | NULL, NULL, &ahc_echo, PAGE, 129 | MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof(rnd), rnd, 130 | MHD_OPTION_NONCE_NC_SIZE, 300, 131 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, 132 | MHD_OPTION_END); 133 | if (d == NULL) 134 | return 1; 135 | (void) getc (stdin); 136 | MHD_stop_daemon (d); 137 | return 0; 138 | } 139 | 140 | /* end of digest_auth_example.c */ 141 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/dual_stack_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2012 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file dual_stack_example.c 21 | * @brief how to use MHD with both IPv4 and IPv6 support (dual-stack) 22 | * @author Christian Grothoff 23 | */ 24 | 25 | #include "platform.h" 26 | #include 27 | 28 | #define PAGE "libmicrohttpd demolibmicrohttpd demo" 29 | 30 | static int 31 | ahc_echo (void *cls, 32 | struct MHD_Connection *connection, 33 | const char *url, 34 | const char *method, 35 | const char *version, 36 | const char *upload_data, size_t *upload_data_size, void **ptr) 37 | { 38 | static int aptr; 39 | const char *me = cls; 40 | struct MHD_Response *response; 41 | int ret; 42 | 43 | if (0 != strcmp (method, "GET")) 44 | return MHD_NO; /* unexpected method */ 45 | if (&aptr != *ptr) 46 | { 47 | /* do never respond on first call */ 48 | *ptr = &aptr; 49 | return MHD_YES; 50 | } 51 | *ptr = NULL; /* reset when done */ 52 | response = MHD_create_response_from_buffer (strlen (me), 53 | (void *) me, 54 | MHD_RESPMEM_PERSISTENT); 55 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 56 | MHD_destroy_response (response); 57 | return ret; 58 | } 59 | 60 | int 61 | main (int argc, char *const *argv) 62 | { 63 | struct MHD_Daemon *d4; 64 | struct MHD_Daemon *d6; 65 | 66 | if (argc != 2) 67 | { 68 | printf ("%s PORT\n", argv[0]); 69 | return 1; 70 | } 71 | d4 = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, 72 | atoi (argv[1]), 73 | NULL, NULL, &ahc_echo, PAGE, 74 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, 75 | MHD_OPTION_END); 76 | d6 = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | MHD_USE_IPv6, 77 | atoi (argv[1]), 78 | NULL, NULL, &ahc_echo, PAGE, 79 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, 80 | MHD_OPTION_END); 81 | (void) getc (stdin); 82 | MHD_stop_daemon (d4); 83 | MHD_stop_daemon (d6); 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/fileserver_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file fileserver_example.c 22 | * @brief minimal example for how to use libmicrohttpd to serve files 23 | * @author Christian Grothoff 24 | */ 25 | 26 | #include "platform.h" 27 | #include 28 | #include 29 | 30 | #define PAGE "File not foundFile not found" 31 | 32 | static ssize_t 33 | file_reader (void *cls, uint64_t pos, char *buf, size_t max) 34 | { 35 | FILE *file = cls; 36 | 37 | (void) fseek (file, pos, SEEK_SET); 38 | return fread (buf, 1, max, file); 39 | } 40 | 41 | static void 42 | free_callback (void *cls) 43 | { 44 | FILE *file = cls; 45 | fclose (file); 46 | } 47 | 48 | static int 49 | ahc_echo (void *cls, 50 | struct MHD_Connection *connection, 51 | const char *url, 52 | const char *method, 53 | const char *version, 54 | const char *upload_data, 55 | size_t *upload_data_size, void **ptr) 56 | { 57 | static int aptr; 58 | struct MHD_Response *response; 59 | int ret; 60 | FILE *file; 61 | struct stat buf; 62 | 63 | if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) 64 | return MHD_NO; /* unexpected method */ 65 | if (&aptr != *ptr) 66 | { 67 | /* do never respond on first call */ 68 | *ptr = &aptr; 69 | return MHD_YES; 70 | } 71 | *ptr = NULL; /* reset when done */ 72 | if (0 == stat (&url[1], &buf)) 73 | file = fopen (&url[1], "rb"); 74 | else 75 | file = NULL; 76 | if (file == NULL) 77 | { 78 | response = MHD_create_response_from_buffer (strlen (PAGE), 79 | (void *) PAGE, 80 | MHD_RESPMEM_PERSISTENT); 81 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); 82 | MHD_destroy_response (response); 83 | } 84 | else 85 | { 86 | response = MHD_create_response_from_callback (buf.st_size, 32 * 1024, /* 32k page size */ 87 | &file_reader, 88 | file, 89 | &free_callback); 90 | if (response == NULL) 91 | { 92 | fclose (file); 93 | return MHD_NO; 94 | } 95 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 96 | MHD_destroy_response (response); 97 | } 98 | return ret; 99 | } 100 | 101 | int 102 | main (int argc, char *const *argv) 103 | { 104 | struct MHD_Daemon *d; 105 | 106 | if (argc != 2) 107 | { 108 | printf ("%s PORT\n", argv[0]); 109 | return 1; 110 | } 111 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 112 | atoi (argv[1]), 113 | NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 114 | if (d == NULL) 115 | return 1; 116 | (void) getc (stdin); 117 | MHD_stop_daemon (d); 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/fileserver_example_dirs.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file fileserver_example.c 22 | * @brief example for how to use libmicrohttpd to serve files (with directory support) 23 | * @author Christian Grothoff 24 | */ 25 | 26 | #include "platform.h" 27 | #include 28 | #include 29 | #include 30 | 31 | #define PAGE "File not foundFile not found" 32 | 33 | static ssize_t 34 | file_reader (void *cls, uint64_t pos, char *buf, size_t max) 35 | { 36 | FILE *file = cls; 37 | 38 | (void) fseek (file, pos, SEEK_SET); 39 | return fread (buf, 1, max, file); 40 | } 41 | 42 | static void 43 | file_free_callback (void *cls) 44 | { 45 | FILE *file = cls; 46 | fclose (file); 47 | } 48 | 49 | static void 50 | dir_free_callback (void *cls) 51 | { 52 | DIR *dir = cls; 53 | if (dir != NULL) 54 | closedir (dir); 55 | } 56 | 57 | static ssize_t 58 | dir_reader (void *cls, uint64_t pos, char *buf, size_t max) 59 | { 60 | DIR *dir = cls; 61 | struct dirent *e; 62 | 63 | if (max < 512) 64 | return 0; 65 | do 66 | { 67 | e = readdir (dir); 68 | if (e == NULL) 69 | return MHD_CONTENT_READER_END_OF_STREAM; 70 | } while (e->d_name[0] == '.'); 71 | return snprintf (buf, max, 72 | "%s
", 73 | e->d_name, 74 | e->d_name); 75 | } 76 | 77 | 78 | static int 79 | ahc_echo (void *cls, 80 | struct MHD_Connection *connection, 81 | const char *url, 82 | const char *method, 83 | const char *version, 84 | const char *upload_data, 85 | size_t *upload_data_size, void **ptr) 86 | { 87 | static int aptr; 88 | struct MHD_Response *response; 89 | int ret; 90 | FILE *file; 91 | DIR *dir; 92 | struct stat buf; 93 | char emsg[1024]; 94 | 95 | if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) 96 | return MHD_NO; /* unexpected method */ 97 | if (&aptr != *ptr) 98 | { 99 | /* do never respond on first call */ 100 | *ptr = &aptr; 101 | return MHD_YES; 102 | } 103 | *ptr = NULL; /* reset when done */ 104 | if ( (0 == stat (&url[1], &buf)) && 105 | (S_ISREG (buf.st_mode)) ) 106 | file = fopen (&url[1], "rb"); 107 | else 108 | file = NULL; 109 | if (file == NULL) 110 | { 111 | dir = opendir ("."); 112 | if (dir == NULL) 113 | { 114 | /* most likely cause: more concurrent requests than 115 | available file descriptors / 2 */ 116 | snprintf (emsg, 117 | sizeof (emsg), 118 | "Failed to open directory `.': %s\n", 119 | strerror (errno)); 120 | response = MHD_create_response_from_buffer (strlen (emsg), 121 | emsg, 122 | MHD_RESPMEM_MUST_COPY); 123 | if (response == NULL) 124 | return MHD_NO; 125 | ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); 126 | MHD_destroy_response (response); 127 | } 128 | else 129 | { 130 | response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 131 | 32 * 1024, 132 | &dir_reader, 133 | dir, 134 | &dir_free_callback); 135 | if (response == NULL) 136 | { 137 | closedir (dir); 138 | return MHD_NO; 139 | } 140 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 141 | MHD_destroy_response (response); 142 | } 143 | } 144 | else 145 | { 146 | response = MHD_create_response_from_callback (buf.st_size, 32 * 1024, /* 32k page size */ 147 | &file_reader, 148 | file, 149 | &file_free_callback); 150 | if (response == NULL) 151 | { 152 | fclose (file); 153 | return MHD_NO; 154 | } 155 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 156 | MHD_destroy_response (response); 157 | } 158 | return ret; 159 | } 160 | 161 | int 162 | main (int argc, char *const *argv) 163 | { 164 | struct MHD_Daemon *d; 165 | 166 | if (argc != 2) 167 | { 168 | printf ("%s PORT\n", argv[0]); 169 | return 1; 170 | } 171 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 172 | atoi (argv[1]), 173 | NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 174 | if (d == NULL) 175 | return 1; 176 | (void) getc (stdin); 177 | MHD_stop_daemon (d); 178 | return 0; 179 | } 180 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/fileserver_example_external_select.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file fileserver_example_external_select.c 21 | * @brief minimal example for how to use libmicrohttpd to server files 22 | * @author Christian Grothoff 23 | */ 24 | 25 | #include "platform.h" 26 | #include 27 | #include 28 | #include 29 | 30 | #define PAGE "File not foundFile not found" 31 | 32 | static ssize_t 33 | file_reader (void *cls, uint64_t pos, char *buf, size_t max) 34 | { 35 | FILE *file = cls; 36 | 37 | (void) fseek (file, pos, SEEK_SET); 38 | return fread (buf, 1, max, file); 39 | } 40 | 41 | static void 42 | free_callback (void *cls) 43 | { 44 | FILE *file = cls; 45 | fclose (file); 46 | } 47 | 48 | static int 49 | ahc_echo (void *cls, 50 | struct MHD_Connection *connection, 51 | const char *url, 52 | const char *method, 53 | const char *version, 54 | const char *upload_data, 55 | size_t *upload_data_size, void **ptr) 56 | { 57 | static int aptr; 58 | struct MHD_Response *response; 59 | int ret; 60 | FILE *file; 61 | struct stat buf; 62 | 63 | if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) 64 | return MHD_NO; /* unexpected method */ 65 | if (&aptr != *ptr) 66 | { 67 | /* do never respond on first call */ 68 | *ptr = &aptr; 69 | return MHD_YES; 70 | } 71 | *ptr = NULL; /* reset when done */ 72 | if ( (0 == stat (&url[1], &buf)) && 73 | (S_ISREG (buf.st_mode)) ) 74 | file = fopen (&url[1], "rb"); 75 | else 76 | file = NULL; 77 | if (file == NULL) 78 | { 79 | response = MHD_create_response_from_buffer (strlen (PAGE), 80 | (void *) PAGE, 81 | MHD_RESPMEM_PERSISTENT); 82 | ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); 83 | MHD_destroy_response (response); 84 | } 85 | else 86 | { 87 | response = MHD_create_response_from_callback (buf.st_size, 32 * 1024, /* 32k page size */ 88 | &file_reader, 89 | file, 90 | &free_callback); 91 | if (response == NULL) 92 | { 93 | fclose (file); 94 | return MHD_NO; 95 | } 96 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 97 | MHD_destroy_response (response); 98 | } 99 | return ret; 100 | } 101 | 102 | int 103 | main (int argc, char *const *argv) 104 | { 105 | struct MHD_Daemon *d; 106 | time_t end; 107 | time_t t; 108 | struct timeval tv; 109 | fd_set rs; 110 | fd_set ws; 111 | fd_set es; 112 | int max; 113 | unsigned MHD_LONG_LONG mhd_timeout; 114 | 115 | if (argc != 3) 116 | { 117 | printf ("%s PORT SECONDS-TO-RUN\n", argv[0]); 118 | return 1; 119 | } 120 | d = MHD_start_daemon (MHD_USE_DEBUG, 121 | atoi (argv[1]), 122 | NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 123 | if (d == NULL) 124 | return 1; 125 | end = time (NULL) + atoi (argv[2]); 126 | while ((t = time (NULL)) < end) 127 | { 128 | tv.tv_sec = end - t; 129 | tv.tv_usec = 0; 130 | max = 0; 131 | FD_ZERO (&rs); 132 | FD_ZERO (&ws); 133 | FD_ZERO (&es); 134 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) 135 | break; /* fatal internal error */ 136 | if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES) 137 | 138 | { 139 | if (tv.tv_sec * 1000 < mhd_timeout) 140 | { 141 | tv.tv_sec = mhd_timeout / 1000; 142 | tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000; 143 | } 144 | } 145 | select (max + 1, &rs, &ws, &es, &tv); 146 | MHD_run (d); 147 | } 148 | MHD_stop_daemon (d); 149 | return 0; 150 | } 151 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/minimal_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file minimal_example.c 21 | * @brief minimal example for how to use libmicrohttpd 22 | * @author Christian Grothoff 23 | */ 24 | 25 | #include "platform.h" 26 | #include 27 | 28 | #define PAGE "libmicrohttpd demolibmicrohttpd demo" 29 | 30 | static int 31 | ahc_echo (void *cls, 32 | struct MHD_Connection *connection, 33 | const char *url, 34 | const char *method, 35 | const char *version, 36 | const char *upload_data, size_t *upload_data_size, void **ptr) 37 | { 38 | static int aptr; 39 | const char *me = cls; 40 | struct MHD_Response *response; 41 | int ret; 42 | 43 | if (0 != strcmp (method, "GET")) 44 | return MHD_NO; /* unexpected method */ 45 | if (&aptr != *ptr) 46 | { 47 | /* do never respond on first call */ 48 | *ptr = &aptr; 49 | return MHD_YES; 50 | } 51 | *ptr = NULL; /* reset when done */ 52 | response = MHD_create_response_from_buffer (strlen (me), 53 | (void *) me, 54 | MHD_RESPMEM_PERSISTENT); 55 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 56 | MHD_destroy_response (response); 57 | return ret; 58 | } 59 | 60 | int 61 | main (int argc, char *const *argv) 62 | { 63 | struct MHD_Daemon *d; 64 | 65 | if (argc != 2) 66 | { 67 | printf ("%s PORT\n", argv[0]); 68 | return 1; 69 | } 70 | d = MHD_start_daemon (// MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | MHD_USE_POLL, 71 | MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, 72 | // MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | MHD_USE_POLL, 73 | // MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 74 | atoi (argv[1]), 75 | NULL, NULL, &ahc_echo, PAGE, 76 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, 77 | MHD_OPTION_END); 78 | if (d == NULL) 79 | return 1; 80 | (void) getc (stdin); 81 | MHD_stop_daemon (d); 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/minimal_example_comet.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file minimal_example.c 21 | * @brief minimal example for how to generate an infinite stream with libmicrohttpd 22 | * @author Christian Grothoff 23 | */ 24 | 25 | #include "platform.h" 26 | #include 27 | 28 | static ssize_t 29 | data_generator (void *cls, uint64_t pos, char *buf, size_t max) 30 | { 31 | if (max < 80) 32 | return 0; 33 | memset (buf, 'A', max - 1); 34 | buf[79] = '\n'; 35 | return 80; 36 | } 37 | 38 | static int 39 | ahc_echo (void *cls, 40 | struct MHD_Connection *connection, 41 | const char *url, 42 | const char *method, 43 | const char *version, 44 | const char *upload_data, size_t *upload_data_size, void **ptr) 45 | { 46 | static int aptr; 47 | struct MHD_Response *response; 48 | int ret; 49 | 50 | if (0 != strcmp (method, "GET")) 51 | return MHD_NO; /* unexpected method */ 52 | if (&aptr != *ptr) 53 | { 54 | /* do never respond on first call */ 55 | *ptr = &aptr; 56 | return MHD_YES; 57 | } 58 | *ptr = NULL; /* reset when done */ 59 | response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 60 | 80, 61 | &data_generator, NULL, NULL); 62 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 63 | MHD_destroy_response (response); 64 | return ret; 65 | } 66 | 67 | int 68 | main (int argc, char *const *argv) 69 | { 70 | struct MHD_Daemon *d; 71 | 72 | if (argc != 2) 73 | { 74 | printf ("%s PORT\n", argv[0]); 75 | return 1; 76 | } 77 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 78 | atoi (argv[1]), 79 | NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 80 | if (d == NULL) 81 | return 1; 82 | (void) getc (stdin); 83 | MHD_stop_daemon (d); 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/querystring_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file querystring_example.c 21 | * @brief example for how to get the query string from libmicrohttpd 22 | * Call with an URI ending with something like "?q=QUERY" 23 | * @author Christian Grothoff 24 | */ 25 | 26 | #include "platform.h" 27 | #include 28 | 29 | #define PAGE "libmicrohttpd demoQuery string for "%s" was "%s"" 30 | 31 | static int 32 | ahc_echo (void *cls, 33 | struct MHD_Connection *connection, 34 | const char *url, 35 | const char *method, 36 | const char *version, 37 | const char *upload_data, size_t *upload_data_size, void **ptr) 38 | { 39 | static int aptr; 40 | const char *fmt = cls; 41 | const char *val; 42 | char *me; 43 | struct MHD_Response *response; 44 | int ret; 45 | 46 | if (0 != strcmp (method, "GET")) 47 | return MHD_NO; /* unexpected method */ 48 | if (&aptr != *ptr) 49 | { 50 | /* do never respond on first call */ 51 | *ptr = &aptr; 52 | return MHD_YES; 53 | } 54 | *ptr = NULL; /* reset when done */ 55 | val = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "q"); 56 | me = malloc (snprintf (NULL, 0, fmt, "q", val) + 1); 57 | if (me == NULL) 58 | return MHD_NO; 59 | sprintf (me, fmt, "q", val); 60 | response = MHD_create_response_from_buffer (strlen (me), me, 61 | MHD_RESPMEM_MUST_FREE); 62 | if (response == NULL) 63 | { 64 | free (me); 65 | return MHD_NO; 66 | } 67 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 68 | MHD_destroy_response (response); 69 | return ret; 70 | } 71 | 72 | int 73 | main (int argc, char *const *argv) 74 | { 75 | struct MHD_Daemon *d; 76 | 77 | if (argc != 2) 78 | { 79 | printf ("%s PORT\n", argv[0]); 80 | return 1; 81 | } 82 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 83 | atoi (argv[1]), 84 | NULL, NULL, &ahc_echo, PAGE, MHD_OPTION_END); 85 | if (d == NULL) 86 | return 1; 87 | (void) getc (stdin); 88 | MHD_stop_daemon (d); 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/examples/refuse_post_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | /** 20 | * @file refuse_post_example.c 21 | * @brief example for how to refuse a POST request properly 22 | * @author Christian Grothoff and Sebastian Gerhardt 23 | */ 24 | #include "platform.h" 25 | #include 26 | 27 | const char *askpage = "\n\ 28 | Upload a file, please!
\n\ 29 |
\n\ 30 | \n\ 31 |
\n\ 32 | "; 33 | 34 | #define BUSYPAGE "Webserver busyWe are too busy to process POSTs right now." 35 | 36 | static int 37 | ahc_echo (void *cls, 38 | struct MHD_Connection *connection, 39 | const char *url, 40 | const char *method, 41 | const char *version, 42 | const char *upload_data, size_t *upload_data_size, void **ptr) 43 | { 44 | static int aptr; 45 | const char *me = cls; 46 | struct MHD_Response *response; 47 | int ret; 48 | 49 | if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST"))) 50 | return MHD_NO; /* unexpected method */ 51 | 52 | if (&aptr != *ptr) 53 | { 54 | *ptr = &aptr; 55 | 56 | /* always to busy for POST requests */ 57 | if (0 == strcmp (method, "POST")) 58 | { 59 | response = MHD_create_response_from_buffer (strlen (BUSYPAGE), 60 | (void *) BUSYPAGE, 61 | MHD_RESPMEM_PERSISTENT); 62 | ret = 63 | MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, 64 | response); 65 | MHD_destroy_response (response); 66 | return ret; 67 | } 68 | } 69 | 70 | *ptr = NULL; /* reset when done */ 71 | response = MHD_create_response_from_buffer (strlen (me), 72 | (void *) me, 73 | MHD_RESPMEM_PERSISTENT); 74 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 75 | MHD_destroy_response (response); 76 | return ret; 77 | } 78 | 79 | int 80 | main (int argc, char *const *argv) 81 | { 82 | struct MHD_Daemon *d; 83 | 84 | if (argc != 2) 85 | { 86 | printf ("%s PORT\n", argv[0]); 87 | return 1; 88 | } 89 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 90 | atoi (argv[1]), 91 | NULL, NULL, &ahc_echo, (void *) askpage, 92 | MHD_OPTION_END); 93 | if (d == NULL) 94 | return 1; 95 | (void) getc (stdin); 96 | MHD_stop_daemon (d); 97 | return 0; 98 | } 99 | 100 | /* end of refuse_post_example.c */ 101 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/include/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = plibc . 2 | include_HEADERS = microhttpd.h 3 | 4 | EXTRA_DIST = platform.h 5 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/include/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2008 Christian Grothoff (and other contributing authors) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | /** 21 | * @file platform.h 22 | * @brief platform-specific includes for libmicrohttpd 23 | * @author Christian Grothoff 24 | * 25 | * This file is included by the libmicrohttpd code 26 | * before "microhttpd.h"; it provides the required 27 | * standard headers (which are platform-specific).

28 | * 29 | * Note that this file depends on our configure.ac 30 | * build process and the generated config.h file. 31 | * Hence you cannot include it directly in applications 32 | * that use libmicrohttpd. 33 | */ 34 | #ifndef MHD_PLATFORM_H 35 | #define MHD_PLATFORM_H 36 | 37 | #include "MHD_config.h" 38 | 39 | #define _XOPEN_SOURCE_EXTENDED 1 40 | #if OS390 41 | #define _OPEN_THREADS 42 | #define _OPEN_SYS_SOCK_IPV6 43 | #define _OPEN_MSGQ_EXT 44 | #define _LP64 45 | #endif 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #if !defined(MINGW) && !defined(__SYMBIAN32__) 57 | #include 58 | #endif 59 | #include 60 | #undef HAVE_CONFIG_H 61 | #include 62 | #define HAVE_CONFIG_H 1 63 | 64 | /* different OSes have fd_set in 65 | a broad range of header files; 66 | we just include most of them (if they 67 | are available) */ 68 | 69 | 70 | #ifdef OS_VXWORKS 71 | #include 72 | #include 73 | #include 74 | #include 75 | #define RESTRICT __restrict__ 76 | #endif 77 | #if HAVE_MEMORY_H 78 | #include 79 | #endif 80 | 81 | #if HAVE_SYS_SELECT_H 82 | #include 83 | #endif 84 | #if HAVE_SYS_TYPES_H 85 | #include 86 | #endif 87 | #if HAVE_SYS_TIME_H 88 | #include 89 | #endif 90 | #if HAVE_SYS_STAT_H 91 | #include 92 | #endif 93 | #if HAVE_SYS_MSG_H 94 | #include 95 | #endif 96 | #if HAVE_SYS_MMAN_H 97 | #include 98 | #endif 99 | #if HAVE_NETDB_H 100 | #include 101 | #endif 102 | #if HAVE_NETINET_IN_H 103 | #include 104 | #endif 105 | #if HAVE_TIME_H 106 | #include 107 | #endif 108 | #if HAVE_SYS_SOCKET_H 109 | #include 110 | #endif 111 | #if HAVE_ARPA_INET_H 112 | #include 113 | #endif 114 | 115 | #include 116 | 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/include/plibc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = . 2 | 3 | EXTRA_DIST = plibc.h 4 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/curl_version_check.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file curl_version_check.c 23 | * @brief verify required cURL version is available to run tests 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "MHD_config.h" 28 | #include "platform.h" 29 | #include 30 | 31 | #ifndef WINDOWS 32 | #include 33 | #endif 34 | 35 | static int 36 | parse_version_number (const char **s) 37 | { 38 | int i = 0; 39 | char num[17]; 40 | 41 | while (i < 16 && ((**s >= '0') & (**s <= '9'))) 42 | { 43 | num[i] = **s; 44 | (*s)++; 45 | i++; 46 | } 47 | 48 | num[i] = '\0'; 49 | 50 | return atoi (num); 51 | } 52 | 53 | const char * 54 | parse_version_string (const char *s, int *major, int *minor, int *micro) 55 | { 56 | if (!s) 57 | return NULL; 58 | *major = parse_version_number (&s); 59 | if (*s != '.') 60 | return NULL; 61 | s++; 62 | *minor = parse_version_number (&s); 63 | if (*s != '.') 64 | return NULL; 65 | s++; 66 | *micro = parse_version_number (&s); 67 | return s; 68 | } 69 | 70 | #if HTTPS_SUPPORT 71 | int 72 | curl_uses_nss_ssl() 73 | { 74 | return (strstr(curl_version(), " NSS/") != NULL) ? 0 : -1; 75 | } 76 | #endif 77 | 78 | /* 79 | * check local libcurl version matches required version 80 | */ 81 | int 82 | curl_check_version (const char *req_version) 83 | { 84 | const char *ver; 85 | const char *curl_ver; 86 | #if HTTPS_SUPPORT 87 | const char *ssl_ver; 88 | const char *req_ssl_ver; 89 | #endif 90 | 91 | int loc_major, loc_minor, loc_micro; 92 | int rq_major, rq_minor, rq_micro; 93 | 94 | ver = curl_version (); 95 | #if HAVE_MESSAGES 96 | fprintf (stderr, "curl version: %s\n", ver); 97 | #endif 98 | /* 99 | * this call relies on the cURL string to be of the exact following format : 100 | * 'libcurl/7.16.4 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/0.6.5' OR 101 | * 'libcurl/7.18.2 GnuTLS/2.4.0 zlib/1.2.3.3 libidn/0.6.5' 102 | */ 103 | curl_ver = strchr (ver, '/'); 104 | if (curl_ver == NULL) 105 | return -1; 106 | curl_ver++; 107 | /* Parse version numbers */ 108 | if ( (NULL == parse_version_string (req_version, &rq_major, &rq_minor, &rq_micro)) || 109 | (NULL == parse_version_string (curl_ver, &loc_major, &loc_minor, &loc_micro)) ) 110 | return -1; 111 | 112 | /* Compare version numbers. */ 113 | if ((loc_major > rq_major 114 | || (loc_major == rq_major && loc_minor > rq_minor) 115 | || (loc_major == rq_major && loc_minor == rq_minor 116 | && loc_micro > rq_micro) || (loc_major == rq_major 117 | && loc_minor == rq_minor 118 | && loc_micro == rq_micro)) == 0) 119 | { 120 | fprintf (stderr, 121 | "Error: running curl test depends on local libcurl version > %s\n", 122 | req_version); 123 | return -1; 124 | } 125 | 126 | /* 127 | * enforce required gnutls/openssl version. 128 | * TODO use curl version string to assert use of gnutls 129 | */ 130 | #if HTTPS_SUPPORT 131 | ssl_ver = strchr (curl_ver, ' '); 132 | if (ssl_ver == NULL) 133 | return -1; 134 | ssl_ver++; 135 | if (strncmp ("GnuTLS", ssl_ver, strlen ("GNUtls")) == 0) 136 | { 137 | ssl_ver = strchr (ssl_ver, '/'); 138 | req_ssl_ver = MHD_REQ_CURL_GNUTLS_VERSION; 139 | } 140 | else if (strncmp ("OpenSSL", ssl_ver, strlen ("OpenSSL")) == 0) 141 | { 142 | ssl_ver = strchr (ssl_ver, '/'); 143 | req_ssl_ver = MHD_REQ_CURL_OPENSSL_VERSION; 144 | } 145 | else if (strncmp ("NSS", ssl_ver, strlen ("NSS")) == 0) 146 | { 147 | ssl_ver = strchr (ssl_ver, '/'); 148 | req_ssl_ver = MHD_REQ_CURL_NSS_VERSION; 149 | } 150 | else 151 | { 152 | fprintf (stderr, "Error: unrecognized curl ssl library\n"); 153 | return -1; 154 | } 155 | if (ssl_ver == NULL) 156 | return -1; 157 | ssl_ver++; 158 | if ( (NULL == parse_version_string (req_ssl_ver, &rq_major, &rq_minor, &rq_micro)) || 159 | (NULL == parse_version_string (ssl_ver, &loc_major, &loc_minor, &loc_micro)) ) 160 | return -1; 161 | 162 | if ((loc_major > rq_major 163 | || (loc_major == rq_major && loc_minor > rq_minor) 164 | || (loc_major == rq_major && loc_minor == rq_minor 165 | && loc_micro > rq_micro) || (loc_major == rq_major 166 | && loc_minor == rq_minor 167 | && loc_micro == rq_micro)) == 0) 168 | { 169 | fprintf (stderr, 170 | "Error: running curl test depends on local libcurl SSL version > %s\n", 171 | req_ssl_ver); 172 | return -1; 173 | } 174 | #endif 175 | return 0; 176 | } 177 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/daemon_options_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file mhds_get_test.c 23 | * @brief Testcase for libmicrohttpd HTTPS GET operations 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | 30 | #define MHD_E_MEM "Error: memory error\n" 31 | #define MHD_E_SERVER_INIT "Error: failed to start server\n" 32 | 33 | const int DEBUG_GNUTLS_LOG_LEVEL = 0; 34 | const char *test_file_name = "https_test_file"; 35 | const char test_file_data[] = "Hello World\n"; 36 | 37 | static int 38 | ahc_echo (void *cls, 39 | struct MHD_Connection *connection, 40 | const char *url, 41 | const char *method, 42 | const char *version, 43 | const char *upload_data, size_t *upload_data_size, 44 | void **unused) 45 | { 46 | return 0; 47 | } 48 | 49 | int 50 | test_wrap (char *test_name, int (*test) (void)) 51 | { 52 | int ret; 53 | 54 | fprintf (stdout, "running test: %s ", test_name); 55 | ret = test (); 56 | if (ret == 0) 57 | { 58 | fprintf (stdout, "[pass]\n"); 59 | } 60 | else 61 | { 62 | fprintf (stdout, "[fail]\n"); 63 | } 64 | return ret; 65 | } 66 | 67 | 68 | /** 69 | * Test daemon initialization with the MHD_OPTION_SOCK_ADDR option 70 | */ 71 | static int 72 | test_ip_addr_option () 73 | { 74 | struct MHD_Daemon *d; 75 | struct sockaddr_in daemon_ip_addr; 76 | #if HAVE_INET6 77 | struct sockaddr_in6 daemon_ip_addr6; 78 | #endif 79 | 80 | memset (&daemon_ip_addr, 0, sizeof (struct sockaddr_in)); 81 | daemon_ip_addr.sin_family = AF_INET; 82 | daemon_ip_addr.sin_port = htons (4233); 83 | 84 | #if HAVE_INET6 85 | memset (&daemon_ip_addr6, 0, sizeof (struct sockaddr_in6)); 86 | daemon_ip_addr6.sin6_family = AF_INET6; 87 | daemon_ip_addr6.sin6_port = htons (4233); 88 | #endif 89 | 90 | inet_pton (AF_INET, "127.0.0.1", &daemon_ip_addr.sin_addr); 91 | #if HAVE_INET6 92 | inet_pton (AF_INET6, "::ffff:127.0.0.1", &daemon_ip_addr6.sin6_addr); 93 | #endif 94 | 95 | d = MHD_start_daemon (MHD_USE_DEBUG, 4233, 96 | NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, 97 | &daemon_ip_addr, MHD_OPTION_END); 98 | 99 | if (d == 0) 100 | return -1; 101 | 102 | MHD_stop_daemon (d); 103 | 104 | #if HAVE_INET6 105 | d = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_IPv6, 4233, 106 | NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, 107 | &daemon_ip_addr6, MHD_OPTION_END); 108 | 109 | if (d == 0) 110 | return -1; 111 | 112 | MHD_stop_daemon (d); 113 | #endif 114 | 115 | return 0; 116 | } 117 | 118 | /* setup a temporary transfer test file */ 119 | int 120 | main (int argc, char *const *argv) 121 | { 122 | unsigned int errorCount = 0; 123 | 124 | errorCount += test_wrap ("ip addr option", &test_ip_addr_option); 125 | 126 | return errorCount != 0; 127 | } 128 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/daemontest_termination.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2009 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file daemontest_termination.c 23 | * @brief Testcase for libmicrohttpd tolerating client not closing immediately 24 | * @author hollosig 25 | */ 26 | #define PORT 12345 27 | 28 | #include "platform.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifndef __MINGW32__ 40 | #include 41 | #include 42 | #endif 43 | 44 | static int 45 | connection_handler (void *cls, 46 | struct MHD_Connection *connection, 47 | const char *url, 48 | const char *method, 49 | const char *version, 50 | const char *upload_data, size_t * upload_data_size, 51 | void **ptr) 52 | { 53 | static int i; 54 | 55 | if (*ptr == NULL) 56 | { 57 | *ptr = &i; 58 | return MHD_YES; 59 | } 60 | 61 | if (*upload_data_size != 0) 62 | { 63 | (*upload_data_size) = 0; 64 | return MHD_YES; 65 | } 66 | 67 | struct MHD_Response *response = 68 | MHD_create_response_from_buffer (strlen ("Response"), "Response", 69 | MHD_RESPMEM_PERSISTENT); 70 | int ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 71 | MHD_destroy_response (response); 72 | 73 | return ret; 74 | } 75 | 76 | static size_t 77 | write_data (void *ptr, size_t size, size_t nmemb, void *stream) 78 | { 79 | return size * nmemb; 80 | } 81 | 82 | int 83 | main () 84 | { 85 | struct MHD_Daemon *daemon; 86 | 87 | daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 88 | PORT, 89 | NULL, 90 | NULL, connection_handler, NULL, MHD_OPTION_END); 91 | 92 | if (daemon == NULL) 93 | { 94 | fprintf (stderr, "Daemon cannot be started!"); 95 | exit (1); 96 | } 97 | 98 | CURL *curl = curl_easy_init (); 99 | //curl_easy_setopt(curl, CURLOPT_POST, 1L); 100 | char url[255]; 101 | sprintf (url, "http://127.0.0.1:%d", PORT); 102 | curl_easy_setopt (curl, CURLOPT_URL, url); 103 | curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data); 104 | 105 | CURLcode success = curl_easy_perform (curl); 106 | if (success != 0) 107 | { 108 | fprintf (stderr, "CURL Error"); 109 | exit (1); 110 | } 111 | /* CPU used to go crazy here */ 112 | sleep (1); 113 | 114 | curl_easy_cleanup (curl); 115 | MHD_stop_daemon (daemon); 116 | 117 | return 0; 118 | } 119 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/daemontest_urlparse.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2009, 2011 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file daemontest_urlparse.c 23 | * @brief Testcase for libmicrohttpd url parsing 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #include "MHD_config.h" 28 | #include "platform.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __MINGW32__ 36 | #define usleep(usec) (Sleep ((usec) / 1000),0) 37 | #endif 38 | 39 | #ifndef WINDOWS 40 | #include 41 | #include 42 | #endif 43 | 44 | static int oneone; 45 | 46 | static int matches; 47 | 48 | struct CBC 49 | { 50 | char *buf; 51 | size_t pos; 52 | size_t size; 53 | }; 54 | 55 | static size_t 56 | copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) 57 | { 58 | struct CBC *cbc = ctx; 59 | 60 | if (cbc->pos + size * nmemb > cbc->size) 61 | return 0; /* overflow */ 62 | memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); 63 | cbc->pos += size * nmemb; 64 | return size * nmemb; 65 | } 66 | 67 | static int 68 | test_values (void *cls, 69 | enum MHD_ValueKind kind, 70 | const char *key, 71 | const char *value) 72 | { 73 | if ( (0 == strcmp (key, "a")) && 74 | (0 == strcmp (value, "b")) ) 75 | matches += 1; 76 | if ( (0 == strcmp (key, "c")) && 77 | (0 == strcmp (value, "")) ) 78 | matches += 2; 79 | if ( (0 == strcmp (key, "d")) && 80 | (NULL == value) ) 81 | matches += 4; 82 | return MHD_YES; 83 | } 84 | 85 | static int 86 | ahc_echo (void *cls, 87 | struct MHD_Connection *connection, 88 | const char *url, 89 | const char *method, 90 | const char *version, 91 | const char *upload_data, size_t *upload_data_size, 92 | void **unused) 93 | { 94 | static int ptr; 95 | const char *me = cls; 96 | struct MHD_Response *response; 97 | int ret; 98 | 99 | if (0 != strcmp (me, method)) 100 | return MHD_NO; /* unexpected method */ 101 | if (&ptr != *unused) 102 | { 103 | *unused = &ptr; 104 | return MHD_YES; 105 | } 106 | MHD_get_connection_values (connection, 107 | MHD_GET_ARGUMENT_KIND, 108 | &test_values, 109 | NULL); 110 | *unused = NULL; 111 | response = MHD_create_response_from_buffer (strlen (url), 112 | (void *) url, 113 | MHD_RESPMEM_MUST_COPY); 114 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 115 | MHD_destroy_response (response); 116 | if (ret == MHD_NO) 117 | abort (); 118 | return ret; 119 | } 120 | 121 | 122 | static int 123 | testInternalGet (int poll_flag) 124 | { 125 | struct MHD_Daemon *d; 126 | CURL *c; 127 | char buf[2048]; 128 | struct CBC cbc; 129 | CURLcode errornum; 130 | 131 | cbc.buf = buf; 132 | cbc.size = 2048; 133 | cbc.pos = 0; 134 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 135 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 136 | if (d == NULL) 137 | return 1; 138 | c = curl_easy_init (); 139 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11080/hello_world?a=b&c=&d"); 140 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 141 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 142 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 143 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 144 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); 145 | if (oneone) 146 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 147 | else 148 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 149 | /* NOTE: use of CONNECTTIMEOUT without also 150 | setting NOSIGNAL results in really weird 151 | crashes on my system!*/ 152 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); 153 | if (CURLE_OK != (errornum = curl_easy_perform (c))) 154 | { 155 | fprintf (stderr, 156 | "curl_easy_perform failed: `%s'\n", 157 | curl_easy_strerror (errornum)); 158 | curl_easy_cleanup (c); 159 | MHD_stop_daemon (d); 160 | return 2; 161 | } 162 | curl_easy_cleanup (c); 163 | MHD_stop_daemon (d); 164 | if (cbc.pos != strlen ("/hello_world")) 165 | return 4; 166 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 167 | return 8; 168 | if (matches != 7) 169 | return 16; 170 | return 0; 171 | } 172 | 173 | 174 | int 175 | main (int argc, char *const *argv) 176 | { 177 | unsigned int errorCount = 0; 178 | 179 | oneone = NULL != strstr (argv[0], "11"); 180 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 181 | return 2; 182 | errorCount += testInternalGet (0); 183 | if (errorCount != 0) 184 | fprintf (stderr, "Error (code: %u)\n", errorCount); 185 | curl_global_cleanup (); 186 | return errorCount != 0; /* 0 == pass */ 187 | } 188 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/gauger.h: -------------------------------------------------------------------------------- 1 | /** --------------------------------------------------------------------------- 2 | * This software is in the public domain, furnished "as is", without technical 3 | * support, and with no warranty, express or implied, as to its usefulness for 4 | * any purpose. 5 | * 6 | * gauger.h 7 | * Interface for C programs to log remotely to a gauger server 8 | * 9 | * Author: Bartlomiej Polot 10 | * -------------------------------------------------------------------------*/ 11 | #ifndef __GAUGER_H__ 12 | #define __GAUGER_H__ 13 | 14 | #ifndef WINDOWS 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #define GAUGER(category, counter, value, unit)\ 21 | {\ 22 | const char * __gauger_v[10]; \ 23 | char __gauger_s[32];\ 24 | pid_t __gauger_p;\ 25 | if(!(__gauger_p=fork())){\ 26 | if(!fork()){ \ 27 | sprintf(__gauger_s,"%Lf", (long double) (value));\ 28 | __gauger_v[0] = "gauger";\ 29 | __gauger_v[1] = "-n";\ 30 | __gauger_v[2] = counter; \ 31 | __gauger_v[3] = "-d";\ 32 | __gauger_v[4] = __gauger_s;\ 33 | __gauger_v[5] = "-u";\ 34 | __gauger_v[6] = unit; \ 35 | __gauger_v[7] = "-c";\ 36 | __gauger_v[8] = category; \ 37 | __gauger_v[9] = (char *)NULL;\ 38 | execvp("gauger", (char*const*) __gauger_v); \ 39 | _exit(1);\ 40 | }else{\ 41 | _exit(0);\ 42 | }\ 43 | }else{\ 44 | waitpid(__gauger_p,NULL,0);\ 45 | }\ 46 | } 47 | 48 | #define GAUGER_ID(category, counter, value, unit, id)\ 49 | {\ 50 | char* __gauger_v[12];\ 51 | char __gauger_s[32];\ 52 | pid_t __gauger_p;\ 53 | if(!(__gauger_p=fork())){\ 54 | if(!fork()){\ 55 | sprintf(__gauger_s,"%Lf", (long double) (value));\ 56 | __gauger_v[0] = "gauger";\ 57 | __gauger_v[1] = "-n";\ 58 | __gauger_v[2] = counter;\ 59 | __gauger_v[3] = "-d";\ 60 | __gauger_v[4] = __gauger_s;\ 61 | __gauger_v[5] = "-u";\ 62 | __gauger_v[6] = unit;\ 63 | __gauger_v[7] = "-i";\ 64 | __gauger_v[8] = id;\ 65 | __gauger_v[9] = "-c";\ 66 | __gauger_v[10] = category;\ 67 | __gauger_v[11] = (char *)NULL;\ 68 | execvp("gauger",__gauger_v);\ 69 | perror("gauger");\ 70 | _exit(1);\ 71 | }else{\ 72 | _exit(0);\ 73 | }\ 74 | }else{\ 75 | waitpid(__gauger_p,NULL,0);\ 76 | }\ 77 | } 78 | 79 | #else 80 | 81 | #define GAUGER_ID(category, counter, value, unit, id) {} 82 | #define GAUGER(category, counter, value, unit) {} 83 | 84 | #endif // WINDOWS 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = . 2 | 3 | if USE_COVERAGE 4 | AM_CFLAGS = --coverage 5 | endif 6 | 7 | if USE_PRIVATE_PLIBC_H 8 | PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc 9 | endif 10 | 11 | AM_CPPFLAGS = \ 12 | $(PLIBC_INCLUDE) \ 13 | -I$(top_srcdir)/src/include \ 14 | -I$(top_srcdir)/src/daemon \ 15 | $(LIBCURL_CPPFLAGS) 16 | 17 | check_PROGRAMS = \ 18 | tls_daemon_options_test \ 19 | tls_authentication_test \ 20 | mhds_multi_daemon_test \ 21 | mhds_get_test \ 22 | mhds_get_test_select \ 23 | mhds_session_info_test \ 24 | tls_thread_mode_test \ 25 | tls_multi_thread_mode_test \ 26 | tls_session_time_out_test 27 | 28 | EXTRA_DIST = cert.pem key.pem tls_test_keys.h tls_test_common.h 29 | 30 | # tls_authentication_test currently fails for unknown reasons 31 | TESTS = \ 32 | tls_daemon_options_test \ 33 | mhds_multi_daemon_test \ 34 | mhds_get_test \ 35 | mhds_get_test_select \ 36 | mhds_session_info_test \ 37 | tls_thread_mode_test \ 38 | tls_multi_thread_mode_test \ 39 | tls_session_time_out_test \ 40 | tls_authentication_test 41 | 42 | # cURL dependent tests 43 | tls_session_time_out_test_SOURCES = \ 44 | tls_session_time_out_test.c \ 45 | tls_test_common.c 46 | tls_session_time_out_test_LDADD = \ 47 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 48 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 49 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 50 | 51 | tls_daemon_options_test_SOURCES = \ 52 | tls_daemon_options_test.c \ 53 | tls_test_common.c 54 | tls_daemon_options_test_LDADD = \ 55 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 56 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 57 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 58 | 59 | tls_thread_mode_test_SOURCES = \ 60 | tls_thread_mode_test.c \ 61 | tls_test_common.c 62 | tls_thread_mode_test_LDADD = \ 63 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 64 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 65 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 66 | 67 | tls_multi_thread_mode_test_SOURCES = \ 68 | tls_multi_thread_mode_test.c \ 69 | tls_test_common.c 70 | tls_multi_thread_mode_test_LDADD = \ 71 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 72 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 73 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 74 | 75 | tls_authentication_test_SOURCES = \ 76 | tls_authentication_test.c \ 77 | tls_test_common.c 78 | tls_authentication_test_LDADD = \ 79 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 80 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 81 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 82 | 83 | mhds_session_info_test_SOURCES = \ 84 | mhds_session_info_test.c \ 85 | tls_test_common.c 86 | mhds_session_info_test_LDADD = \ 87 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 88 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 89 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 90 | 91 | mhds_multi_daemon_test_SOURCES = \ 92 | mhds_multi_daemon_test.c \ 93 | tls_test_common.c 94 | mhds_multi_daemon_test_LDADD = \ 95 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 96 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 97 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 98 | 99 | mhds_get_test_SOURCES = \ 100 | mhds_get_test.c \ 101 | tls_test_common.c 102 | mhds_get_test_LDADD = \ 103 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 104 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 105 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 106 | 107 | 108 | mhds_get_test_select_SOURCES = \ 109 | mhds_get_test_select.c \ 110 | tls_test_common.c 111 | mhds_get_test_select_LDADD = \ 112 | $(top_builddir)/src/testcurl/libcurl_version_check.a \ 113 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 114 | @LIBCURL@ -lgnutls @LIBGCRYPT_LIBS@ 115 | 116 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICpjCCAZCgAwIBAgIESEPtjjALBgkqhkiG9w0BAQUwADAeFw0wODA2MDIxMjU0 3 | MzhaFw0wOTA2MDIxMjU0NDZaMAAwggEfMAsGCSqGSIb3DQEBAQOCAQ4AMIIBCQKC 4 | AQC03TyUvK5HmUAirRp067taIEO4bibh5nqolUoUdo/LeblMQV+qnrv/RNAMTx5X 5 | fNLZ45/kbM9geF8qY0vsPyQvP4jumzK0LOJYuIwmHaUm9vbXnYieILiwCuTgjaud 6 | 3VkZDoQ9fteIo+6we9UTpVqZpxpbLulBMh/VsvX0cPJ1VFC7rT59o9hAUlFf9jX/ 7 | GmKdYI79MtgVx0OPBjmmSD6kicBBfmfgkO7bIGwlRtsIyMznxbHu6VuoX/eVxrTv 8 | rmCwgEXLWRZ6ru8MQl5YfqeGXXRVwMeXU961KefbuvmEPccgCxm8FZ1C1cnDHFXh 9 | siSgAzMBjC/b6KVhNQ4KnUdZAgMBAAGjLzAtMAwGA1UdEwEB/wQCMAAwHQYDVR0O 10 | BBYEFJcUvpjvE5fF/yzUshkWDpdYiQh/MAsGCSqGSIb3DQEBBQOCAQEARP7eKSB2 11 | RNd6XjEjK0SrxtoTnxS3nw9sfcS7/qD1+XHdObtDFqGNSjGYFB3Gpx8fpQhCXdoN 12 | 8QUs3/5ZVa5yjZMQewWBgz8kNbnbH40F2y81MHITxxCe1Y+qqHWwVaYLsiOTqj2/ 13 | 0S3QjEJ9tvklmg7JX09HC4m5QRYfWBeQLD1u8ZjA1Sf1xJriomFVyRLI2VPO2bNe 14 | JDMXWuP+8kMC7gEvUnJ7A92Y2yrhu3QI3bjPk8uSpHea19Q77tul1UVBJ5g+zpH3 15 | OsF5p0MyaVf09GTzcLds5nE/osTdXGUyHJapWReVmPm3Zn6gqYlnzD99z+DPIgIV 16 | RhZvQx74NQnS6g== 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAtN08lLyuR5lAIq0adOu7WiBDuG4m4eZ6qJVKFHaPy3m5TEFf 3 | qp67/0TQDE8eV3zS2eOf5GzPYHhfKmNL7D8kLz+I7psytCziWLiMJh2lJvb2152I 4 | niC4sArk4I2rnd1ZGQ6EPX7XiKPusHvVE6VamacaWy7pQTIf1bL19HDydVRQu60+ 5 | faPYQFJRX/Y1/xpinWCO/TLYFcdDjwY5pkg+pInAQX5n4JDu2yBsJUbbCMjM58Wx 6 | 7ulbqF/3lca0765gsIBFy1kWeq7vDEJeWH6nhl10VcDHl1PetSnn27r5hD3HIAsZ 7 | vBWdQtXJwxxV4bIkoAMzAYwv2+ilYTUOCp1HWQIDAQABAoIBAArOQv3R7gmqDspj 8 | lDaTFOz0C4e70QfjGMX0sWnakYnDGn6DU19iv3GnX1S072ejtgc9kcJ4e8VUO79R 9 | EmqpdRR7k8dJr3RTUCyjzf/C+qiCzcmhCFYGN3KRHA6MeEnkvRuBogX4i5EG1k5l 10 | /5t+YBTZBnqXKWlzQLKoUAiMLPg0eRWh+6q7H4N7kdWWBmTpako7TEqpIwuEnPGx 11 | u3EPuTR+LN6lF55WBePbCHccUHUQaXuav18NuDkcJmCiMArK9SKb+h0RqLD6oMI/ 12 | dKD6n8cZXeMBkK+C8U/K0sN2hFHACsu30b9XfdnljgP9v+BP8GhnB0nCB6tNBCPo 13 | 32srOwECgYEAxWh3iBT4lWqL6bZavVbnhmvtif4nHv2t2/hOs/CAq8iLAw0oWGZc 14 | +JEZTUDMvFRlulr0kcaWra+4fN3OmJnjeuFXZq52lfMgXBIKBmoSaZpIh2aDY1Rd 15 | RbEse7nQl9hTEPmYspiXLGtnAXW7HuWqVfFFP3ya8rUS3t4d07Hig8ECgYEA6ou6 16 | OHiBRTbtDqLIv8NghARc/AqwNWgEc9PelCPe5bdCOLBEyFjqKiT2MttnSSUc2Zob 17 | XhYkHC6zN1Mlq30N0e3Q61YK9LxMdU1vsluXxNq2rfK1Scb1oOlOOtlbV3zA3VRF 18 | hV3t1nOA9tFmUrwZi0CUMWJE/zbPAyhwWotKyZkCgYEAh0kFicPdbABdrCglXVae 19 | SnfSjVwYkVuGd5Ze0WADvjYsVkYBHTvhgRNnRJMg+/vWz3Sf4Ps4rgUbqK8Vc20b 20 | AU5G6H6tlCvPRGm0ZxrwTWDHTcuKRVs+pJE8C/qWoklE/AAhjluWVoGwUMbPGuiH 21 | 6Gf1bgHF6oj/Sq7rv/VLZ8ECgYBeq7ml05YyLuJutuwa4yzQ/MXfghzv4aVyb0F3 22 | QCdXR6o2IYgR6jnSewrZKlA9aPqFJrwHNR6sNXlnSmt5Fcf/RWO/qgJQGLUv3+rG 23 | 7kuLTNDR05azSdiZc7J89ID3Bkb+z2YkV+6JUiPq/Ei1+nDBEXb/m+/HqALU/nyj 24 | P3gXeQKBgBusb8Rbd+KgxSA0hwY6aoRTPRt8LNvXdsB9vRcKKHUFQvxUWiUSS+L9 25 | /Qu1sJbrUquKOHqksV5wCnWnAKyJNJlhHuBToqQTgKXjuNmVdYSe631saiI7PHyC 26 | eRJ6DxULPxABytJrYCRrNqmXi5TCiqR2mtfalEMOPxz8rUU8dYyx 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/mhds_get_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file mhds_get_test.c 23 | * @brief Testcase for libmicrohttpd HTTPS GET operations 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "tls_test_common.h" 34 | 35 | extern const char srv_key_pem[]; 36 | extern const char srv_self_signed_cert_pem[]; 37 | extern const char srv_signed_cert_pem[]; 38 | extern const char srv_signed_key_pem[]; 39 | 40 | static int 41 | test_cipher_option (FILE * test_fd, char *cipher_suite, int proto_version) 42 | { 43 | 44 | int ret; 45 | struct MHD_Daemon *d; 46 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 47 | MHD_USE_DEBUG, 4233, 48 | NULL, NULL, &http_ahc, NULL, 49 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 50 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 51 | MHD_OPTION_END); 52 | 53 | if (d == NULL) 54 | { 55 | fprintf (stderr, MHD_E_SERVER_INIT); 56 | return -1; 57 | } 58 | 59 | ret = test_https_transfer (test_fd, cipher_suite, proto_version); 60 | 61 | MHD_stop_daemon (d); 62 | return ret; 63 | } 64 | 65 | /* perform a HTTP GET request via SSL/TLS */ 66 | int 67 | test_secure_get (FILE * test_fd, char *cipher_suite, int proto_version) 68 | { 69 | int ret; 70 | struct MHD_Daemon *d; 71 | 72 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 73 | MHD_USE_DEBUG, 4233, 74 | NULL, NULL, &http_ahc, NULL, 75 | MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, 76 | MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, 77 | MHD_OPTION_END); 78 | 79 | if (d == NULL) 80 | { 81 | fprintf (stderr, MHD_E_SERVER_INIT); 82 | return -1; 83 | } 84 | 85 | ret = test_https_transfer (test_fd, cipher_suite, proto_version); 86 | 87 | MHD_stop_daemon (d); 88 | return ret; 89 | } 90 | 91 | int 92 | main (int argc, char *const *argv) 93 | { 94 | unsigned int errorCount = 0; 95 | 96 | if (!gcry_check_version (GCRYPT_VERSION)) 97 | abort (); 98 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) 99 | { 100 | fprintf (stderr, "Error: %s\n", strerror (errno)); 101 | return -1; 102 | } 103 | 104 | char *aes256_sha_tlsv1 = "AES256-SHA"; 105 | char *aes256_sha_sslv3 = "AES256-SHA"; 106 | char *des_cbc3_sha_tlsv1 = "DES-CBC3-SHA"; 107 | 108 | if (curl_uses_nss_ssl() == 0) 109 | { 110 | aes256_sha_tlsv1 = "rsa_aes_256_sha"; 111 | aes256_sha_sslv3 = "rsa_aes_256_sha"; 112 | des_cbc3_sha_tlsv1 = "rsa_aes_128_sha"; 113 | } 114 | 115 | errorCount += 116 | test_secure_get (NULL, aes256_sha_tlsv1, CURL_SSLVERSION_TLSv1); 117 | errorCount += 118 | test_secure_get (NULL, aes256_sha_sslv3, CURL_SSLVERSION_SSLv3); 119 | errorCount += 120 | test_cipher_option (NULL, des_cbc3_sha_tlsv1, CURL_SSLVERSION_TLSv1); 121 | 122 | print_test_result (errorCount, argv[0]); 123 | 124 | curl_global_cleanup (); 125 | 126 | return errorCount != 0; 127 | } 128 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/mhds_multi_daemon_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file mhds_multi_daemon_test.c 23 | * @brief Testcase for libmicrohttpd multiple HTTPS daemon scenario 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | #include 30 | #include 31 | #include 32 | 33 | #include "tls_test_common.h" 34 | 35 | extern int curl_check_version (const char *req_version, ...); 36 | extern const char srv_key_pem[]; 37 | extern const char srv_self_signed_cert_pem[]; 38 | 39 | /* 40 | * assert initiating two separate daemons and having one shut down 41 | * doesn't affect the other 42 | */ 43 | int 44 | test_concurent_daemon_pair (void * cls, char *cipher_suite, 45 | int proto_version) 46 | { 47 | 48 | int ret; 49 | struct MHD_Daemon *d1; 50 | struct MHD_Daemon *d2; 51 | d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 52 | MHD_USE_DEBUG, DEAMON_TEST_PORT, 53 | NULL, NULL, &http_ahc, NULL, 54 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 55 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 56 | MHD_OPTION_END); 57 | 58 | if (d1 == NULL) 59 | { 60 | fprintf (stderr, MHD_E_SERVER_INIT); 61 | return -1; 62 | } 63 | 64 | d2 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 65 | MHD_USE_DEBUG, DEAMON_TEST_PORT + 1, 66 | NULL, NULL, &http_ahc, NULL, 67 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 68 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 69 | MHD_OPTION_END); 70 | 71 | if (d2 == NULL) 72 | { 73 | MHD_stop_daemon (d1); 74 | fprintf (stderr, MHD_E_SERVER_INIT); 75 | return -1; 76 | } 77 | 78 | ret = 79 | test_daemon_get (NULL, cipher_suite, proto_version, DEAMON_TEST_PORT, 0); 80 | ret += 81 | test_daemon_get (NULL, cipher_suite, proto_version, 82 | DEAMON_TEST_PORT + 1, 0); 83 | 84 | MHD_stop_daemon (d2); 85 | ret += 86 | test_daemon_get (NULL, cipher_suite, proto_version, DEAMON_TEST_PORT, 0); 87 | MHD_stop_daemon (d1); 88 | return ret; 89 | } 90 | 91 | int 92 | main (int argc, char *const *argv) 93 | { 94 | unsigned int errorCount = 0; 95 | FILE *cert; 96 | 97 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) 98 | { 99 | fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__, 100 | __FUNCTION__); 101 | return -1; 102 | } 103 | if ((cert = setup_ca_cert ()) == NULL) 104 | { 105 | fprintf (stderr, MHD_E_TEST_FILE_CREAT); 106 | return -1; 107 | } 108 | 109 | char *aes256_sha = "AES256-SHA"; 110 | if (curl_uses_nss_ssl() == 0) 111 | { 112 | aes256_sha = "rsa_aes_256_sha"; 113 | } 114 | 115 | errorCount += 116 | test_concurent_daemon_pair (NULL, aes256_sha, CURL_SSLVERSION_SSLv3); 117 | 118 | print_test_result (errorCount, "concurent_daemon_pair"); 119 | 120 | curl_global_cleanup (); 121 | fclose (cert); 122 | remove (ca_cert_file_name); 123 | return errorCount != 0; 124 | } 125 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/mhds_session_info_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file mhds_session_info_test.c 23 | * @brief Testcase for libmicrohttpd HTTPS connection querying operations 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | #include 30 | 31 | #include "tls_test_common.h" 32 | 33 | extern int curl_check_version (const char *req_version, ...); 34 | extern const char srv_key_pem[]; 35 | extern const char srv_self_signed_cert_pem[]; 36 | 37 | struct MHD_Daemon *d; 38 | 39 | /* 40 | * HTTP access handler call back 41 | * used to query negotiated security parameters 42 | */ 43 | static int 44 | query_session_ahc (void *cls, struct MHD_Connection *connection, 45 | const char *url, const char *method, 46 | const char *upload_data, const char *version, 47 | size_t *upload_data_size, void **ptr) 48 | { 49 | struct MHD_Response *response; 50 | int ret; 51 | 52 | if (NULL == *ptr) 53 | { 54 | *ptr = &query_session_ahc; 55 | return MHD_YES; 56 | } 57 | 58 | if (GNUTLS_SSL3 != 59 | (ret = MHD_get_connection_info 60 | (connection, 61 | MHD_CONNECTION_INFO_PROTOCOL)->protocol)) 62 | { 63 | fprintf (stderr, "Error: requested protocol mismatch (wanted %d, got %d)\n", 64 | GNUTLS_SSL3, 65 | ret); 66 | return -1; 67 | } 68 | 69 | response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE), 70 | (void *) EMPTY_PAGE, 71 | MHD_RESPMEM_PERSISTENT); 72 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 73 | MHD_destroy_response (response); 74 | return ret; 75 | } 76 | 77 | 78 | /** 79 | * negotiate a secure connection with server & query negotiated security parameters 80 | */ 81 | static int 82 | test_query_session () 83 | { 84 | CURL *c; 85 | struct CBC cbc; 86 | CURLcode errornum; 87 | char url[256]; 88 | 89 | if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) 90 | return 16; 91 | cbc.size = 255; 92 | cbc.pos = 0; 93 | 94 | gen_test_file_url (url, DEAMON_TEST_PORT); 95 | 96 | /* setup test */ 97 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 98 | MHD_USE_DEBUG, DEAMON_TEST_PORT, 99 | NULL, NULL, &query_session_ahc, NULL, 100 | MHD_OPTION_HTTPS_PRIORITIES, "NORMAL:+ARCFOUR-128", 101 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 102 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 103 | MHD_OPTION_END); 104 | 105 | if (d == NULL) 106 | return 2; 107 | 108 | const char *aes256_sha = "AES256-SHA"; 109 | if (curl_uses_nss_ssl() == 0) 110 | { 111 | aes256_sha = "rsa_aes_256_sha"; 112 | } 113 | 114 | c = curl_easy_init (); 115 | #if DEBUG_HTTPS_TEST 116 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1); 117 | #endif 118 | curl_easy_setopt (c, CURLOPT_URL, url); 119 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 120 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L); 121 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L); 122 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 123 | curl_easy_setopt (c, CURLOPT_FILE, &cbc); 124 | /* TLS options */ 125 | curl_easy_setopt (c, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3); 126 | curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST, aes256_sha); 127 | /* currently skip any peer authentication */ 128 | curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0); 129 | curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0); 130 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 131 | 132 | // NOTE: use of CONNECTTIMEOUT without also 133 | // setting NOSIGNAL results in really weird 134 | // crashes on my system! 135 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); 136 | if (CURLE_OK != (errornum = curl_easy_perform (c))) 137 | { 138 | fprintf (stderr, "curl_easy_perform failed: `%s'\n", 139 | curl_easy_strerror (errornum)); 140 | 141 | MHD_stop_daemon (d); 142 | curl_easy_cleanup (c); 143 | free (cbc.buf); 144 | return -1; 145 | } 146 | 147 | curl_easy_cleanup (c); 148 | MHD_stop_daemon (d); 149 | free (cbc.buf); 150 | return 0; 151 | } 152 | 153 | 154 | int 155 | main (int argc, char *const *argv) 156 | { 157 | unsigned int errorCount = 0; 158 | 159 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) 160 | { 161 | fprintf (stderr, "Error (code: %u)\n", errorCount); 162 | return -1; 163 | } 164 | errorCount += test_query_session (); 165 | print_test_result (errorCount, argv[0]); 166 | curl_global_cleanup (); 167 | if (errorCount > 0) 168 | fprintf (stderr, "Error (code: %u)\n", errorCount); 169 | return errorCount; 170 | } 171 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/tls_authentication_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file tls_authentication_test.c 23 | * @brief Testcase for libmicrohttpd HTTPS GET operations 24 | * @author Sagie Amir 25 | */ 26 | 27 | #include "platform.h" 28 | #include "microhttpd.h" 29 | #include 30 | #include 31 | #include 32 | 33 | #include "tls_test_common.h" 34 | 35 | extern int curl_check_version (const char *req_version, ...); 36 | extern const char test_file_data[]; 37 | 38 | extern const char ca_key_pem[]; 39 | extern const char ca_cert_pem[]; 40 | extern const char srv_signed_cert_pem[]; 41 | extern const char srv_signed_key_pem[]; 42 | 43 | 44 | 45 | /* perform a HTTP GET request via SSL/TLS */ 46 | static int 47 | test_secure_get (void * cls, char *cipher_suite, int proto_version) 48 | { 49 | int ret; 50 | struct MHD_Daemon *d; 51 | 52 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 53 | MHD_USE_DEBUG, DEAMON_TEST_PORT, 54 | NULL, NULL, &http_ahc, NULL, 55 | MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, 56 | MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, 57 | MHD_OPTION_END); 58 | 59 | if (d == NULL) 60 | { 61 | fprintf (stderr, MHD_E_SERVER_INIT); 62 | return -1; 63 | } 64 | 65 | ret = test_daemon_get (NULL, cipher_suite, proto_version, DEAMON_TEST_PORT, 0); 66 | 67 | MHD_stop_daemon (d); 68 | return ret; 69 | } 70 | 71 | 72 | int 73 | main (int argc, char *const *argv) 74 | { 75 | unsigned int errorCount = 0; 76 | 77 | if (setup_ca_cert () == NULL) 78 | { 79 | fprintf (stderr, MHD_E_TEST_FILE_CREAT); 80 | return -1; 81 | } 82 | 83 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) 84 | { 85 | fprintf (stderr, "Error (code: %u)\n", errorCount); 86 | return -1; 87 | } 88 | 89 | char *aes256_sha = "AES256-SHA"; 90 | if (curl_uses_nss_ssl() == 0) 91 | { 92 | aes256_sha = "rsa_aes_256_sha"; 93 | } 94 | 95 | errorCount += 96 | test_secure_get (NULL, aes256_sha, CURL_SSLVERSION_TLSv1); 97 | 98 | print_test_result (errorCount, argv[0]); 99 | 100 | curl_global_cleanup (); 101 | remove (ca_cert_file_name); 102 | return errorCount != 0; 103 | } 104 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/tls_session_time_out_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file mhds_get_test.c 23 | * @brief: daemon TLS alert response test-case 24 | * 25 | * @author Sagie Amir 26 | */ 27 | 28 | #include "platform.h" 29 | #include "microhttpd.h" 30 | #include "internal.h" 31 | #include "tls_test_common.h" 32 | 33 | extern const char srv_key_pem[]; 34 | extern const char srv_self_signed_cert_pem[]; 35 | 36 | static const int TIME_OUT = 3; 37 | 38 | char *http_get_req = "GET / HTTP/1.1\r\n\r\n"; 39 | 40 | static int 41 | test_tls_session_time_out (gnutls_session_t session) 42 | { 43 | int sd, ret; 44 | struct sockaddr_in sa; 45 | 46 | sd = socket (AF_INET, SOCK_STREAM, 0); 47 | if (sd == -1) 48 | { 49 | fprintf (stderr, "Failed to create socket: %s\n", strerror (errno)); 50 | return -1; 51 | } 52 | 53 | memset (&sa, '\0', sizeof (struct sockaddr_in)); 54 | sa.sin_family = AF_INET; 55 | sa.sin_port = htons (DEAMON_TEST_PORT); 56 | inet_pton (AF_INET, "127.0.0.1", &sa.sin_addr); 57 | 58 | gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (long) sd); 59 | 60 | ret = connect (sd, &sa, sizeof (struct sockaddr_in)); 61 | 62 | if (ret < 0) 63 | { 64 | fprintf (stderr, "Error: %s\n", MHD_E_FAILED_TO_CONNECT); 65 | return -1; 66 | } 67 | 68 | ret = gnutls_handshake (session); 69 | if (ret < 0) 70 | { 71 | fprintf (stderr, "Handshake failed\n"); 72 | return -1; 73 | } 74 | 75 | sleep (TIME_OUT + 1); 76 | 77 | /* check that server has closed the connection */ 78 | /* TODO better RST trigger */ 79 | if (send (sd, "", 1, 0) == 0) 80 | { 81 | fprintf (stderr, "Connection failed to time-out\n"); 82 | return -1; 83 | } 84 | 85 | close (sd); 86 | return 0; 87 | } 88 | 89 | int 90 | main (int argc, char *const *argv) 91 | { 92 | int errorCount = 0;; 93 | struct MHD_Daemon *d; 94 | gnutls_session_t session; 95 | gnutls_datum_t key; 96 | gnutls_datum_t cert; 97 | gnutls_certificate_credentials_t xcred; 98 | 99 | gnutls_global_init (); 100 | gnutls_global_set_log_level (11); 101 | 102 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 103 | MHD_USE_DEBUG, DEAMON_TEST_PORT, 104 | NULL, NULL, &http_dummy_ahc, NULL, 105 | MHD_OPTION_CONNECTION_TIMEOUT, TIME_OUT, 106 | MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 107 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 108 | MHD_OPTION_END); 109 | 110 | if (d == NULL) 111 | { 112 | fprintf (stderr, MHD_E_SERVER_INIT); 113 | return -1; 114 | } 115 | 116 | if (0 != setup_session (&session, &key, &cert, &xcred)) 117 | { 118 | fprintf (stderr, "failed to setup session\n"); 119 | return 1; 120 | } 121 | errorCount += test_tls_session_time_out (session); 122 | teardown_session (session, &key, &cert, xcred); 123 | 124 | print_test_result (errorCount, argv[0]); 125 | 126 | MHD_stop_daemon (d); 127 | gnutls_global_deinit (); 128 | 129 | return errorCount != 0; 130 | } 131 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/tls_test_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef TLS_TEST_COMMON_H_ 22 | #define TLS_TEST_COMMON_H_ 23 | 24 | #include "platform.h" 25 | #include "microhttpd.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /* this enables verbos CURL version checking */ 32 | #define DEBUG_HTTPS_TEST 0 33 | #define CURL_VERBOS_LEVEL 0 34 | 35 | #define DEAMON_TEST_PORT 4233 36 | 37 | #define test_data "Hello World\n" 38 | #define ca_cert_file_name "tmp_ca_cert.pem" 39 | 40 | #define EMPTY_PAGE "Empty pageEmpty page" 41 | #define PAGE_NOT_FOUND "File not foundFile not found" 42 | 43 | #define MHD_E_MEM "Error: memory error\n" 44 | #define MHD_E_SERVER_INIT "Error: failed to start server\n" 45 | #define MHD_E_TEST_FILE_CREAT "Error: failed to setup test file\n" 46 | #define MHD_E_CERT_FILE_CREAT "Error: failed to setup test certificate\n" 47 | #define MHD_E_KEY_FILE_CREAT "Error: failed to setup test certificate\n" 48 | #define MHD_E_FAILED_TO_CONNECT "Error: server connection could not be established\n" 49 | 50 | /* TODO rm if unused */ 51 | struct https_test_data 52 | { 53 | void *cls; 54 | const char *cipher_suite; 55 | int proto_version; 56 | }; 57 | 58 | struct CBC 59 | { 60 | char *buf; 61 | size_t pos; 62 | size_t size; 63 | }; 64 | 65 | struct CipherDef 66 | { 67 | int options[2]; 68 | char *curlname; 69 | }; 70 | 71 | 72 | int curl_check_version (const char *req_version, ...); 73 | int curl_uses_nss_ssl (); 74 | 75 | 76 | FILE * 77 | setup_ca_cert (); 78 | 79 | /** 80 | * perform cURL request for file 81 | */ 82 | int 83 | test_daemon_get (void * cls, char *cipher_suite, int proto_version, 84 | int port, int ver_peer); 85 | 86 | void print_test_result (int test_outcome, char *test_name); 87 | 88 | size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); 89 | 90 | int 91 | http_ahc (void *cls, struct MHD_Connection *connection, 92 | const char *url, const char *method, const char *upload_data, 93 | const char *version, size_t *upload_data_size, void **ptr); 94 | 95 | int 96 | http_dummy_ahc (void *cls, struct MHD_Connection *connection, 97 | const char *url, const char *method, const char *upload_data, 98 | const char *version, size_t *upload_data_size, 99 | void **ptr); 100 | 101 | int gen_test_file_url (char *url, int port); 102 | 103 | int 104 | send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite, 105 | int proto_version); 106 | 107 | int 108 | test_https_transfer (void *cls, const char *cipher_suite, int proto_version); 109 | 110 | int 111 | setup_testcase (struct MHD_Daemon **d, int daemon_flags, va_list arg_list); 112 | 113 | void teardown_testcase (struct MHD_Daemon *d); 114 | 115 | int 116 | setup_session (gnutls_session_t * session, 117 | gnutls_datum_t * key, 118 | gnutls_datum_t * cert, 119 | gnutls_certificate_credentials_t * xcred); 120 | 121 | int 122 | teardown_session (gnutls_session_t session, 123 | gnutls_datum_t * key, 124 | gnutls_datum_t * cert, 125 | gnutls_certificate_credentials_t xcred); 126 | 127 | int 128 | test_wrap (const char *test_name, int 129 | (*test_function) (void * cls, const char *cipher_suite, 130 | int proto_version), void *test_function_cls, 131 | int daemon_flags, const char *cipher_suite, int proto_version, ...); 132 | #endif /* TLS_TEST_COMMON_H_ */ 133 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/https/tls_thread_mode_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file tls_thread_mode_test.c 23 | * @brief Testcase for libmicrohttpd HTTPS GET operations 24 | * @author Sagie Amir 25 | * @author Christian Grothoff 26 | * 27 | * TODO: add test for external select! 28 | */ 29 | 30 | #include "platform.h" 31 | #include "microhttpd.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "tls_test_common.h" 37 | 38 | extern const char srv_key_pem[]; 39 | extern const char srv_self_signed_cert_pem[]; 40 | 41 | int curl_check_version (const char *req_version, ...); 42 | 43 | /** 44 | * used when spawning multiple threads executing curl server requests 45 | * 46 | */ 47 | static void * 48 | https_transfer_thread_adapter (void *args) 49 | { 50 | static int nonnull; 51 | struct https_test_data *cargs = args; 52 | int ret; 53 | 54 | /* time spread incomming requests */ 55 | usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX)); 56 | ret = test_https_transfer (NULL, 57 | cargs->cipher_suite, cargs->proto_version); 58 | if (ret == 0) 59 | return NULL; 60 | return &nonnull; 61 | } 62 | 63 | /** 64 | * Test non-parallel requests. 65 | * 66 | * @return: 0 upon all client requests returning '0', -1 otherwise. 67 | * 68 | * TODO : make client_count a parameter - numver of curl client threads to spawn 69 | */ 70 | static int 71 | test_single_client (void *cls, const char *cipher_suite, 72 | int curl_proto_version) 73 | { 74 | void *client_thread_ret; 75 | struct https_test_data client_args = 76 | { NULL, cipher_suite, curl_proto_version }; 77 | 78 | client_thread_ret = https_transfer_thread_adapter (&client_args); 79 | if (client_thread_ret != NULL) 80 | return -1; 81 | return 0; 82 | } 83 | 84 | /** 85 | * Test parallel request handling. 86 | * 87 | * @return: 0 upon all client requests returning '0', -1 otherwise. 88 | * 89 | * TODO : make client_count a parameter - numver of curl client threads to spawn 90 | */ 91 | static int 92 | test_parallel_clients (void * cls, const char *cipher_suite, 93 | int curl_proto_version) 94 | { 95 | int i; 96 | int client_count = 3; 97 | void *client_thread_ret; 98 | pthread_t client_arr[client_count]; 99 | struct https_test_data client_args = 100 | { NULL, cipher_suite, curl_proto_version }; 101 | 102 | for (i = 0; i < client_count; ++i) 103 | { 104 | if (pthread_create (&client_arr[i], NULL, 105 | &https_transfer_thread_adapter, &client_args) != 0) 106 | { 107 | fprintf (stderr, "Error: failed to spawn test client threads.\n"); 108 | return -1; 109 | } 110 | } 111 | 112 | /* check all client requests fulfilled correctly */ 113 | for (i = 0; i < client_count; ++i) 114 | { 115 | if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || 116 | (client_thread_ret != NULL)) 117 | return -1; 118 | } 119 | 120 | return 0; 121 | } 122 | 123 | GCRY_THREAD_OPTION_PTHREAD_IMPL; 124 | 125 | int 126 | main (int argc, char *const *argv) 127 | { 128 | unsigned int errorCount = 0; 129 | 130 | /* initialize random seed used by curl clients */ 131 | unsigned int iseed = (unsigned int) time (NULL); 132 | srand (iseed); 133 | gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); 134 | if (0 != curl_global_init (CURL_GLOBAL_ALL)) 135 | { 136 | fprintf (stderr, "Error: %s\n", strerror (errno)); 137 | return -1; 138 | } 139 | 140 | char *aes256_sha = "AES256-SHA"; 141 | if (curl_uses_nss_ssl() == 0) 142 | { 143 | aes256_sha = "rsa_aes_256_sha"; 144 | } 145 | 146 | errorCount += 147 | test_wrap ("single threaded daemon, single client", &test_single_client, 148 | NULL, 149 | MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, 150 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, 151 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, 152 | srv_self_signed_cert_pem, MHD_OPTION_END); 153 | 154 | errorCount += 155 | test_wrap ("single threaded daemon, parallel clients", 156 | &test_parallel_clients, NULL, 157 | MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, 158 | aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, 159 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, 160 | srv_self_signed_cert_pem, MHD_OPTION_END); 161 | 162 | curl_global_cleanup (); 163 | return errorCount != 0; 164 | } 165 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/test_callback.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2007, 2009, 2011 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file test_callback.c 23 | * @brief Testcase for MHD not calling the callback too often 24 | * @author Jan Seeger 25 | * @author Christian Grothoff 26 | */ 27 | 28 | 29 | #include "MHD_config.h" 30 | #include "platform.h" 31 | #include 32 | #include 33 | 34 | struct callback_closure { 35 | unsigned int called; 36 | }; 37 | 38 | 39 | static ssize_t 40 | called_twice(void *cls, uint64_t pos, char *buf, size_t max) 41 | { 42 | struct callback_closure *cls2 = cls; 43 | 44 | if (cls2->called == 0) 45 | { 46 | memset(buf, 0, max); 47 | strcat(buf, "test"); 48 | cls2->called = 1; 49 | return strlen(buf); 50 | } 51 | if (cls2->called == 1) 52 | { 53 | cls2->called = 2; 54 | return MHD_CONTENT_READER_END_OF_STREAM; 55 | } 56 | fprintf(stderr, 57 | "Handler called after returning END_OF_STREAM!\n"); 58 | return MHD_CONTENT_READER_END_WITH_ERROR; 59 | } 60 | 61 | 62 | static int 63 | callback(void *cls, struct MHD_Connection *connection, const char *url, 64 | const char *method, const char *version, const char *upload_data, 65 | size_t *upload_data_size, void **con_cls) { 66 | struct callback_closure *cbc = calloc(1, sizeof(struct callback_closure)); 67 | struct MHD_Response *r; 68 | 69 | r = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024, 70 | &called_twice, cbc, 71 | &free); 72 | MHD_queue_response(connection, 200, r); 73 | MHD_destroy_response(r); 74 | return MHD_YES; 75 | } 76 | 77 | 78 | static size_t 79 | discard_buffer (void *ptr, size_t size, size_t nmemb, void *ctx) 80 | { 81 | return size * nmemb; 82 | } 83 | 84 | 85 | int main(int argc, char **argv) 86 | { 87 | struct MHD_Daemon *d; 88 | fd_set rs; 89 | fd_set ws; 90 | fd_set es; 91 | int max; 92 | CURL *c; 93 | CURLM *multi; 94 | CURLMcode mret; 95 | struct CURLMsg *msg; 96 | int running; 97 | struct timeval tv; 98 | int extra; 99 | 100 | d = MHD_start_daemon(0, 101 | 8000, 102 | NULL, 103 | NULL, 104 | callback, 105 | NULL, 106 | MHD_OPTION_END); 107 | c = curl_easy_init (); 108 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:8000/"); 109 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &discard_buffer); 110 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 111 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 112 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 113 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); 114 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); 115 | multi = curl_multi_init (); 116 | if (multi == NULL) 117 | { 118 | curl_easy_cleanup (c); 119 | MHD_stop_daemon (d); 120 | return 1; 121 | } 122 | mret = curl_multi_add_handle (multi, c); 123 | if (mret != CURLM_OK) 124 | { 125 | curl_multi_cleanup (multi); 126 | curl_easy_cleanup (c); 127 | MHD_stop_daemon (d); 128 | return 2; 129 | } 130 | extra = 10; 131 | while ( (c != NULL) || (--extra > 0) ) 132 | { 133 | max = -1; 134 | FD_ZERO(&ws); 135 | FD_ZERO(&rs); 136 | FD_ZERO(&es); 137 | curl_multi_perform (multi, &running); 138 | if (NULL != multi) 139 | { 140 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); 141 | if (mret != CURLM_OK) 142 | { 143 | curl_multi_remove_handle (multi, c); 144 | curl_multi_cleanup (multi); 145 | curl_easy_cleanup (c); 146 | MHD_stop_daemon (d); 147 | return 3; 148 | } 149 | } 150 | if (MHD_YES != 151 | MHD_get_fdset(d, &rs, &ws, &es, &max)) 152 | { 153 | curl_multi_remove_handle (multi, c); 154 | curl_multi_cleanup (multi); 155 | curl_easy_cleanup (c); 156 | MHD_stop_daemon (d); 157 | return 4; 158 | } 159 | tv.tv_sec = 0; 160 | tv.tv_usec = 1000; 161 | select(max + 1, &rs, &ws, &es, &tv); 162 | if (NULL != multi) 163 | { 164 | curl_multi_perform (multi, &running); 165 | if (running == 0) 166 | { 167 | msg = curl_multi_info_read (multi, &running); 168 | if (msg == NULL) 169 | break; 170 | if (msg->msg == CURLMSG_DONE) 171 | { 172 | if (msg->data.result != CURLE_OK) 173 | printf ("%s failed at %s:%d: `%s'\n", 174 | "curl_multi_perform", 175 | __FILE__, 176 | __LINE__, curl_easy_strerror (msg->data.result)); 177 | curl_multi_remove_handle (multi, c); 178 | curl_multi_cleanup (multi); 179 | curl_easy_cleanup (c); 180 | c = NULL; 181 | multi = NULL; 182 | } 183 | } 184 | } 185 | MHD_run(d); 186 | } 187 | MHD_stop_daemon(d); 188 | return 0; 189 | } 190 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testcurl/test_start_stop.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2011 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file test_start_stop.c 23 | * @brief test for #1901 (start+stop) 24 | * @author Christian Grothoff 25 | */ 26 | #include "MHD_config.h" 27 | #include "platform.h" 28 | #include 29 | #include 30 | 31 | 32 | static int 33 | ahc_echo (void *cls, 34 | struct MHD_Connection *connection, 35 | const char *url, 36 | const char *method, 37 | const char *version, 38 | const char *upload_data, size_t *upload_data_size, 39 | void **unused) 40 | { 41 | return MHD_NO; 42 | } 43 | 44 | 45 | static int 46 | testInternalGet (int poll_flag) 47 | { 48 | struct MHD_Daemon *d; 49 | 50 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 51 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 52 | if (d == NULL) 53 | return 1; 54 | MHD_stop_daemon (d); 55 | return 0; 56 | } 57 | 58 | static int 59 | testMultithreadedGet (int poll_flag) 60 | { 61 | struct MHD_Daemon *d; 62 | 63 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 64 | 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 65 | if (d == NULL) 66 | return 2; 67 | MHD_stop_daemon (d); 68 | return 0; 69 | } 70 | 71 | static int 72 | testMultithreadedPoolGet (int poll_flag) 73 | { 74 | struct MHD_Daemon *d; 75 | 76 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 77 | 1081, NULL, NULL, &ahc_echo, "GET", 78 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); 79 | if (d == NULL) 80 | return 4; 81 | MHD_stop_daemon (d); 82 | return 0; 83 | } 84 | 85 | static int 86 | testExternalGet () 87 | { 88 | struct MHD_Daemon *d; 89 | 90 | d = MHD_start_daemon (MHD_USE_DEBUG, 91 | 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 92 | if (d == NULL) 93 | return 8; 94 | MHD_stop_daemon (d); 95 | return 0; 96 | } 97 | 98 | 99 | int 100 | main (int argc, char *const *argv) 101 | { 102 | unsigned int errorCount = 0; 103 | 104 | errorCount += testInternalGet (0); 105 | errorCount += testMultithreadedGet (0); 106 | errorCount += testMultithreadedPoolGet (0); 107 | errorCount += testExternalGet (); 108 | #if !WINDOWS 109 | errorCount += testInternalGet (MHD_USE_POLL); 110 | errorCount += testMultithreadedGet (MHD_USE_POLL); 111 | errorCount += testMultithreadedPoolGet (MHD_USE_POLL); 112 | #endif 113 | if (errorCount != 0) 114 | fprintf (stderr, "Error (code: %u)\n", errorCount); 115 | return errorCount != 0; /* 0 == pass */ 116 | } 117 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testzzuf/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = . 2 | 3 | if USE_COVERAGE 4 | AM_CFLAGS = -fprofile-arcs -ftest-coverage 5 | endif 6 | 7 | if USE_PRIVATE_PLIBC_H 8 | PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc 9 | endif 10 | 11 | INCLUDES = $(PLIBC_INCLUDE) -I$(top_srcdir)/src/include 12 | 13 | EXTRA_DIST = README socat.c 14 | 15 | check_PROGRAMS = \ 16 | daemontest_get \ 17 | daemontest_post \ 18 | daemontest_postform \ 19 | daemontest_put \ 20 | daemontest_large_put \ 21 | daemontest_get11 \ 22 | daemontest_post11 \ 23 | daemontest_postform11 \ 24 | daemontest_put11 \ 25 | daemontest_large_put11 \ 26 | daemontest_long_header \ 27 | daemontest_get_chunked \ 28 | daemontest_put_chunked 29 | 30 | TESTS = $(check_PROGRAMS) 31 | 32 | daemontest_get_SOURCES = \ 33 | daemontest_get.c 34 | daemontest_get_LDADD = \ 35 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 36 | @LIBCURL@ 37 | 38 | daemontest_get_chunked_SOURCES = \ 39 | daemontest_get_chunked.c 40 | daemontest_get_chunked_LDADD = \ 41 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 42 | @LIBCURL@ 43 | 44 | daemontest_post_SOURCES = \ 45 | daemontest_post.c 46 | daemontest_post_LDADD = \ 47 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 48 | @LIBCURL@ 49 | 50 | daemontest_postform_SOURCES = \ 51 | daemontest_postform.c 52 | daemontest_postform_LDADD = \ 53 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 54 | @LIBCURL@ 55 | 56 | daemontest_put_SOURCES = \ 57 | daemontest_put.c 58 | daemontest_put_LDADD = \ 59 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 60 | @LIBCURL@ 61 | 62 | daemontest_put_chunked_SOURCES = \ 63 | daemontest_put_chunked.c 64 | daemontest_put_chunked_LDADD = \ 65 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 66 | @LIBCURL@ 67 | 68 | daemontest_get11_SOURCES = \ 69 | daemontest_get.c 70 | daemontest_get11_LDADD = \ 71 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 72 | @LIBCURL@ 73 | 74 | daemontest_post11_SOURCES = \ 75 | daemontest_post.c 76 | daemontest_post11_LDADD = \ 77 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 78 | @LIBCURL@ 79 | 80 | daemontest_postform11_SOURCES = \ 81 | daemontest_postform.c 82 | daemontest_postform11_LDADD = \ 83 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 84 | @LIBCURL@ 85 | 86 | daemontest_put11_SOURCES = \ 87 | daemontest_put.c 88 | daemontest_put11_LDADD = \ 89 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 90 | @LIBCURL@ 91 | 92 | 93 | daemontest_large_put_SOURCES = \ 94 | daemontest_large_put.c 95 | daemontest_large_put_LDADD = \ 96 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 97 | @LIBCURL@ 98 | 99 | daemontest_large_put11_SOURCES = \ 100 | daemontest_large_put.c 101 | daemontest_large_put11_LDADD = \ 102 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 103 | @LIBCURL@ 104 | 105 | daemontest_long_header_SOURCES = \ 106 | daemontest_long_header.c 107 | daemontest_long_header_LDADD = \ 108 | $(top_builddir)/src/daemon/libmicrohttpd.la \ 109 | @LIBCURL@ 110 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testzzuf/README: -------------------------------------------------------------------------------- 1 | Testcases in this directory require zzuf and socat. 2 | 3 | zzuf is used to randomly mess with the TCP connection between the CURL 4 | clients and the MHD server. The goal is to expose problems in MHD's 5 | error handling (by introducing random syntax errors). socat is 6 | used to listen on port 11081 and forward the randomzied stream to 7 | port 11080 where MHD is waiting. 8 | 9 | As a result, the testcases in this directory do NOT check that 10 | whatever CURL returns is what was expected -- random modifications to 11 | the TCP stream can have random effects ;-). Testcases "fail" if the 12 | code crashes or hangs indefinitely. 13 | 14 | -------------------------------------------------------------------------------- /vendor/libmicrohttpd/src/testzzuf/socat.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of libmicrohttpd 3 | (C) 2008 Christian Grothoff 4 | 5 | libmicrohttpd is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 2, or (at your 8 | option) any later version. 9 | 10 | libmicrohttpd is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libmicrohttpd; see the file COPYING. If not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | /** 22 | * @file socat.c 23 | * @brief Code to fork-exec zzuf and start the socat process 24 | * @author Christian Grothoff 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | /** 34 | * A larger loop count will run more random tests -- 35 | * which would be good, except that it may take too 36 | * long for most user's patience. So this small 37 | * value is the default. 38 | */ 39 | #define LOOP_COUNT 10 40 | 41 | #define CURL_TIMEOUT 50L 42 | 43 | static pid_t zzuf_pid; 44 | 45 | static void 46 | zzuf_socat_start () 47 | { 48 | int status; 49 | char *const args[] = { 50 | "zzuf", 51 | "--ratio=0.0:0.75", 52 | "-n", 53 | "-A", 54 | "--", 55 | "socat", 56 | "-lf", 57 | "/dev/null", 58 | "TCP4-LISTEN:11081,reuseaddr,fork", 59 | "TCP4:127.0.0.1:11080", 60 | NULL, 61 | }; 62 | zzuf_pid = fork (); 63 | if (zzuf_pid == -1) 64 | { 65 | fprintf (stderr, "fork failed: %s\n", strerror (errno)); 66 | exit (1); 67 | } 68 | if (zzuf_pid != 0) 69 | { 70 | sleep (1); /* allow zzuf and socat to start */ 71 | status = 0; 72 | if (0 < waitpid (zzuf_pid, &status, WNOHANG)) 73 | { 74 | if (WIFEXITED (status)) 75 | fprintf (stderr, 76 | "zzuf died with status code %d!\n", 77 | WEXITSTATUS (status)); 78 | if (WIFSIGNALED (status)) 79 | fprintf (stderr, 80 | "zzuf died from signal %d!\n", WTERMSIG (status)); 81 | exit (1); 82 | } 83 | return; 84 | } 85 | setpgrp (); 86 | execvp ("zzuf", args); 87 | fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno)); 88 | zzuf_pid = 0; /* fork failed */ 89 | exit (1); 90 | } 91 | 92 | 93 | static void 94 | zzuf_socat_stop () 95 | { 96 | int status; 97 | if (zzuf_pid != 0) 98 | { 99 | if (0 != killpg (zzuf_pid, SIGINT)) 100 | fprintf (stderr, "Failed to killpg: %s\n", strerror (errno)); 101 | kill (zzuf_pid, SIGINT); 102 | waitpid (zzuf_pid, &status, 0); 103 | sleep (1); /* allow socat to also die in peace */ 104 | } 105 | } 106 | 107 | /* end of socat.c */ 108 | --------------------------------------------------------------------------------