[Libwebsockets] serving compressed http response from a zip archive

Per Bothner per at bothner.com
Sat Feb 11 22:23:20 CET 2017

I'm using libwebsockets for my JavaScript-based DomTerm terminal emulator
(http://domterm.org).  The "ldomterm" application is the combination of
DomTerm + libwebsockets + application code (derived from ttyd), which
optionally starts up a window in a specified browser.

It's working quite well, but for various practical reasons it might make sense to
put the "resources' (html + js + css) in a zip archive.  It seems straight-forward
to mmap the zip file, and then use JUnzip (https://github.com/jokkebk/JUnzip) to
decompress the requested file and send the data with lws_write_http.

What would be really interesting if we could send the compressed data directly,
and let the browser decompress it.  Most browsers accept gzip compressed replies,
and creating a gzip result from a deflate-compressed zip entry should be
just a matter of sending a gzip header, followed by the raw compressed zip entry,
followed by the gzip tail (using the crc32 checksum present in the zip file).

Does this make sense?  Has anyone tried something similar?
	--Per Bothner
per at bothner.com   http://per.bothner.com/

More information about the Libwebsockets mailing list