diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-05-23 12:46:05 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-05-23 12:46:05 +0000 |
commit | f2754fd787a3e879553471988b259578363084ea (patch) | |
tree | 36a0b0e4bd5fe90fcba1d008cfdf9b3759f06b30 /lib/mongrel/handlers.rb | |
parent | 7022bfab09a2e036bf92f7892f1b4495d23f3426 (diff) | |
download | unicorn-f2754fd787a3e879553471988b259578363084ea.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@210 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel/handlers.rb')
-rw-r--r-- | lib/mongrel/handlers.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/mongrel/handlers.rb b/lib/mongrel/handlers.rb index b70568c..99aaeae 100644 --- a/lib/mongrel/handlers.rb +++ b/lib/mongrel/handlers.rb @@ -1,4 +1,5 @@ require 'mongrel/stats' +require 'zlib' # Mongrel Web Server - A Mostly Ruby Webserver and Library # @@ -273,17 +274,21 @@ module Mongrel # When added to a config script (-S in mongrel_rails) it will # look at the client's allowed response types and then gzip # compress anything that is going out. + # + # Valid option is :always_deflate => false which tells the handler to + # deflate everything even if the client can't handle it. class DeflateFilter < HttpHandler HTTP_ACCEPT_ENCODING = "HTTP_ACCEPT_ENCODING" def initialize(ops={}) @options = ops + @always_deflate = ops[:always_deflate] || false end def process(request, response) accepts = request.params[HTTP_ACCEPT_ENCODING] # only process if they support compression - if accepts and (accepts.include? "deflate" and not response.body_sent) + if @always_deflate or (accepts and (accepts.include? "deflate" and not response.body_sent)) response.header["Content-Encoding"] = "deflate" # we can't just rewind the body and gzip it since the body could be an attached file response.body.rewind |