On Apr 8, 2008, at 1:54 PM, Brett Schwarz wrote:
So, from my reading, its seems as though that in 4.5, we got on the
fly ADP page compression. However, it seems as though there isn't
comparable functionality for Tcl files (i.e. ns_return). I know
there are some work arounds, but I was just curious why this was
not implemented in the core? I took a look at the sources, and it
looks fairly straight forward to add this functionality. I see
there are three possibilities:
1) modify ns_return to take a flag. The optional connid parameter
makes parsing the args a little trickier.
Current:
ns_return ?connid? status type string (is connid ever used??)
I use:
ns_return_gzipped $conn $x
which is this, and works very reliably:
proc ns_return_gzipped {conn html} {
if {[string first {gzip} [ns_set get [ns_conn headers] {Accept-
Encoding}]] == -1} {
ns_return $conn 200 text/html $html
return TCL_OK
}
# john 9/21/07 -- found that we need to convert to utf-8, it isn't
automatic
set zl [ns_zlib gzip [encoding convertto utf-8 $html]]
set h [subst {HTTP/1.0 200 OK
MIME-Version: 1.0
Server: MoochServer/4.5.0a
Connection: close
Content-Type: text/html; charset=utf-8
Content-Length: [string length $zl]
Content-Encoding: gzip
$zl}]
ns_write $conn $h
return TCL_OK
}
--
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.