From f2754fd787a3e879553471988b259578363084ea Mon Sep 17 00:00:00 2001 From: zedshaw Date: Tue, 23 May 2006 12:46:05 +0000 Subject: Improved tests increasing test coverage. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@210 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel/handlers.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/mongrel/handlers.rb') 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 -- cgit v1.2.3-24-ge0c7