From ee0942b2e0ea1683d9329f45cc81b193908672ec Mon Sep 17 00:00:00 2001 From: ng0 Date: Tue, 25 Jun 2019 14:05:12 +0000 Subject: iAdd headerfile for mhd_send. --- src/microhttpd/Makefile.am | 2 +- src/microhttpd/mhd_send.c | 26 +---------------- src/microhttpd/mhd_send.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 src/microhttpd/mhd_send.h diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am index 452e8971..7a484371 100644 --- a/src/microhttpd/Makefile.am +++ b/src/microhttpd/Makefile.am @@ -62,7 +62,7 @@ libmicrohttpd_la_SOURCES = \ mhd_limits.h mhd_byteorder.h \ sysfdsetsize.c sysfdsetsize.h \ mhd_str.c mhd_str.h \ - mhd_send.c \ + mhd_send.h mhd_send.c \ mhd_assert.h \ mhd_sockets.c mhd_sockets.h \ mhd_itc.c mhd_itc.h mhd_itc_types.h \ diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index c3724cba..50013c13 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c @@ -29,14 +29,7 @@ // are used. // TODO: sendfile() wrappers. -#include "platform.h" -#include "internal.h" - -#ifdef HAVE_STDBOOL_H -#include -#endif -#include - +#include "mhd_send.h" // NOTE: TCP_CORK == TCP_NOPUSH in FreeBSD. // TCP_CORK is Linux. @@ -47,23 +40,6 @@ // the linked library needs a different setsockopt usage: // https://stackoverflow.com/questions/48670299/setsockopt-usage-in-linux-and-solaris-invalid-argument-in-solaris -enum MHD_SendSocketOptions -{ - /* definitely no corking (use NODELAY, or explicitly disable cork) */ - MHD_SSO_NO_CORK = 0, - /* should enable corking (use MSG_MORE, or explicitly enable cork) */ - MHD_SSO_MAY_CORK = 1, - /* - * consider tcpi_snd_mss and consider not corking for the header - * part if the size of the header is close to the MSS. - * Only used if we are NOT doing 100 Continue and are still - * sending the header (provided in full as the buffer to - * MHD_send_on_connection_ or as the header to - * MHD_send_on_connection2_). - */ - MHD_SSO_HDR_CORK = 2 -}; - /* * https://svnweb.freebsd.org/base/head/sys/netinet/tcp_usrreq.c?view=markup&pathrev=346360 * Approximately in 2007 work began to make TCP_NOPUSH in FreeBSD diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h new file mode 100644 index 00000000..2ff39a05 --- /dev/null +++ b/src/microhttpd/mhd_send.h @@ -0,0 +1,70 @@ +/* + This file is part of libmicrohttpd + Copyright (C) 2019 ng0 + + 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 mhd_send.h + * @brief Implementation of send() wrappers. + * @author ng0 + */ + +#ifndef MHD_SEND_H +#define MHD_SEND_H + +#include "platform.h" +#include "internal.h" + +#if defined(HAVE_STDBOOL_H) +#include +#endif /* HAVE_STDBOOL_H */ + +#include + +enum MHD_SendSocketOptions +{ + /* definitely no corking (use NODELAY, or explicitly disable cork) */ + MHD_SSO_NO_CORK = 0, + /* should enable corking (use MSG_MORE, or explicitly enable cork) */ + MHD_SSO_MAY_CORK = 1, + /* + * consider tcpi_snd_mss and consider not corking for the header + * part if the size of the header is close to the MSS. + * Only used if we are NOT doing 100 Continue and are still + * sending the header (provided in full as the buffer to + * MHD_send_on_connection_ or as the header to + * MHD_send_on_connection2_). + */ + MHD_SSO_HDR_CORK = 2 +}; + + +ssize_t +MHD_send_on_connection_ (struct MHD_Connection *connection, + const char *buffer, + size_t buffer_size, + enum MHD_SendSocketOptions options); + +ssize_t +MHD_send_on_connection2_ (struct MHD_Connection *connection, + const char *header, + size_t header_size, + const char *buffer, + size_t buffer_size); + +#endif /* MHD_SEND_H */ -- cgit v1.2.3