libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] suspend/resume patch


From: José Bollo
Subject: Re: [libmicrohttpd] suspend/resume patch
Date: Mon, 30 May 2016 07:10:40 +0200

Le dimanche 29 mai 2016 à 20:53 +0200, Christian Grothoff a écrit :
> On 05/17/2016 09:53 AM, José Bollo wrote:
> > 
> > Le mercredi 20 avril 2016 à 20:41 +0300, Evgeny Grin a écrit :
> > Please could check again whether the following patch that avoid to
> > close the connection when upgrade is called is valid or not.
> > 
> > diff -Naur a/src/microhttpd/connection.c
> > b/src/microhttpd/connection.c
> > --- a/src/microhttpd/connection.c   2016-04-08
> > 19:02:26.000000000
> > +0000
> > +++ b/src/microhttpd/connection.c   2016-04-08
> > 19:02:26.000000000
> > +0000
> > @@ -731,8 +731,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;
> >    }
> 
> Well, as usual the situation isn't quite that simple. As you can see
> in
> 
> http://lists.gnu.org/archive/html/libmicrohttpd/2014-12/msg00000.html
> 
> this case was actually introduced to help Gregory support "upgrade",
> so
> now you're asking us to remove to help you support "upgrade".
> Funny...

Hello Christian,

Yeap, that's really funny!

I encountered no issue with "Connection: Keep-alive" in the reply using
firefox and chrome. But I encountered the same issue than Dominic Froud
and had to use in the client of MHD a kind of 'strcasestr' when the
upgrade header had a line like "Connection: Keep-alive, Upgrade" (don't
remember is it chrome or firefox that works that way).

> As discussed in the old threat, the issue is simply more complicated
> and
> neither version will fully do; "upgrade" needs more logic in various
> places, as we need to not generate "Connection: Keep-alive" (as
> Gregory
> points out), but also not close the socket.

My current implementation (that revert SVN 34474) works (*) with chrome
and firefox (versions of today, ask for detail if expected).

I currently have no solution for HTTPS/WSS and I agree that it is an
issue. As is also an issue the ressource handling. I think that
offering an interface like beloaw could be enough to make any upgrade:

MHD_upgrade(connection, mysetup, mydata);

called in the completion callback when answer is sent, with the
function mysetup defined like:

struct upgrade_interface {
   int (*set_on_event)(void (*callback)(void
*, int, MHD_xxx *));
   ssize_t (*writev) (MHD_xxx *, const struct iovec
*, int);
   ssize_t (*readv) (MHD_xxx *, const struct iovec *, int);
 
 int (*close) (MHD_xxx *);
   int (*resume) (MHD_xxx *);
};

int mysetup(void *closure,  struct upgrade_interface *interface,
MHD_xxx *handle) ...

and it records using set_on_event a callback to handle incoming events
(data, hangup, starve, ..)

Best regards
José Bollo

(*) if curious it can be seen there https://github.com/iotbzh/afb-daemo
n/blob/master/src/afb-websock.c





reply via email to

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