[Libwebsockets] serving compressed http response from a zip archive

Per Bothner per at bothner.com
Tue Feb 14 03:49:06 CET 2017


On 02/13/2017 06:31 PM, Andy Green wrote:

>> If serve-from-zip support is something you'd like to include
>> in stock libwebsockets that I'm happy to help with that.
> Great.
>
> Yes this would be a nice feature I think... if storage is tight and it's, eg, large html or JS that is needed, from lws device side this costs no extra cpu with a client that can accept gzip (all browsers afaik), and delivers the same data quicker with less bandwidth (for text, with really quite considerable compression factors).  The client has to deal with it but often the clients are modern PCs or modern phones / tablets that just shrug it off.

There is a bonus in using .zip/.jar for DomTerm since I support multiple
embeddings in addition to "ldomterm" (which uses lws): For Java
applications you can use the standard JavaFX WebEngine, which means
you don't need a server at all - and in that case it is convenient to
get the resources from a .jar file.  In addition I have a Firefox/XUL
wrapper and if I bundle the domterm.xul with the html files in the
same jar file it simplifies communication between the XUL window
and the content window. (For the latter I use lws/ldomterm for ws and
pty management, but not for the resources.)

I'm working on packaging domterm for Fedora, and my goal is to use
the same jar file for all 3 purposes.

>> My immediate problem is that I use JUnZip, which I quickly
>> realized has major portability programs - it assumes both a
>> little-endian architecture and gcc __packed__ attributes.
>>
>> So I have to decide to clean up junzip (compact, familiar)
>> or use some other library (probably contrib/minizip from zlib).
>> (The former is probably easier.)
>
> zlib is already integrated to lws for permessage-deflate ws extension fwiw.

I'm using the system zlib (at least on Fedora).  Or rather JUnzip does.
That takes care of the actual uncompressing.  However, you still need to
parse and seek in the zip archive file.  For that I use JUnzip.  It's
not very complicated (for our limited needs), so it should be easy
rewrite JUnzip so it is clean and portable.

-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the Libwebsockets mailing list