There is the answer in the documentation for Tcl 8.6
http://www.tcl.tk/man/tcl8.6/TclCmd/zlib.htm#M62

And so the correct solution is:

set gzip [ns_zlib gzip [encoding convertto utf-8 $content]]
ns_write "HTTP/1.0 200 OK
Content-Type: text/plain; charset=utf-8
Content-Encoding: gzip
\n"
ns_write $gzip

Tcl 8.6 has native zlib support:

set content [encoding convertto utf-8 $content]
set gzip [binary format "H*iH*" "1f8b0800" [clock seconds] "0003"]
append gzip [zlib deflate $content 0]
append gzip [binary format i [zlib crc32 $content]]
append gzip [binary format i [string length $content]]
ns_write "HTTP/1.0 200 OK
Content-Type: text/plain; charset=utf-8
Content-Encoding: gzip
\n"
ns_write $gzip


Can somebody to add these examples to AOL documentation?

-- 
Best regards, Alexey Pechnikov.
http://pechnikov.tel/


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to 
<[email protected]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to