[Libwebsockets] "Split" HTTP Responses
drew at drewnoakes.com
Thu Feb 14 15:29:37 CET 2013
I too would be interested in an example that shows how to formulate a
non-file response to a web request through libwebsockets. My use case is
similar -- I'd like a client to be able to request a static dump of some
data, probably as a JSON document. This would be composed dynamically in
the same process as my libwebsockets server.
On 14 February 2013 13:42, "Andy Green (林安廸)" <andy at warmcat.com> wrote:
> On 14/02/13 21:34, the mail apparently from Andreas Wetzel included:
>> 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.
> Libwebsockets mailing list
> Libwebsockets at ml.**libwebsockets.org <Libwebsockets at ml.libwebsockets.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libwebsockets