Hi,

ZnServer now supports gzip Content-Encoding and chunked Transfer-Encoding 
(something ZnClient already did). Here is an example from the unit tests:

ZnServerTests>>#self withServerDo: [ :server | | client |
        server useGzipCompressionAndChunking: true.
        (client := ZnClient new)
                url: server localUrl;
                addPathSegment: 'dw-bench';
                setAcceptEncodingGzip;
                get.
        self assert: client isSuccess.
        self assert: client response hasContentEncoding.
        self assert: (client response headers at: 'Content-Encoding') equals: 
'gzip'.
        self assert: client response hasTransferEncoding.
        self assert: (client response headers at: 'Transfer-Encoding') equals: 
'chunked' ]

For the /dw-bench page, the actual uncompressed size is 7.6 Kb, while the 
compressed, transferred size is only 1.6 Kb (Google Chrome make it easy to see 
this difference). 

By combining a GzipWriteStream and a ZnChunkedWriteStream, streaming is 
naturally done with 4Kb buffers. 

Although the compression/decompression takes time, the profit in reduced 
transfer size is more important in almost all cases, especially for mobile 
networks. The counter examples are very small responses or responses that are 
already compressed (like most images).

For now, the #useGzipCompressionAndChunking feature is disabled by default. 
When enabled, only textual content will be compressed/chunked automatically. 
Any Zn server handler can enable compression/chunking manually for any response.

ConfigurationOfZincHTTPComponents project bleedingEdge load.

Sven

--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill


Reply via email to