[Libwebsockets] "Split" HTTP Responses

"Andy Green (林安廸)" andy at warmcat.com
Thu Feb 14 14:42:34 CET 2013

On 14/02/13 21:34, the mail apparently from Andreas Wetzel included:
> Hi,
> Currently, I'm using libwebsockets v1.1 to stream live sensor-data to a
> web-interface. the data is accumulated outside of libwebsockets thread,
> submitted to client on "writeable" callback. Everything works as I would
> expect it.
> Now, I want to provide a method to save the sensor data-stream to a file
> (on the client-side). Easiest way to do so seems to be without
> websockets, but using a plain HTTP download.
> I tried to achieve a similar functionality using the LWS_CALLBACK_HTTP
> callback. But there seems no counterpart to the
> LWS_CALLBACK_SERVER_WRITEABLE callback for HTTP (or non-websockets)
> connections. Is that true?
> Does anybody know how to handle that? Or is there another (better?)
> method to send live-data to a file on client-side?
> Any help would be highly appreciated.

You are right, it's missing right now.

Originally the HTTP stuff was just added to allow lws to deliver a 
"seed" html script that would make the websocket connections from the 
client back to the server, as you can see in the test server.  That 
works fine.

The http file transfer stuff has been upgraded recently to use 
"writable" callbacks, and to stuff the send channel until just before it 
would block, but it's special for the case you have a physical file on 
the server you want to transfer: there's no general way to take care of 
writeability callback in http as there is in websocket protocol.

Actually I think that is pretty desirable to also provide it for http. 
I'll take a look at adding it shortly / tomorrow.


More information about the Libwebsockets mailing list