mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
got demo rewrite to compile
This commit is contained in:
@@ -7152,6 +7152,7 @@ src/tests/basic/Makefile
|
||||
src/tests/client_server/Makefile
|
||||
src/microhttpd_ws/Makefile
|
||||
src/examples/Makefile
|
||||
src/examples2/Makefile
|
||||
src/tools/Makefile
|
||||
src/testcurl/Makefile
|
||||
src/testcurl/https/Makefile
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ SUBDIRS += microhttpd_ws
|
||||
endif
|
||||
|
||||
if BUILD_EXAMPLES
|
||||
SUBDIRS += examples
|
||||
SUBDIRS += examples examples2
|
||||
endif
|
||||
|
||||
if BUILD_TOOLS
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# This Makefile.am is in the public domain
|
||||
SUBDIRS = .
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/include \
|
||||
$(CPPFLAGS_ac)
|
||||
|
||||
AM_CFLAGS = $(CFLAGS_ac)
|
||||
|
||||
AM_LDFLAGS = $(LDFLAGS_ac)
|
||||
|
||||
MHD_CPU_COUNT_DEF = -DMHD_CPU_COUNT=$(CPU_COUNT)
|
||||
|
||||
AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac)
|
||||
|
||||
LDADD = $(top_builddir)/src/mhd2/libmicrohttpd2.la
|
||||
|
||||
if USE_COVERAGE
|
||||
AM_CFLAGS += --coverage
|
||||
endif
|
||||
|
||||
$(top_builddir)/src/mhd2/libmicrohttpd2.la: $(top_builddir)/src/mhd2/Makefile
|
||||
@echo ' cd $(top_builddir)/src/mhd2 && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd2.la'; \
|
||||
$(am__cd) $(top_builddir)/src/mhd2 && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd2.la
|
||||
|
||||
|
||||
# example programs
|
||||
noinst_PROGRAMS = \
|
||||
demo
|
||||
|
||||
demo_SOURCES = \
|
||||
demo.c
|
||||
@@ -0,0 +1,1101 @@
|
||||
/*
|
||||
This file is part of libmicrohttpd
|
||||
Copyright (C) 2013-2024 Christian Grothoff (and other contributing authors)
|
||||
Copyright (C) 2014-2022 Evgeny Grin (Karlson2k)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/**
|
||||
* @file demo.c
|
||||
* @brief complex demonstration site: create directory index, offer
|
||||
* upload via form and HTTP POST, download with mime type detection
|
||||
* and error reporting (403, etc.) --- and all of this with
|
||||
* high-performance settings (large buffers, thread pool).
|
||||
* If you want to benchmark MHD, this code should be used to
|
||||
* run tests against. Note that the number of threads may need
|
||||
* to be adjusted depending on the number of available cores.
|
||||
* @author Christian Grothoff
|
||||
* @author Karlson2k (Evgeny Grin)
|
||||
*/
|
||||
#include <microhttpd2.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
#include <magic.h>
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2
|
||||
#undef MHD_CPU_COUNT
|
||||
#endif
|
||||
#if ! defined(MHD_CPU_COUNT)
|
||||
#define MHD_CPU_COUNT 2
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
/* Some platforms (namely: GNU Hurd) do no define PATH_MAX.
|
||||
As it is only example for MHD, just use reasonable value for PATH_MAX. */
|
||||
#define PATH_MAX 16384
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Number of threads to run in the thread pool. Should (roughly) match
|
||||
* the number of cores on your system.
|
||||
*/
|
||||
#define NUMBER_OF_THREADS MHD_CPU_COUNT
|
||||
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
/**
|
||||
* How many bytes of a file do we give to libmagic to determine the mime type?
|
||||
* 16k might be a bit excessive, but ought not hurt performance much anyway,
|
||||
* and should definitively be on the safe side.
|
||||
*/
|
||||
#define MAGIC_HEADER_SIZE (16 * 1024)
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
|
||||
|
||||
/**
|
||||
* Page returned for file-not-found.
|
||||
*/
|
||||
#define FILE_NOT_FOUND_PAGE \
|
||||
"<html><head><title>File not found</title></head><body>File not found</body></html>"
|
||||
|
||||
|
||||
/**
|
||||
* Page returned for internal errors.
|
||||
*/
|
||||
#define INTERNAL_ERROR_PAGE \
|
||||
"<html><head><title>Internal error</title></head><body>Internal error</body></html>"
|
||||
|
||||
|
||||
/**
|
||||
* Page returned for refused requests.
|
||||
*/
|
||||
#define REQUEST_REFUSED_PAGE \
|
||||
"<html><head><title>Request refused</title></head><body>Request refused (file exists?)</body></html>"
|
||||
|
||||
|
||||
/**
|
||||
* Head of index page.
|
||||
*/
|
||||
#define INDEX_PAGE_HEADER \
|
||||
"<html>\n<head><title>Welcome</title></head>\n<body>\n" \
|
||||
"<h1>Upload</h1>\n" \
|
||||
"<form method=\"POST\" enctype=\"multipart/form-data\" action=\"/\">\n" \
|
||||
"<dl><dt>Content type:</dt><dd>" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"books\">Book</input>" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"images\">Image</input>" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"music\">Music</input>" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"software\">Software</input>" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"videos\">Videos</input>\n" \
|
||||
"<input type=\"radio\" name=\"category\" value=\"other\" checked>Other</input></dd>" \
|
||||
"<dt>Language:</dt><dd>" \
|
||||
"<input type=\"radio\" name=\"language\" value=\"no-lang\" checked>none</input>" \
|
||||
"<input type=\"radio\" name=\"language\" value=\"en\">English</input>" \
|
||||
"<input type=\"radio\" name=\"language\" value=\"de\">German</input>" \
|
||||
"<input type=\"radio\" name=\"language\" value=\"fr\">French</input>" \
|
||||
"<input type=\"radio\" name=\"language\" value=\"es\">Spanish</input></dd>\n" \
|
||||
"<dt>File:</dt><dd>" \
|
||||
"<input type=\"file\" name=\"upload\"/></dd></dl>" \
|
||||
"<input type=\"submit\" value=\"Send!\"/>\n" \
|
||||
"</form>\n" \
|
||||
"<h1>Download</h1>\n" \
|
||||
"<ol>\n"
|
||||
|
||||
/**
|
||||
* Footer of index page.
|
||||
*/
|
||||
#define INDEX_PAGE_FOOTER "</ol>\n</body>\n</html>"
|
||||
|
||||
|
||||
/**
|
||||
* NULL-terminated array of supported upload categories. Should match HTML
|
||||
* in the form.
|
||||
*/
|
||||
static const char *const categories[] = {
|
||||
"books",
|
||||
"images",
|
||||
"music",
|
||||
"software",
|
||||
"videos",
|
||||
"other",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Specification of a supported language.
|
||||
*/
|
||||
struct Language
|
||||
{
|
||||
/**
|
||||
* Directory name for the language.
|
||||
*/
|
||||
const char *dirname;
|
||||
|
||||
/**
|
||||
* Long name for humans.
|
||||
*/
|
||||
const char *longname;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* NULL-terminated array of supported upload categories. Should match HTML
|
||||
* in the form.
|
||||
*/
|
||||
static const struct Language languages[] = {
|
||||
{ "no-lang", "No language specified" },
|
||||
{ "en", "English" },
|
||||
{ "de", "German" },
|
||||
{ "fr", "French" },
|
||||
{ "es", "Spanish" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Response returned if the requested file does not exist (or is not accessible).
|
||||
*/
|
||||
static struct MHD_Response *file_not_found_response;
|
||||
|
||||
/**
|
||||
* Response returned for internal errors.
|
||||
*/
|
||||
static struct MHD_Response *internal_error_response;
|
||||
|
||||
/**
|
||||
* Response returned for '/' (GET) to list the contents of the directory and allow upload.
|
||||
*/
|
||||
static struct MHD_Response *cached_directory_response;
|
||||
|
||||
/**
|
||||
* Response returned for refused uploads.
|
||||
*/
|
||||
static struct MHD_Response *request_refused_response;
|
||||
|
||||
/**
|
||||
* Mutex used when we update the cached directory response object.
|
||||
*/
|
||||
static pthread_mutex_t mutex;
|
||||
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
/**
|
||||
* Global handle to MAGIC data.
|
||||
*/
|
||||
static magic_t magic;
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
|
||||
|
||||
/**
|
||||
* Mark the given response as HTML for the browser.
|
||||
*
|
||||
* @param response response to mark
|
||||
*/
|
||||
static void
|
||||
mark_as_html (struct MHD_Response *response)
|
||||
{
|
||||
(void) MHD_response_add_header (response,
|
||||
MHD_HTTP_HEADER_CONTENT_TYPE,
|
||||
"text/html");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace the existing 'cached_directory_response' with the
|
||||
* given response.
|
||||
*
|
||||
* @param response new directory response
|
||||
*/
|
||||
static void
|
||||
update_cached_response (struct MHD_Response *response)
|
||||
{
|
||||
(void) pthread_mutex_lock (&mutex);
|
||||
if (NULL != cached_directory_response)
|
||||
MHD_response_destroy (cached_directory_response);
|
||||
cached_directory_response = response;
|
||||
if (MHD_SC_OK !=
|
||||
MHD_response_set_option (response,
|
||||
&MHD_R_OPTION_REUSABLE (
|
||||
MHD_YES)))
|
||||
exit (1);
|
||||
(void) pthread_mutex_unlock (&mutex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Context keeping the data for the response we're building.
|
||||
*/
|
||||
struct ResponseDataContext
|
||||
{
|
||||
/**
|
||||
* Response data string.
|
||||
*/
|
||||
char *buf;
|
||||
|
||||
/**
|
||||
* Number of bytes allocated for 'buf'.
|
||||
*/
|
||||
size_t buf_len;
|
||||
|
||||
/**
|
||||
* Current position where we append to 'buf'. Must be smaller or equal to 'buf_len'.
|
||||
*/
|
||||
size_t off;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a listing of the files in 'dirname' in HTML.
|
||||
*
|
||||
* @param rdc where to store the list of files
|
||||
* @param dirname name of the directory to list
|
||||
* @return true on success, false on error
|
||||
*/
|
||||
static bool
|
||||
list_directory (struct ResponseDataContext *rdc,
|
||||
const char *dirname)
|
||||
{
|
||||
char fullname[PATH_MAX];
|
||||
struct stat sbuf;
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
|
||||
if (NULL == (dir = opendir (dirname)))
|
||||
return false;
|
||||
while (NULL != (de = readdir (dir)))
|
||||
{
|
||||
int res;
|
||||
if ('.' == de->d_name[0])
|
||||
continue;
|
||||
if (sizeof (fullname) <= (unsigned int)
|
||||
snprintf (fullname, sizeof (fullname),
|
||||
"%s/%s",
|
||||
dirname, de->d_name))
|
||||
continue; /* ugh, file too long? how can this be!? */
|
||||
if (0 != stat (fullname, &sbuf))
|
||||
continue; /* ugh, failed to 'stat' */
|
||||
if (! S_ISREG (sbuf.st_mode))
|
||||
continue; /* not a regular file, skip */
|
||||
if (rdc->off + 1024 > rdc->buf_len)
|
||||
{
|
||||
void *r;
|
||||
|
||||
if ( (2 * rdc->buf_len + 1024) < rdc->buf_len)
|
||||
break; /* more than SIZE_T _index_ size? Too big for us */
|
||||
rdc->buf_len = 2 * rdc->buf_len + 1024;
|
||||
if (NULL == (r = realloc (rdc->buf, rdc->buf_len)))
|
||||
break; /* out of memory */
|
||||
rdc->buf = r;
|
||||
}
|
||||
res = snprintf (&rdc->buf[rdc->off],
|
||||
rdc->buf_len - rdc->off,
|
||||
"<li><a href=\"/%s\">%s</a></li>\n",
|
||||
fullname,
|
||||
de->d_name);
|
||||
if (0 >= res)
|
||||
continue; /* snprintf() error */
|
||||
if (rdc->buf_len - rdc->off <= (size_t) res)
|
||||
continue; /* buffer too small?? */
|
||||
rdc->off += (size_t) res;
|
||||
}
|
||||
(void) closedir (dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Re-scan our local directory and re-build the index.
|
||||
*/
|
||||
static void
|
||||
update_directory (void)
|
||||
{
|
||||
static size_t initial_allocation = 32 * 1024; /* initial size for response buffer */
|
||||
struct MHD_Response *response;
|
||||
struct ResponseDataContext rdc;
|
||||
unsigned int language_idx;
|
||||
unsigned int category_idx;
|
||||
const struct Language *language;
|
||||
const char *category;
|
||||
char dir_name[128];
|
||||
struct stat sbuf;
|
||||
int res;
|
||||
size_t len;
|
||||
|
||||
rdc.buf_len = initial_allocation;
|
||||
if (NULL == (rdc.buf = malloc (rdc.buf_len)))
|
||||
{
|
||||
update_cached_response (NULL);
|
||||
return;
|
||||
}
|
||||
len = strlen (INDEX_PAGE_HEADER);
|
||||
if (rdc.buf_len <= len)
|
||||
{ /* buffer too small */
|
||||
free (rdc.buf);
|
||||
update_cached_response (NULL);
|
||||
return;
|
||||
}
|
||||
memcpy (rdc.buf, INDEX_PAGE_HEADER, len);
|
||||
rdc.off = len;
|
||||
for (language_idx = 0; NULL != languages[language_idx].dirname;
|
||||
language_idx++)
|
||||
{
|
||||
language = &languages[language_idx];
|
||||
|
||||
if (0 != stat (language->dirname, &sbuf))
|
||||
continue; /* empty */
|
||||
/* we ensured always +1k room, filenames are ~256 bytes,
|
||||
so there is always still enough space for the header
|
||||
without need for an additional reallocation check. */
|
||||
res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off,
|
||||
"<h2>%s</h2>\n",
|
||||
language->longname);
|
||||
if (0 >= res)
|
||||
continue; /* snprintf() error */
|
||||
if (rdc.buf_len - rdc.off <= (size_t) res)
|
||||
continue; /* buffer too small?? */
|
||||
rdc.off += (size_t) res;
|
||||
for (category_idx = 0; NULL != categories[category_idx]; category_idx++)
|
||||
{
|
||||
category = categories[category_idx];
|
||||
res = snprintf (dir_name, sizeof (dir_name),
|
||||
"%s/%s",
|
||||
language->dirname,
|
||||
category);
|
||||
if ((0 >= res) || (sizeof (dir_name) <= (size_t) res))
|
||||
continue; /* cannot print dir name */
|
||||
if (0 != stat (dir_name, &sbuf))
|
||||
continue; /* empty */
|
||||
|
||||
/* we ensured always +1k room, filenames are ~256 bytes,
|
||||
so there is always still enough space for the header
|
||||
without need for an additional reallocation check. */
|
||||
res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off,
|
||||
"<h3>%s</h3>\n",
|
||||
category);
|
||||
if (0 >= res)
|
||||
continue; /* snprintf() error */
|
||||
if (rdc.buf_len - rdc.off <= (size_t) res)
|
||||
continue; /* buffer too small?? */
|
||||
rdc.off += (size_t) res;
|
||||
|
||||
if (! list_directory (&rdc,
|
||||
dir_name))
|
||||
{
|
||||
free (rdc.buf);
|
||||
update_cached_response (NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* we ensured always +1k room, filenames are ~256 bytes,
|
||||
so there is always still enough space for the footer
|
||||
without need for a final reallocation check. */
|
||||
len = strlen (INDEX_PAGE_FOOTER);
|
||||
if (rdc.buf_len - rdc.off <= len)
|
||||
{ /* buffer too small */
|
||||
free (rdc.buf);
|
||||
update_cached_response (NULL);
|
||||
return;
|
||||
}
|
||||
memcpy (rdc.buf, INDEX_PAGE_FOOTER, len);
|
||||
rdc.off += len;
|
||||
initial_allocation = rdc.buf_len; /* remember for next time */
|
||||
response =
|
||||
MHD_response_from_buffer (MHD_HTTP_STATUS_OK,
|
||||
rdc.off,
|
||||
rdc.buf,
|
||||
&free,
|
||||
rdc.buf);
|
||||
mark_as_html (response);
|
||||
#ifdef FORCE_CLOSE
|
||||
(void) MHD_response_add_header (response,
|
||||
MHD_HTTP_HEADER_CONNECTION,
|
||||
"close");
|
||||
#endif
|
||||
update_cached_response (response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Context we keep for an upload.
|
||||
*/
|
||||
struct UploadContext
|
||||
{
|
||||
/**
|
||||
* Handle where we write the uploaded file to.
|
||||
*/
|
||||
int fd;
|
||||
|
||||
/**
|
||||
* Name of our temporary file where we initially read to.
|
||||
*/
|
||||
char tmpname[PATH_MAX];
|
||||
|
||||
/**
|
||||
* Name of the file on disk.
|
||||
*/
|
||||
char *filename;
|
||||
|
||||
/**
|
||||
* True once @a tmpfile exists.
|
||||
*/
|
||||
bool have_file;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* "Stream" reader for POST data.
|
||||
* This callback is called to incrementally process parsed POST data sent by
|
||||
* the client.
|
||||
* The pointers to the MHD_String and MHD_StringNullable are valid only until
|
||||
* return from this callback.
|
||||
* The pointers to the strings and the @a data are valid only until return from
|
||||
* this callback.
|
||||
*
|
||||
* @param req the request
|
||||
* @param cls user-specified closure
|
||||
* @param name the name of the POST field
|
||||
* @param filename the name of the uploaded file, @a cstr member is NULL if not
|
||||
* known / not provided
|
||||
* @param content_type the mime-type of the data, cstr member is NULL if not
|
||||
* known / not provided
|
||||
* @param encoding the encoding of the data, cstr member is NULL if not known /
|
||||
* not provided
|
||||
* @param size the number of bytes in @a data available, may be zero if
|
||||
* the @a final_data is #MHD_YES
|
||||
* @param data the pointer to @a size bytes of data at the specified
|
||||
* @a off offset, NOT zero-terminated
|
||||
* @param off the offset of @a data in the overall value, always equal to
|
||||
* the sum of sizes of previous calls for the same field / file;
|
||||
* client may provide more than one field with the same name and
|
||||
* the same filename, the new filed (or file) is indicated by zero
|
||||
* value of @a off (and the end is indicated by @a final_data)
|
||||
* @param final_data if set to #MHD_YES then full field data is provided,
|
||||
* if set to #MHD_NO then more field data may be provided
|
||||
* @return action specifying how to proceed:
|
||||
* #MHD_upload_action_continue() if all is well,
|
||||
* #MHD_upload_action_suspend() to stop reading the upload until
|
||||
* the request is resumed,
|
||||
* #MHD_upload_action_abort_request() to close the socket,
|
||||
* or a response to discard the rest of the upload and transmit
|
||||
* the response
|
||||
* @ingroup action
|
||||
*/
|
||||
static const struct MHD_UploadAction *
|
||||
stream_reader (struct MHD_Request *req,
|
||||
void *cls,
|
||||
const struct MHD_String *name,
|
||||
const struct MHD_StringNullable *filename,
|
||||
const struct MHD_StringNullable *content_type,
|
||||
const struct MHD_StringNullable *encoding,
|
||||
size_t size,
|
||||
const void *data,
|
||||
uint_fast64_t off,
|
||||
enum MHD_Bool final_data)
|
||||
{
|
||||
struct UploadContext *uc = cls;
|
||||
|
||||
(void) content_type; /* Unused. Silent compiler warning. */
|
||||
(void) encoding; /* Unused. Silent compiler warning. */
|
||||
(void) off; /* Unused. Silent compiler warning. */
|
||||
if ( (0 == strcmp (name->cstr,
|
||||
"category")) ||
|
||||
(0 == strcmp (name->cstr,
|
||||
"filename")) ||
|
||||
(0 == strcmp (name->cstr,
|
||||
"language")) )
|
||||
{
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
if (0 != strcmp (name->cstr,
|
||||
"upload"))
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Ignoring unexpected form value `%s'\n",
|
||||
name->cstr);
|
||||
return MHD_upload_action_continue (req);
|
||||
}
|
||||
if (NULL == filename->cstr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"No filename, aborting upload.\n");
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
if (-1 == uc->fd)
|
||||
{
|
||||
if ( (NULL != strstr (filename->cstr,
|
||||
"..")) ||
|
||||
(NULL != strchr (filename->cstr,
|
||||
'/')) ||
|
||||
(NULL != strchr (filename->cstr,
|
||||
'\\')) )
|
||||
{
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
uc->filename = strdup (filename->cstr);
|
||||
if (NULL == uc->filename)
|
||||
{
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
internal_error_response);
|
||||
}
|
||||
{
|
||||
size_t slen = strlen (uc->filename);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < slen; i++)
|
||||
if (! isprint ((unsigned char) uc->filename[i]))
|
||||
uc->filename[i] = '_';
|
||||
}
|
||||
uc->fd = mkstemp (uc->tmpname);
|
||||
if (-1 == uc->fd)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Error creating temporary file `%s' for upload: %s\n",
|
||||
uc->tmpname,
|
||||
strerror (errno));
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
}
|
||||
if ( (0 != size) &&
|
||||
#if ! defined(_WIN32) || defined(__CYGWIN__)
|
||||
(size !=
|
||||
(size_t) write (uc->fd,
|
||||
data,
|
||||
size))
|
||||
#else /* Native W32 */
|
||||
(size !=
|
||||
(size_t) write (uc->fd,
|
||||
data,
|
||||
(unsigned int) size))
|
||||
#endif /* Native W32 */
|
||||
)
|
||||
{
|
||||
/* write failed; likely: disk full */
|
||||
fprintf (stderr,
|
||||
"Error writing to file `%s': %s\n",
|
||||
uc->tmpname,
|
||||
strerror (errno));
|
||||
(void) close (uc->fd);
|
||||
uc->fd = -1;
|
||||
free (uc->filename);
|
||||
unlink (uc->tmpname);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
internal_error_response);
|
||||
}
|
||||
if (final_data)
|
||||
{
|
||||
(void) close (uc->fd);
|
||||
uc->fd = -1;
|
||||
uc->have_file = true;
|
||||
}
|
||||
return MHD_upload_action_continue (req);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The callback to be called when finished with processing
|
||||
* of the postprocessor upload data.
|
||||
* @param req the request
|
||||
* @param cls the closure
|
||||
* @param parsing_result the result of POST data parsing
|
||||
* @return the action to proceed
|
||||
*/
|
||||
static const struct MHD_UploadAction *
|
||||
done_cb (struct MHD_Request *req,
|
||||
void *cls,
|
||||
enum MHD_PostParseResult parsing_result)
|
||||
{
|
||||
struct UploadContext *uc = cls;
|
||||
const struct MHD_UploadAction *ret;
|
||||
const struct MHD_StringNullable *cat;
|
||||
const struct MHD_StringNullable *lang;
|
||||
const struct MHD_StringNullable *upload;
|
||||
char fn[PATH_MAX];
|
||||
int res;
|
||||
|
||||
if (MHD_POST_PARSE_RES_OK != parsing_result)
|
||||
{
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
if (-1 != uc->fd)
|
||||
{
|
||||
(void) close (uc->fd);
|
||||
if (NULL != uc->filename)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Upload of file `%s' failed (incomplete or aborted), removing file.\n",
|
||||
uc->filename);
|
||||
}
|
||||
(void) unlink (uc->tmpname);
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
internal_error_response);
|
||||
}
|
||||
cat = MHD_request_get_value (req,
|
||||
MHD_VK_POSTDATA,
|
||||
"category");
|
||||
lang = MHD_request_get_value (req,
|
||||
MHD_VK_POSTDATA,
|
||||
"language");
|
||||
if ( (NULL == lang->cstr) ||
|
||||
(NULL == cat->cstr) )
|
||||
{
|
||||
if (uc->have_file)
|
||||
(void) unlink (uc->tmpname);
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
/* FIXME: ugly that we may have to deal with upload
|
||||
here as well! */
|
||||
upload = MHD_request_get_value (req,
|
||||
MHD_VK_POSTDATA,
|
||||
"upload");
|
||||
if (NULL != upload->cstr)
|
||||
{
|
||||
if (uc->have_file)
|
||||
{
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
internal_error_response);
|
||||
}
|
||||
uc->fd = mkstemp (uc->tmpname);
|
||||
if (-1 == uc->fd)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Error creating temporary file `%s' for upload: %s\n",
|
||||
uc->tmpname,
|
||||
strerror (errno));
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
// FIXME: error handling, ...
|
||||
write (uc->fd,
|
||||
upload->cstr,
|
||||
upload->len);
|
||||
close (uc->fd);
|
||||
uc->have_file = true;
|
||||
}
|
||||
/* create directories -- if they don't exist already */
|
||||
#ifdef WINDOWS
|
||||
(void) mkdir (lang->cstr);
|
||||
#else
|
||||
(void) mkdir (lang->cstr,
|
||||
S_IRWXU);
|
||||
#endif
|
||||
res = snprintf (fn,
|
||||
sizeof (fn),
|
||||
"%s/%s",
|
||||
lang->cstr,
|
||||
cat->cstr);
|
||||
if ( (0 >= res) ||
|
||||
(sizeof (fn) <= (size_t) res) )
|
||||
{
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
(void) mkdir (fn);
|
||||
#else
|
||||
(void) mkdir (fn,
|
||||
S_IRWXU);
|
||||
#endif
|
||||
/* compute filename */
|
||||
res = snprintf (fn,
|
||||
sizeof (fn),
|
||||
"%s/%s/%s",
|
||||
lang->cstr,
|
||||
cat->cstr,
|
||||
uc->filename);
|
||||
if ( (0 >= res) ||
|
||||
(sizeof (fn) <= (size_t) res) )
|
||||
{
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
|
||||
if (0 !=
|
||||
rename (uc->tmpname,
|
||||
uc->filename))
|
||||
{
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
return MHD_upload_action_from_response (req,
|
||||
request_refused_response);
|
||||
}
|
||||
chmod (uc->filename,
|
||||
S_IRUSR | S_IWUSR);
|
||||
free (uc->filename);
|
||||
free (uc);
|
||||
|
||||
update_directory ();
|
||||
(void) pthread_mutex_lock (&mutex);
|
||||
if (NULL == cached_directory_response)
|
||||
ret = MHD_upload_action_from_response (req,
|
||||
internal_error_response);
|
||||
else
|
||||
ret = MHD_upload_action_from_response (req,
|
||||
cached_directory_response);
|
||||
(void) pthread_mutex_unlock (&mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main callback from MHD, used to generate the page.
|
||||
*
|
||||
* @param cls NULL
|
||||
* @param request the request object
|
||||
* @param path the requested uri (without arguments after "?")
|
||||
* @param method the HTTP method used (#MHD_HTTP_METHOD_GET,
|
||||
* #MHD_HTTP_METHOD_PUT, etc.)
|
||||
* @param upload_size the size of the message upload content payload,
|
||||
* #MHD_SIZE_UNKNOWN for chunked uploads (if the
|
||||
* final chunk has not been processed yet)
|
||||
* @return action how to proceed, NULL
|
||||
* if the request must be aborted due to a serious
|
||||
* error while handling the request (implies closure
|
||||
* of underling data stream, for HTTP/1.1 it means
|
||||
* socket closure). */
|
||||
static const struct MHD_Action *
|
||||
generate_page (void *cls,
|
||||
struct MHD_Request *request,
|
||||
const struct MHD_String *path,
|
||||
enum MHD_HTTP_Method method,
|
||||
uint_fast64_t upload_size)
|
||||
{
|
||||
struct MHD_Response *response;
|
||||
const char *url = path->cstr;
|
||||
|
||||
(void ) cls;
|
||||
if ( ( (MHD_HTTP_METHOD_GET == method) ||
|
||||
(MHD_HTTP_METHOD_HEAD == method) ) &&
|
||||
(0 != strcmp (url,
|
||||
"/")) )
|
||||
{
|
||||
/* should be file download */
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
char file_data[MAGIC_HEADER_SIZE];
|
||||
ssize_t got;
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
const char *mime;
|
||||
int fd = -1;
|
||||
struct stat buf;
|
||||
|
||||
fd = -1;
|
||||
if ( (NULL == strstr (&url[1],
|
||||
"..")) &&
|
||||
('/' != url[1]) )
|
||||
{
|
||||
fd = open (&url[1],
|
||||
O_RDONLY);
|
||||
if ( (-1 != fd) &&
|
||||
( (0 != fstat (fd,
|
||||
&buf)) ||
|
||||
(! S_ISREG (buf.st_mode)) ) )
|
||||
{
|
||||
(void) close (fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
if (-1 == fd)
|
||||
return MHD_action_from_response (request,
|
||||
file_not_found_response);
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
/* read beginning of the file to determine mime type */
|
||||
got = read (fd,
|
||||
file_data,
|
||||
sizeof (file_data));
|
||||
(void) lseek (fd,
|
||||
0,
|
||||
SEEK_SET);
|
||||
if (0 < got)
|
||||
mime = magic_buffer (magic,
|
||||
file_data,
|
||||
(size_t) got);
|
||||
else
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
mime = NULL;
|
||||
{
|
||||
/* Set mime-type by file-extension in some cases */
|
||||
const char *ldot = strrchr (&url[1],
|
||||
'.');
|
||||
|
||||
if (NULL != ldot)
|
||||
{
|
||||
if (0 == strcasecmp (ldot,
|
||||
".html"))
|
||||
mime = "text/html";
|
||||
if (0 == strcasecmp (ldot,
|
||||
".css"))
|
||||
mime = "text/css";
|
||||
if (0 == strcasecmp (ldot,
|
||||
".css3"))
|
||||
mime = "text/css";
|
||||
if (0 == strcasecmp (ldot,
|
||||
".js"))
|
||||
mime = "application/javascript";
|
||||
}
|
||||
}
|
||||
|
||||
response = MHD_response_from_fd (MHD_HTTP_STATUS_OK,
|
||||
fd,
|
||||
0LLU /* offset */,
|
||||
(uint_fast64_t) buf.st_size);
|
||||
if (NULL == response)
|
||||
{
|
||||
/* internal error (i.e. out of memory) */
|
||||
(void) close (fd);
|
||||
return MHD_action_abort_request (request);
|
||||
}
|
||||
|
||||
/* add mime type if we had one */
|
||||
if (NULL != mime)
|
||||
(void) MHD_response_add_header (response,
|
||||
MHD_HTTP_HEADER_CONTENT_TYPE,
|
||||
mime);
|
||||
return MHD_action_from_response (request,
|
||||
response);
|
||||
}
|
||||
|
||||
if ( (MHD_HTTP_METHOD_POST == method) &&
|
||||
(0 == strcmp (path->cstr,
|
||||
"/")) )
|
||||
{
|
||||
struct UploadContext *uc;
|
||||
|
||||
uc = malloc (sizeof (struct UploadContext));
|
||||
if (NULL == uc)
|
||||
return MHD_action_abort_request (request); /* out of memory, close connection */
|
||||
memset (uc,
|
||||
0,
|
||||
sizeof (struct UploadContext));
|
||||
strcpy (uc->tmpname,
|
||||
"/tmp/mhd-demo-XXXXXX");
|
||||
uc->fd = -1;
|
||||
return MHD_action_parse_post (request,
|
||||
64 * 1024 /* buffer size */,
|
||||
1024 /* max non-stream size */,
|
||||
MHD_HTTP_POST_ENCODING_OTHER,
|
||||
&stream_reader,
|
||||
uc,
|
||||
&done_cb,
|
||||
uc);
|
||||
}
|
||||
if ( ( (MHD_HTTP_METHOD_GET == method) ||
|
||||
(MHD_HTTP_METHOD_HEAD == method) ) &&
|
||||
(0 == strcmp (url,
|
||||
"/")) )
|
||||
{
|
||||
const struct MHD_Action *ret;
|
||||
|
||||
(void) pthread_mutex_lock (&mutex);
|
||||
if (NULL == cached_directory_response)
|
||||
ret = MHD_action_from_response (request,
|
||||
internal_error_response);
|
||||
else
|
||||
ret = MHD_action_from_response (request,
|
||||
cached_directory_response);
|
||||
(void) pthread_mutex_unlock (&mutex);
|
||||
return ret;
|
||||
}
|
||||
/* unexpected request, refuse */
|
||||
return MHD_action_from_response (request,
|
||||
request_refused_response);
|
||||
}
|
||||
|
||||
|
||||
#ifndef MINGW
|
||||
/**
|
||||
* Function called if we get a SIGPIPE. Does nothing.
|
||||
*
|
||||
* @param sig will be SIGPIPE (ignored)
|
||||
*/
|
||||
static void
|
||||
catcher (int sig)
|
||||
{
|
||||
(void) sig; /* Unused. Silent compiler warning. */
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setup handlers to ignore SIGPIPE.
|
||||
*/
|
||||
static void
|
||||
ignore_sigpipe (void)
|
||||
{
|
||||
struct sigaction oldsig;
|
||||
struct sigaction sig;
|
||||
|
||||
sig.sa_handler = &catcher;
|
||||
sigemptyset (&sig.sa_mask);
|
||||
#ifdef SA_INTERRUPT
|
||||
sig.sa_flags = SA_INTERRUPT; /* SunOS */
|
||||
#else
|
||||
sig.sa_flags = SA_RESTART;
|
||||
#endif
|
||||
if (0 != sigaction (SIGPIPE,
|
||||
&sig,
|
||||
&oldsig))
|
||||
fprintf (stderr,
|
||||
"Failed to install SIGPIPE handler: %s\n", strerror (errno));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Entry point to demo. Note: this HTTP server will make all
|
||||
* files in the current directory and its subdirectories available
|
||||
* to anyone. Press ENTER to stop the server once it has started.
|
||||
*
|
||||
* @param argc number of arguments in argv
|
||||
* @param argv first and only argument should be the port number
|
||||
* @return 0 on success
|
||||
*/
|
||||
int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
struct MHD_Daemon *d;
|
||||
unsigned int port;
|
||||
|
||||
if ( (argc != 2) ||
|
||||
(1 != sscanf (argv[1], "%u", &port)) ||
|
||||
(UINT16_MAX < port) )
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s PORT\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
#ifndef MINGW
|
||||
ignore_sigpipe ();
|
||||
#endif
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
magic = magic_open (MAGIC_MIME_TYPE);
|
||||
(void) magic_load (magic, NULL);
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
|
||||
(void) pthread_mutex_init (&mutex, NULL);
|
||||
file_not_found_response =
|
||||
MHD_response_from_buffer_static (
|
||||
MHD_HTTP_STATUS_NOT_FOUND,
|
||||
strlen (FILE_NOT_FOUND_PAGE),
|
||||
(const void *) FILE_NOT_FOUND_PAGE);
|
||||
mark_as_html (file_not_found_response);
|
||||
if (MHD_SC_OK !=
|
||||
MHD_response_set_option (file_not_found_response,
|
||||
&MHD_R_OPTION_REUSABLE (
|
||||
MHD_YES)))
|
||||
return 1;
|
||||
request_refused_response =
|
||||
MHD_response_from_buffer_static (
|
||||
MHD_HTTP_STATUS_FORBIDDEN,
|
||||
strlen (REQUEST_REFUSED_PAGE),
|
||||
(const void *) REQUEST_REFUSED_PAGE);
|
||||
mark_as_html (request_refused_response);
|
||||
if (MHD_SC_OK !=
|
||||
MHD_response_set_option (request_refused_response,
|
||||
&MHD_R_OPTION_REUSABLE (
|
||||
MHD_YES)))
|
||||
return 1;
|
||||
internal_error_response =
|
||||
MHD_response_from_buffer_static (
|
||||
MHD_HTTP_STATUS_INTERNAL_SERVER_ERROR,
|
||||
strlen (INTERNAL_ERROR_PAGE),
|
||||
(const void *) INTERNAL_ERROR_PAGE);
|
||||
mark_as_html (internal_error_response);
|
||||
if (MHD_SC_OK !=
|
||||
MHD_response_set_option (internal_error_response,
|
||||
&MHD_R_OPTION_REUSABLE (
|
||||
MHD_YES)))
|
||||
return 1;
|
||||
update_directory ();
|
||||
d = MHD_daemon_create (&generate_page,
|
||||
NULL);
|
||||
if (NULL == d)
|
||||
return 1;
|
||||
if (MHD_SC_OK !=
|
||||
MHD_DAEMON_SET_OPTIONS (
|
||||
d,
|
||||
MHD_D_OPTION_POLL_SYSCALL (MHD_SPS_AUTO),
|
||||
MHD_D_OPTION_WM_WORKER_THREADS (NUMBER_OF_THREADS),
|
||||
#ifdef PRODUCTION
|
||||
MHD_D_OPTION_PER_IP_LIMIT (64),
|
||||
#endif
|
||||
MHD_D_OPTION_DEFAULT_TIMEOUT (120 /* seconds */),
|
||||
MHD_D_OPTION_CONN_MEMORY_LIMIT (256 * 1024),
|
||||
MHD_D_OPTION_BIND_PORT (MHD_AF_AUTO,
|
||||
port)))
|
||||
return 1;
|
||||
if (MHD_SC_OK !=
|
||||
MHD_daemon_start (d))
|
||||
{
|
||||
MHD_daemon_destroy (d);
|
||||
return 1;
|
||||
}
|
||||
fprintf (stderr, "HTTP server running. Press ENTER to stop the server.\n");
|
||||
(void) getc (stdin);
|
||||
MHD_daemon_destroy (d);
|
||||
MHD_response_destroy (file_not_found_response);
|
||||
MHD_response_destroy (request_refused_response);
|
||||
MHD_response_destroy (internal_error_response);
|
||||
update_cached_response (NULL);
|
||||
(void) pthread_mutex_destroy (&mutex);
|
||||
#ifdef MHD_HAVE_LIBMAGIC
|
||||
magic_close (magic);
|
||||
#endif /* MHD_HAVE_LIBMAGIC */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* end of demo.c */
|
||||
+38
-38
@@ -3868,11 +3868,11 @@ MHD_D_OPTION_LISTEN_BACKLOG (
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_SIGPIPE_SUPPRESSED (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -3929,11 +3929,11 @@ MHD_D_OPTION_TLS_PSK_CALLBACK (
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_NO_ALPN (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4014,32 +4014,32 @@ MHD_D_OPTION_EARLY_URI_LOGGER (
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_SUPPRESS_DATE_HEADER (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_ENABLE_SHOUTCAST (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4047,11 +4047,11 @@ MHD_D_OPTION_ENABLE_SHOUTCAST (
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_CONN_MEMORY_LIMIT (
|
||||
size_t val
|
||||
size_t value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4059,22 +4059,22 @@ MHD_D_OPTION_CONN_MEMORY_LIMIT (
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_LARGE_POOL_SIZE (
|
||||
size_t val
|
||||
size_t value
|
||||
);
|
||||
|
||||
/**
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_STACK_SIZE (
|
||||
size_t val
|
||||
size_t value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4097,11 +4097,11 @@ MHD_D_OPTION_FD_NUMBER_LIMIT (
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_TURBO (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4111,11 +4111,11 @@ MHD_D_OPTION_TURBO (
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_THREAD_SAFETY (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4123,11 +4123,11 @@ MHD_D_OPTION_DISABLE_THREAD_SAFETY (
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_UPGRADE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4135,11 +4135,11 @@ MHD_D_OPTION_DISALLOW_UPGRADE (
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_SUSPEND_RESUME (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4259,11 +4259,11 @@ MHD_D_OPTION_DAUTH_DEF_MAX_NC (
|
||||
* Make the response object re-usable. (FIXME: not used in struct ResponseOptions; remove!?)
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_REUSABLE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4272,30 +4272,30 @@ MHD_R_OPTION_REUSABLE (
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HEAD_ONLY_RESPONSE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CHUNKED_ENC (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CONN_CLOSE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4309,11 +4309,11 @@ MHD_R_OPTION_CONN_CLOSE (
|
||||
* + chunked: no
|
||||
*
|
||||
This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -4329,21 +4329,21 @@ MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (
|
||||
* + chunked: no
|
||||
*
|
||||
With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_SERVER (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -996,14 +996,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_SIGPIPE_SUPPRESSED(val) \
|
||||
# define MHD_D_OPTION_SIGPIPE_SUPPRESSED(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_SIGPIPE_SUPPRESSED, \
|
||||
.val.sigpipe_suppressed = (val) \
|
||||
.val.sigpipe_suppressed = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1072,14 +1072,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_NO_ALPN(val) \
|
||||
# define MHD_D_OPTION_NO_ALPN(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_NO_ALPN, \
|
||||
.val.no_alpn = (val) \
|
||||
.val.no_alpn = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1178,41 +1178,41 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE(val) \
|
||||
# define MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE, \
|
||||
.val.disable_uri_query_plus_as_space = (val) \
|
||||
.val.disable_uri_query_plus_as_space = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_SUPPRESS_DATE_HEADER(val) \
|
||||
# define MHD_D_OPTION_SUPPRESS_DATE_HEADER(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_SUPPRESS_DATE_HEADER, \
|
||||
.val.suppress_date_header = (val) \
|
||||
.val.suppress_date_header = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_ENABLE_SHOUTCAST(val) \
|
||||
# define MHD_D_OPTION_ENABLE_SHOUTCAST(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_ENABLE_SHOUTCAST, \
|
||||
.val.enable_shoutcast = (val) \
|
||||
.val.enable_shoutcast = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1220,14 +1220,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_CONN_MEMORY_LIMIT(val) \
|
||||
# define MHD_D_OPTION_CONN_MEMORY_LIMIT(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_CONN_MEMORY_LIMIT, \
|
||||
.val.conn_memory_limit = (val) \
|
||||
.val.conn_memory_limit = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1235,28 +1235,28 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_LARGE_POOL_SIZE(val) \
|
||||
# define MHD_D_OPTION_LARGE_POOL_SIZE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_LARGE_POOL_SIZE, \
|
||||
.val.large_pool_size = (val) \
|
||||
.val.large_pool_size = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_STACK_SIZE(val) \
|
||||
# define MHD_D_OPTION_STACK_SIZE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_STACK_SIZE, \
|
||||
.val.stack_size = (val) \
|
||||
.val.stack_size = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1282,14 +1282,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_TURBO(val) \
|
||||
# define MHD_D_OPTION_TURBO(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_TURBO, \
|
||||
.val.turbo = (val) \
|
||||
.val.turbo = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1299,14 +1299,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISABLE_THREAD_SAFETY(val) \
|
||||
# define MHD_D_OPTION_DISABLE_THREAD_SAFETY(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISABLE_THREAD_SAFETY, \
|
||||
.val.disable_thread_safety = (val) \
|
||||
.val.disable_thread_safety = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1314,14 +1314,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISALLOW_UPGRADE(val) \
|
||||
# define MHD_D_OPTION_DISALLOW_UPGRADE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISALLOW_UPGRADE, \
|
||||
.val.disallow_upgrade = (val) \
|
||||
.val.disallow_upgrade = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1329,14 +1329,14 @@ Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used.
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_D_OPTION_DISALLOW_SUSPEND_RESUME(val) \
|
||||
# define MHD_D_OPTION_DISALLOW_SUSPEND_RESUME(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_DaemonOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_D_O_DISALLOW_SUSPEND_RESUME, \
|
||||
.val.disallow_suspend_resume = (val) \
|
||||
.val.disallow_suspend_resume = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -1701,17 +1701,17 @@ MHD_D_OPTION_LISTEN_BACKLOG (
|
||||
* Inform that SIGPIPE is suppressed or handled by application.
|
||||
* If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`.
|
||||
* Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_SIGPIPE_SUPPRESSED (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_SIGPIPE_SUPPRESSED;
|
||||
opt_val.val.sigpipe_suppressed = (val); \
|
||||
opt_val.val.sigpipe_suppressed = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -1810,17 +1810,17 @@ MHD_D_OPTION_TLS_PSK_CALLBACK (
|
||||
* Control ALPN for TLS connection.
|
||||
* Silently ignored for non-TLS.
|
||||
* By default ALPN is automatically used for TLS connections.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_NO_ALPN (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_NO_ALPN;
|
||||
opt_val.val.no_alpn = (val); \
|
||||
opt_val.val.no_alpn = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -1961,17 +1961,17 @@ MHD_D_OPTION_EARLY_URI_LOGGER (
|
||||
* Disable converting plus ('+') character to space in GET parameters (URI part after '?').
|
||||
* Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details.
|
||||
* By default plus is converted to space in the query part of URI.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE;
|
||||
opt_val.val.disable_uri_query_plus_as_space = (val); \
|
||||
opt_val.val.disable_uri_query_plus_as_space = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -1981,17 +1981,17 @@ MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE (
|
||||
* Suppresse use of 'Date:' header.
|
||||
* According to RFC should be suppressed only if the system has no RTC.
|
||||
* The 'Date:' is not suppressed (the header is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_SUPPRESS_DATE_HEADER (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_SUPPRESS_DATE_HEADER;
|
||||
opt_val.val.suppress_date_header = (val); \
|
||||
opt_val.val.suppress_date_header = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2000,17 +2000,17 @@ MHD_D_OPTION_SUPPRESS_DATE_HEADER (
|
||||
/**
|
||||
* Use SHOUTcast for responses.
|
||||
* This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_ENABLE_SHOUTCAST (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_ENABLE_SHOUTCAST;
|
||||
opt_val.val.enable_shoutcast = (val); \
|
||||
opt_val.val.enable_shoutcast = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2021,17 +2021,17 @@ MHD_D_OPTION_ENABLE_SHOUTCAST (
|
||||
* Default is 32kb.
|
||||
* Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
|
||||
* The size should be large enough to fit all request headers (together with internal parsing information).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_CONN_MEMORY_LIMIT (
|
||||
size_t val
|
||||
size_t value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_CONN_MEMORY_LIMIT;
|
||||
opt_val.val.conn_memory_limit = (val); \
|
||||
opt_val.val.conn_memory_limit = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2042,17 +2042,17 @@ MHD_D_OPTION_CONN_MEMORY_LIMIT (
|
||||
* The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application.
|
||||
* Default is 8Mb.
|
||||
* Can be set to zero to disable share pool.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_LARGE_POOL_SIZE (
|
||||
size_t val
|
||||
size_t value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_LARGE_POOL_SIZE;
|
||||
opt_val.val.large_pool_size = (val); \
|
||||
opt_val.val.large_pool_size = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2062,17 +2062,17 @@ MHD_D_OPTION_LARGE_POOL_SIZE (
|
||||
* Desired size of the stack for the threads started by MHD.
|
||||
* Use 0 for system default, which is also MHD default.
|
||||
* Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION().
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_STACK_SIZE (
|
||||
size_t val
|
||||
size_t value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_STACK_SIZE;
|
||||
opt_val.val.stack_size = (val); \
|
||||
opt_val.val.stack_size = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2107,17 +2107,17 @@ MHD_D_OPTION_FD_NUMBER_LIMIT (
|
||||
* Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
|
||||
* Most effects only happen with internal threads with epoll.
|
||||
* The 'turbo' mode is not enabled (mode is disabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_TURBO (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_TURBO;
|
||||
opt_val.val.turbo = (val); \
|
||||
opt_val.val.turbo = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2130,17 +2130,17 @@ MHD_D_OPTION_TURBO (
|
||||
* Not compatible with any internal threads modes.
|
||||
* If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory.
|
||||
* Thread safety is not disabled (safety is enabled) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISABLE_THREAD_SAFETY (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISABLE_THREAD_SAFETY;
|
||||
opt_val.val.disable_thread_safety = (val); \
|
||||
opt_val.val.disable_thread_safety = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2151,17 +2151,17 @@ MHD_D_OPTION_DISABLE_THREAD_SAFETY (
|
||||
* Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used.
|
||||
* You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving.
|
||||
* The upgrade is not disallowed (upgrade is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_UPGRADE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISALLOW_UPGRADE;
|
||||
opt_val.val.disallow_upgrade = (val); \
|
||||
opt_val.val.disallow_upgrade = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -2172,17 +2172,17 @@ MHD_D_OPTION_DISALLOW_UPGRADE (
|
||||
*
|
||||
You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
|
||||
* The suspend is not disallowed (suspend is allowed) by default.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_DaemonOptionAndValue
|
||||
MHD_D_OPTION_DISALLOW_SUSPEND_RESUME (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_DaemonOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_D_O_DISALLOW_SUSPEND_RESUME;
|
||||
opt_val.val.disallow_suspend_resume = (val); \
|
||||
opt_val.val.disallow_suspend_resume = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
@@ -181,14 +181,14 @@ struct MHD_ResponseOptionAndValue
|
||||
* Make the response object re-usable. (FIXME: not used in struct ResponseOptions; remove!?)
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_REUSABLE(val) \
|
||||
# define MHD_R_OPTION_REUSABLE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_REUSABLE, \
|
||||
.val.reusable = (val) \
|
||||
.val.reusable = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -197,39 +197,39 @@ struct MHD_ResponseOptionAndValue
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HEAD_ONLY_RESPONSE(val) \
|
||||
# define MHD_R_OPTION_HEAD_ONLY_RESPONSE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HEAD_ONLY_RESPONSE, \
|
||||
.val.head_only_response = (val) \
|
||||
.val.head_only_response = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_CHUNKED_ENC(val) \
|
||||
# define MHD_R_OPTION_CHUNKED_ENC(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_CHUNKED_ENC, \
|
||||
.val.chunked_enc = (val) \
|
||||
.val.chunked_enc = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_CONN_CLOSE(val) \
|
||||
# define MHD_R_OPTION_CONN_CLOSE(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_CONN_CLOSE, \
|
||||
.val.conn_close = (val) \
|
||||
.val.conn_close = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -243,14 +243,14 @@ struct MHD_ResponseOptionAndValue
|
||||
* + chunked: no
|
||||
*
|
||||
This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT(val) \
|
||||
# define MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT, \
|
||||
.val.http_1_0_compatible_strict = (val) \
|
||||
.val.http_1_0_compatible_strict = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -266,27 +266,27 @@ This option can be used to communicate with some broken client, which does not i
|
||||
* + chunked: no
|
||||
*
|
||||
With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_HTTP_1_0_SERVER(val) \
|
||||
# define MHD_R_OPTION_HTTP_1_0_SERVER(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_HTTP_1_0_SERVER, \
|
||||
.val.http_1_0_server = (val) \
|
||||
.val.http_1_0_server = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
# define MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH(val) \
|
||||
# define MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH(value) \
|
||||
MHD_NOWARN_COMPOUND_LITERALS_ \
|
||||
(const struct MHD_ResponseOptionAndValue) \
|
||||
{ \
|
||||
.opt = MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH, \
|
||||
.val.insanity_header_content_length = (val) \
|
||||
.val.insanity_header_content_length = (value) \
|
||||
} \
|
||||
MHD_RESTORE_WARN_COMPOUND_LITERALS_
|
||||
/**
|
||||
@@ -324,17 +324,17 @@ MHD_NOWARN_UNUSED_FUNC_
|
||||
* Make the response object re-usable. (FIXME: not used in struct ResponseOptions; remove!?)
|
||||
* The response will not be consumed by MHD_action_from_response() and must be destroyed by MHD_response_destroy().
|
||||
* Useful if the same response is often used to reply.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_REUSABLE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_REUSABLE;
|
||||
opt_val.val.reusable = (val); \
|
||||
opt_val.val.reusable = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -346,17 +346,17 @@ MHD_R_OPTION_REUSABLE (
|
||||
* This flag value can be used only with responses created without body (zero-size body).
|
||||
* Responses with this flag enabled cannot be used in situations where reply body must be sent to the client.
|
||||
* This flag is primarily intended to be used when automatic 'Content-Length' header is undesirable in response to HEAD requests.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HEAD_ONLY_RESPONSE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HEAD_ONLY_RESPONSE;
|
||||
opt_val.val.head_only_response = (val); \
|
||||
opt_val.val.head_only_response = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -365,17 +365,17 @@ MHD_R_OPTION_HEAD_ONLY_RESPONSE (
|
||||
/**
|
||||
* Force use of chunked encoding even if the response content size is known.
|
||||
* Ignored when the reply cannot have body/content.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CHUNKED_ENC (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CHUNKED_ENC;
|
||||
opt_val.val.chunked_enc = (val); \
|
||||
opt_val.val.chunked_enc = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -383,17 +383,17 @@ MHD_R_OPTION_CHUNKED_ENC (
|
||||
|
||||
/**
|
||||
* Force close connection after sending the response, prevents keep-alive connections and adds 'Connection: close' header.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_CONN_CLOSE (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_CONN_CLOSE;
|
||||
opt_val.val.conn_close = (val); \
|
||||
opt_val.val.conn_close = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -410,17 +410,17 @@ MHD_R_OPTION_CONN_CLOSE (
|
||||
* + chunked: no
|
||||
*
|
||||
This option can be used to communicate with some broken client, which does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_COMPATIBLE_STRICT;
|
||||
opt_val.val.http_1_0_compatible_strict = (val); \
|
||||
opt_val.val.http_1_0_compatible_strict = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -439,17 +439,17 @@ MHD_R_OPTION_HTTP_1_0_COMPATIBLE_STRICT (
|
||||
* + chunked: no
|
||||
*
|
||||
With this option HTTP/1.0 server is emulated (with support for 'keep-alive' connections).
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_HTTP_1_0_SERVER (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_HTTP_1_0_SERVER;
|
||||
opt_val.val.http_1_0_server = (val); \
|
||||
opt_val.val.http_1_0_server = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
@@ -458,17 +458,17 @@ MHD_R_OPTION_HTTP_1_0_SERVER (
|
||||
/**
|
||||
* Disable sanity check preventing clients from manually setting the HTTP content length option.
|
||||
* Allow to set several 'Content-Length' headers. These headers will be used even with replies without body.
|
||||
* @param val the value of the parameter * @return structure with the requested setting
|
||||
* @param value the value of the parameter * @return structure with the requested setting
|
||||
*/
|
||||
static MHD_INLINE struct MHD_ResponseOptionAndValue
|
||||
MHD_R_OPTION_INSANITY_HEADER_CONTENT_LENGTH (
|
||||
enum MHD_Bool val
|
||||
enum MHD_Bool value
|
||||
)
|
||||
{
|
||||
struct MHD_ResponseOptionAndValue opt_val;
|
||||
|
||||
opt_val.opt = MHD_R_O_INSANITY_HEADER_CONTENT_LENGTH;
|
||||
opt_val.val.insanity_header_content_length = (val); \
|
||||
opt_val.val.insanity_header_content_length = (value); \
|
||||
|
||||
return opt_val;
|
||||
}
|
||||
|
||||
@@ -410,13 +410,13 @@ dump_option_macros (const char *name,
|
||||
desc));
|
||||
}
|
||||
if (0 == desct)
|
||||
printf (" * @param val the value of the parameter");
|
||||
printf (" * @param value the value of the parameter");
|
||||
printf (" * @return structure with the requested setting\n */\n");
|
||||
printf ("# define MHD_%c_OPTION_%s(",
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == argc)
|
||||
printf ("val");
|
||||
printf ("value");
|
||||
else
|
||||
for (unsigned int i = 0; i<argc; i++)
|
||||
{
|
||||
@@ -434,7 +434,7 @@ dump_option_macros (const char *name,
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == argc)
|
||||
printf (" .val.%s = (val) \\\n",
|
||||
printf (" .val.%s = (value) \\\n",
|
||||
lowercase (name));
|
||||
else
|
||||
for (unsigned int i = 0; i<argc; i++)
|
||||
@@ -491,7 +491,7 @@ dump_option_static_functions (const char *name,
|
||||
desc));
|
||||
}
|
||||
if (0 == desct)
|
||||
printf (" * @param val the value of the parameter");
|
||||
printf (" * @param value the value of the parameter");
|
||||
printf (" * @return structure with the requested setting\n */\n");
|
||||
printf ("static MHD_INLINE struct MHD_%sOptionAndValue\n"
|
||||
"MHD_%c_OPTION_%s (\n",
|
||||
@@ -499,7 +499,7 @@ dump_option_static_functions (const char *name,
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == argc)
|
||||
printf (" %s val",
|
||||
printf (" %s value",
|
||||
NULL != type
|
||||
? type
|
||||
: arguments[0]);
|
||||
@@ -527,7 +527,7 @@ dump_option_static_functions (const char *name,
|
||||
(char) toupper (*category),
|
||||
uppercase (name));
|
||||
if (0 == argc)
|
||||
printf (" opt_val.val.%s = (val); \\\n",
|
||||
printf (" opt_val.val.%s = (value); \\\n",
|
||||
lowercase (name));
|
||||
else
|
||||
for (unsigned int i = 0; i<argc; i++)
|
||||
@@ -576,7 +576,7 @@ dump_option_documentation_functions (const char *name,
|
||||
desc));
|
||||
}
|
||||
if (0 == desct)
|
||||
fprintf (f, " * @param val the value of the parameter");
|
||||
fprintf (f, " * @param value the value of the parameter");
|
||||
fprintf (f, " * @return structure with the requested setting\n */\n");
|
||||
fprintf (f,"struct MHD_%sOptionAndValue\n"
|
||||
"MHD_%c_OPTION_%s (\n",
|
||||
@@ -585,7 +585,7 @@ dump_option_documentation_functions (const char *name,
|
||||
uppercase (name));
|
||||
if (0 == argc)
|
||||
fprintf (f,
|
||||
" %s val",
|
||||
" %s value",
|
||||
NULL != type
|
||||
? type
|
||||
: arguments[0]);
|
||||
|
||||
Reference in New Issue
Block a user