libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] upgrading connection


From: Evgeny Grin
Subject: Re: [libmicrohttpd] upgrading connection
Date: Wed, 20 Apr 2016 18:03:39 +0300
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2


On 20.04.2016 15:28, José Bollo wrote:
> I implement web-socket upgrading and it worked very well with firefox.
> The bad happens when I use Chromium. The following little patch of the
> function 'keepalive_possible' of 'connection.c' solves the issue:
> 
> --- a/connection.c
> +++ b/connection.c
> @@ -733,8 +733,7 @@
>    {
>      if (NULL == end)
>        return MHD_YES;
> -    if ( (MHD_str_equal_caseless_ (end, "close")) ||
> -         (MHD_str_equal_caseless_ (end, "upgrade")) )
> +    if ( (MHD_str_equal_caseless_ (end, "close")) )
>        return MHD_NO;
>     return MHD_YES;
>    }
> 
> Explanation: I use MHD_suspend_connection and MHD_resume_connection to
> handle the connection that MHD created (MHD listens and creates
> connections). The connection is suspended in the callback
> MHD_OPTION_NOTIFY_COMPLETED, after sending the HTTP reply 101 'switching
> protocols'. I enjoy that MHD can send the reply.
> 
> But chromium emits the header "connection: upgrade\r\n" when firefox
> emits the header "connection: keep-alive, upgrade\r\n". This has the
> effect that the connection is closed unexpectedly for chromium but not
> for firefox.
> 
> So here is my mind: (1) there is a bug in 'keepalive_possible' that
> doesn't handle multiple keys for 'connection' (but maybe HTTP states
> that only one key is possible, I haven't checked) (2) my patch is the
> smallest one that solves my problem (3) what is the official path for
> upgrading a connection? If none, do you agree that the use of
> suspend/resume is a good idea? If yes, the patch should be upstreamed to
> avoid the closing of the connection when "connection: upgrade\r\n"
> appears.

Multiple "connection: " and multiple values for "connection: " header is
not correctly supported now. It need improvement so code will handle all
possible situation according to RFC. However in practice, browser sends
only single value. "upgrade" is the exception, but "upgrade" is not
supported currently. We are collecting ideas how to support "upgrade" in
the best way, you can see some preliminary drafts in disabled part of
microhttpd.h (look for "MHD_UpgradeAction").

Not sure that MHD_suspend_connection()/MHD_resume_connection() are
designed to be used in such way. MHD keeps internal stage of connection
processing and it's not updated after MHD_resume_connection().
How did you obtain socket FD and when you are calling
MHD_resume_connection()?

-- 
Best Wishes,
Evgeny Grin

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]