Hey John,

I use something similar...in fact I think I stole it from an older post from 
you, IIRC. However, I guess my point was, that the mechanism is all there in 
4.5. The *only* thing that is needed for ns_return's to return compressed data 
is to set a flag (via Ns_ConnSetGzipFlag)...that's it. It's seems like a shame 
to me to let that go to waste...

Thanks,
     --brett

----- Original Message ----
From: John Buckman <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, April 8, 2008 2:59:44 PM
Subject: Re: [AOLSERVER] Compression

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.





      
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


--
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