[Libwebsockets] Serving a large file using LWSMPRO_CALLBACK vhost

Thomas Spitz thomas.spitz at gmail.com
Tue Jan 14 18:34:56 CET 2020


Hello,

I would like to send a large file from a vhost whose origin_protocol is
LWSMPRO_CALLBACK. I cannot use origin_protocol LWSMPRO_FILE because the URI
path and the file location are very different.

I manage to do so using lws_serve_http_file() from LWS_CALLBACK_HTTP but
this blocks the server until the file is served (websockets clients are not
updated until the end of the sending). In order to avoid such blockage, I
suppose a good design is to send the file by chunk through
LWS_CALLBACK_HTTP_WRITEABLE  in the same principle as in
minimal-http-server-dynamic?

Assuming I am right, I got back to test-server-http.c (libwesockets <2.4)
where the leaf.jpg was send "by hand" using LWS_CALLBACK_HTTP_WRITEABLE and
lws_plat_file functions but It seems that those lws_plat_file functions are
not available anymore in lws newest versions. Is it something wanted?

Thank in advance

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200114/3c2934e2/attachment.htm>


More information about the Libwebsockets mailing list