> I wouldn't mind seeing hooks, especially if they can be made more generic;
> gzip is today's problem, but I'm sure there will be another down the road.
> It would be nice to be able to have a stack of stream postprocessors, of
> which gzip compression could be one.  Another module to get pushed onto
> the stack might be rate-limiting (so that a greedy client gets no more
> than x bytes per second; different from connection throttling, which needs
> to be done at the front of the request).

I have not had the opportunity to delve too far into how the latest
AOLServer handles its I/O, although I know that it is somewhat (mostly?)
independent of the core Tcl_Channel's based on an earlier I18N discussion
(and I understand this is in large part historical).

In any case, I did want to mention that since 8.2 Tcl has had stacked
channels in the core.  Extensions like Trf, memchan and TLS use this
to do compression and/or encryption on channels transparent to the user.
gzip gets a bit more complicated because you have to stack multiple
things to get it right (compression and checksums), but it can still
be wrapped in a transparent manner.  The same could go for ssl
encryption, which is in fact what tclhttpd uses, simply like so:

package require http
package require tls

http::register https 443 \
        [list ::tls::socket -require 1 -cafile ./server.pem]

set tok [http::geturl https://developer.netscape.com/]

That builds on hooks in the http library, but basically says that if
we are accessing something on port 443 (default https port), apply
the tls::socket transform (stack) onto the channel (with a few options
that pertain to SSL stuff).

It would be nice to move towards this model in the AOLServer internals.

BTW, with the attached gzip.tcl file and Trf (part of ActiveTcl 8.4.1),
the following code would create a valid gzip file:

package require gzip; # in turn requires Trf
set filename example.txt
set ifid [open $filename]
set ofid [open $filename.gz w]
gzip::open $ofid; # actually attaches transforms, writes header
fcopy $ifid $ofid
gzip::close $ofid; # detaches transforms, writes crc trailer
close $ifid
close $ofid

Consider the gzip open/close could also be named attach/detach.

  Jeff Hobbs                     The Tcl Guy
  Senior Developer               http://www.ActiveState.com/
      Tcl Support and Productivity Solutions

Attachment: gzip.tcl
Description: Binary data

Reply via email to