Commit Graph
361 Commits
Author SHA1 Message Date
Christian Grothoff 6ee22efc8b From:
"Junker, Gregory" <gregory.junker@intel.com>
Date:
12/04/2014 12:30 AM
To:
"libmicrohttpd@gnu.org" <libmicrohttpd@gnu.org>

Hi all

I need a tiny addition made to connection.c.

In keepalive_possible(), can we change the line that says

    if (0 == strcasecmp (end, "close"))

to



    if (0 == strcasecmp (end, "close") || 0 == strcasecmp (end, "upgrade"))

?

This would make it possible to use libmicrohttpd in a WebSocket (RFC6455) environment. Currently, the way that the WebSocket protocol works, it sends "Connection: Upgrade" in the headers with the initial handshake, which causes this check to fail and (ultimately) insert "Connection: Keep-Alive" in the response headers (which cause any compliant WebSocket client to fail the handshake, since it needs "Connection: Upgrade" in the response headers, and there is no way to remove this keepalive header from the response from outside of MHD, as it is added automatically to the response buffer).

Note that this is only an HTTP/1.1 issue, AFAIK (I am pretty sure, though not positive, that WebSocket is not compatible with HTTP/1.0).

Thanks!
Greg
2014-12-03 23:47:40 +00:00
Christian Grothoff 774e50c035 Hi Christian,
the recently added MHD_DAEMON_INFO_CURRENT_CONNECTIONS can return quite
outdated values in MHD_USE_THREAD_PER_CONNECTION mode. The reason is
that closed connections are collected in MHD_cleanup_connections, which
is called only from the select thread. In the
MHD_USE_THREAD_PER_CONNECTION mode that happens only after accepting an
connection -- therefore, the last connection is always not collected and
MHD_DAEMON_INFO_CURRENT_CONNECTIONS returns >= 1, even when there are no
connections. That makes it very unusable to detect whether all
connections have been handled.

Would you consider the attached patch, which calls
MHD_cleanup_connections whenever MHD_DAEMON_INFO_CURRENT_CONNECTIONS is
called? It makes MHD_DAEMON_INFO_CURRENT_CONNECTIONS slower, but the
returned value is much more accurate.

Cheers,
Milan Straka
2014-11-18 12:54:01 +00:00
Christian Grothoff fd94723863 Hi Christian,
I attach the first attempt on SO_REUSEPORT. The patch is available
either at https://github.com/foxik/libmicrohttpd/commit/9ce9422742e10458f87275ea202a982e00c2b88c
or attached. (It is against the version with
MHD_DAEMON_OPTION_CURRENT_CONNECTIONS, but I can rebase it to current
SVN HEAD if you want.)

It seems that a reasonably multiplatform way of detecting SO_REUSEPORT is
  #ifdef SO_REPOSEPORT
which is used for example by Perl. For SO_EXCLUSIVEADDRUSE, the same
strategy seems to work too, according to Windows SDK headers and MinGW
WinAPI headers.

The current patch adds an option to allowing/disallowing address:port
reuse. One remark:
- currently both nonexisting SO_xxx and setsockopt failure are fatal and
  MHD_start_daemon fails. That may be too harsh -- maybe the
  MHD_OPTION_LISTENING_ADDRESS_REUSE should be only a hint.

  Nevertheless, as one can freely not use
  MHD_OPTION_LISTENING_ADDRESS_REUSE option, I chose the "fail on error"
  behaviour.

Thanks,
cheers,
Milan Straka

Original patch modified to get rid of some redundant USE_DEBUG
checks, fix indentation, and #ifndef SO_REUSEPORT on Linux,
we try be #defining it to 15 ourselves.
2014-10-29 19:50:58 +00:00
Christian Grothoff d50980a765 From: Milan Straka <fox@ucw.cz>
Date: Wed, 29 Oct 2014 09:59:09 +0100
Subject: [PATCH 2/2] Add MHD_DAEMON_INFO_CURRENT_CONNECTIONS to
 MHD_DaemonInfoType.

The MHD_DAEMON_INFO_CURRENT_CONNECTIONS returns number of current
connections handled by the daemon.

Useful after MHD_quiesce_daemon to find out whether all connections
have been served.
2014-10-29 15:29:31 +00:00
Christian Grothoff 67d953de64 -preping for release 0.9.38 2014-10-03 12:40:39 +00:00
Christian Grothoff ee47d16366 fix '+' unescape logic for URI-encoded POST data 2014-09-29 20:35:58 +00:00
Christian Grothoff 9e8530eea8 fix #3543 2014-09-12 15:35:01 +00:00
Christian Grothoff ed9dfcdad4 fix failure to terminate quickly in thread-per-connection mode if clients have open connections 2014-06-26 19:07:19 +00:00
Christian Grothoff 44467484f7 better fix for the concurrent response modification issue: do not modify response to add extra headers, only add them into the connection output buffer 2014-06-22 10:25:46 +00:00
Christian Grothoff 86cbb04673 lock when modifying response object to add missing headers 2014-06-21 22:22:55 +00:00
Christian Grothoff 69cacd7e02 -fix lack of adding listen FD to epoll set for external select before first call to MHD_run (see mailinglist) 2014-06-19 15:35:25 +00:00
Christian Grothoff ea8bac4745 adding MHD_set_response_options function 2014-06-08 13:11:50 +00:00
Christian Grothoff 1f4a53507e fix #3413 2014-06-01 22:08:47 +00:00
Christian Grothoff d71165ed3a second attempt to properly commit patch for #3392 2014-05-28 13:48:57 +00:00
Christian Grothoff 07e0a5ea0a releasing 0.9.36 2014-05-25 18:20:18 +00:00
Christian Grothoff 14a0065869 never notify twice 2014-05-17 04:47:33 +00:00
Christian Grothoff 51da5739fe -fix #3397 2014-05-13 16:26:49 +00:00
Christian Grothoff cb4bd812c4 Bernd Kuhls <berndkuhls@hotmail.com> wrote:
Hi,

the latest release added

AC_CHECK_FILE([$with_gnutls/include/gnutls/gnutls.h],

to configure.ac which is not cross-compile aware, for the precise error 
message have a look at the bottom of 
http://autobuild.buildroot.net/results/cb2/cb2cec1295a40667a3c21060864dd0e65a
312c3e/build-end.log

The following patch fixes the problem

--- configure.ac       2014-05-02 20:38:40.000000000 +0200
+++ configure.ac   2014-05-04 09:17:00.000000000 +0200
@@ -639,8 +639,7 @@
         SAVE_CPPFLAGS="$CPPFLAGS"
         LDFLAGS="-L$with_gnutls/lib $LDFLAGS"
         CPPFLAGS="-I$with_gnutls/include $CPPFLAGS"
-        AC_CHECK_FILE([$with_gnutls/include/gnutls/gnutls.h],
-          [AC_CHECK_HEADERS([gnutls/gnutls.h],
+          AC_CHECK_HEADERS([gnutls/gnutls.h],
             [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
               [
                 GNUTLS_CPPFLAGS="-I$with_gnutls/include"
@@ -648,7 +647,7 @@
                 GNUTLS_LIBS="-lgnutls"
                 AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB
([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])])
                 have_gnutls=yes
-              ])])])
+              ])])
         AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find 
usable libgnutls at specified prefix $with_gnutls])])
         LDFLAGS="$SAVE_LDFLAGS"
         CPPFLAGS="$SAVE_CPPFLAGS"

Regards, Bernd
2014-05-04 09:06:27 +00:00
Christian Grothoff 7231b7f830 fix #3391 2014-05-02 18:43:17 +00:00
Christian Grothoff 1bd97426ba fix rare epoll/resume issue, also simplifying logic 2014-05-02 18:37:35 +00:00
Christian Grothoff 312d11ec19 fix #3392 as suggested by reporter 2014-05-02 18:23:58 +00:00
Christian Grothoff 14ca1719e9 fix #3371 2014-04-10 07:43:05 +00:00
Evgeny Grin (Karlson2k) 2bffe00f07 Added ability to use native W32 threads, added --with-threads=LIB configure parameter 2014-04-08 14:46:06 +00:00
Christian Grothoff ca3a7d621c add MHD_OPTION_HTTPS_MEM_DHPARAMS to support PFS 2014-04-07 11:27:18 +00:00
Evgeny Grin (Karlson2k) e1fbd3e574 ChangeLog update 2014-04-01 06:16:22 +00:00
Evgeny Grin (Karlson2k) 36394bd3bd Fixed typo in ChangeLog 2014-03-29 15:17:23 +00:00
Evgeny Grin (Karlson2k) 52a6587591 Added new function MHD_is_feature_supported() 2014-03-29 15:13:33 +00:00
Evgeny Grin (Karlson2k) 3bc4813f52 Increased FD_SETSIZE for W32, added MHD_get_fdset2 2014-03-27 13:49:19 +00:00
Evgeny Grin (Karlson2k) bb8f952bef Fix limiting by IPv6 address 2014-03-25 11:55:32 +00:00
Evgeny Grin (Karlson2k) 582da7168a more checks for FD_SETSIZE, implemented check for FD_SETSIZE on W32 2014-03-25 08:05:52 +00:00
Evgeny Grin (Karlson2k) 5988eb9204 Update ChangeLog 2014-03-05 13:21:23 +00:00
Evgeny Grin (Karlson2k) b33a2d2436 ChangeLog and AUTHORS update 2014-02-26 17:55:54 +00:00
Christian Grothoff 756e2da381 version bumping 2014-02-24 22:33:49 +00:00
Evgeny Grin (Karlson2k) a9474fdab2 Remove plibc leftover, update ChangeLog and docs 2014-02-18 20:05:14 +00:00
Christian Grothoff 5ae9cc7f06 size_t vs. int fixes by Evgeny Grin, plus some additional fixes by CG 2014-02-08 14:09:04 +00:00
Christian Grothoff dd902f337b Luke-Jr wrote:
MHD_USE_DUAL_STACK in libmicrohttpd currently just *inhibits setting* the 
IPV6_V6ONLY socket option, but per Microsoft's documentation 
http://msdn.microsoft.com/en-us/library/windows/desktop/bb513665(v=vs.85).aspx
the default on Windows is that this is enabled, thus MHD_USE_DUAL_STACK will 
not work (since it leaves the default). libmicrohttpd should probably just 
unconditionally set IPV6_V6ONLY to the desired value when the option is 
available.

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 0a33b77..3cbf28e 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3493,8 +3493,7 @@ MHD_start_daemon_va (unsigned int flags,
 	}
       daemon->socket_fd = socket_fd;
 
-      if ( (0 != (flags & MHD_USE_IPv6)) &&
-	   (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)) )
+      if (0 != (flags & MHD_USE_IPv6))
 	{
 #ifdef IPPROTO_IPV6
 #ifdef IPV6_V6ONLY
@@ -3503,10 +3502,11 @@ MHD_start_daemon_va (unsigned int flags,
 	     and may also be missing on older POSIX systems; good luck if you have 
any of those,
 	     your IPv6 socket may then also bind against IPv4 anyway... */
 #ifndef WINDOWS
-	  const int on = 1;
+	  const int
 #else
-	  const char on = 1;
+	  const char
 #endif
+		 on = (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK));
 	  if ( (0 > SETSOCKOPT (socket_fd,
 				IPPROTO_IPV6, IPV6_V6ONLY,
 				&on, sizeof (on))) &&
2014-01-22 08:47:48 +00:00
Christian Grothoff e4e05d001c enable use of keep-alive with http 1.0 if explicitly requested by the client 2014-01-01 20:43:44 +00:00
Christian Grothoff a372d23b4e -hide symbols 2013-12-24 11:28:30 +00:00
Christian Grothoff 324e9852db -work around compiler warnings 2013-12-22 13:55:17 +00:00
Christian Grothoff 33affa9d1e -releasing 0.9.33 2013-12-21 16:30:55 +00:00
Christian Grothoff 9889fd9eee add support for SNI 2013-12-21 16:28:54 +00:00
Christian Grothoff 00a9277f49 -fix postexample 2013-12-21 16:27:06 +00:00
Christian Grothoff e82e13bba5 fixing #3179 2013-12-09 20:43:13 +00:00
Christian Grothoff 38fad29b45 -fix build issue without HTTPS and compiler warnings, as reported by Dilyan Palauzov
on the mailinglist
2013-12-06 23:45:41 +00:00
Christian Grothoff d9999d6650 -version bumps and chlogs for 0.9.32 release 2013-12-03 20:33:47 +00:00
Christian Grothoff 04ca76e78e Adding Matt Holiday's fixes to suspend/resume logic
(plus documentation updates).
2013-12-03 20:11:34 +00:00
Christian Grothoff 4245c6e9c3 eliminate theoretical stack overflow 2013-11-29 19:18:51 +00:00
Christian Grothoff 8ba82afc4b -fix shutdown race for wpipe on non-Linux systems 2013-11-26 00:28:14 +00:00
Christian Grothoff 74e0a68567 -fixes to MHD_suspend_connection 2013-11-25 21:51:08 +00:00
Christian Grothoff 3fb38e6948 -fix post processor, expanded test suite to cover garbage before payload 2013-10-30 08:35:28 +00:00