[Libwebsockets] HTTP transaction before upgrading to WebSockets

Andy Green andy at warmcat.com
Mon Aug 18 13:08:15 CEST 2014



On 18 August 2014 18:07:47 GMT+08:00, sthustfo <sthustfo at gmail.com> wrote:
>Hi All,
>
>Is it possible to perform an HTTP GET transaction and then later
>upgrade to
>WS? If so, is there any sample code which I can look at for the HTTP
>request and response? Any other pointers also appreciated.

Andrew Canaday added support for HTTP keep-alive (http 1.1) recently, on the server side this should allow it OK already in git HEAD.

But for lws client side, you'll need to do some work if that's what you want.

Something like

1) patch the client connect code before it sends the upgrade headers, so that it can optionally send user callback-provided headers instead, delaying sending the upgrade header until the callback says go ahead (by returning the default 0).

2) patch the client response processing stuff to do the same trick, if the upgrade header had not yet been sent, give the user callback a chance to process the response data instead and only treat it like normal when the upgrade header had been sent

Does it make sense?

-Andy

>Thanks.
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list