"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
This commit is contained in:
Christian Grothoff
2014-12-03 23:47:40 +00:00
parent d5571974e5
commit 6ee22efc8b
3 changed files with 8 additions and 3 deletions
+4
View File
@@ -1,3 +1,7 @@
Thu Dec 4 00:43:10 CET 2014
If "Connection: upgrade" is requested, do not add
"Connection: Keep-Alive" in the response. -GJ
Tue Nov 18 13:52:29 CET 2014
Call MHD_cleanup_connections() during MHD_DAEMON_INFO_CURRENT_CONNECTIONS
processing for more accurate results. -MS
+1 -1
View File
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
* Current version of the library.
* 0x01093001 = 1.9.30-1.
*/
#define MHD_VERSION 0x00093801
#define MHD_VERSION 0x00093802
/**
* MHD-internal return code for "YES".
+3 -2
View File
@@ -524,9 +524,10 @@ keepalive_possible (struct MHD_Connection *connection)
{
if (NULL == end)
return MHD_YES;
if (0 == strcasecmp (end, "close"))
if ( (0 == strcasecmp (end, "close")) ||
(0 == strcasecmp (end, "upgrade")) )
return MHD_NO;
return MHD_YES;
return MHD_YES;
}
if (0 == strcasecmp (connection->version,
MHD_HTTP_VERSION_1_0))