Class: Mongrel::DeflateFilter

### Home Classes Methods

### In Files

- lib/mongrel/handlers.rb

### Parent

Mongrel::HttpHandler

### Methods

- ::new
- #process

### Included Modules

- Zlib

### Files

- CHANGELOG
- COPYING
- LICENSE
- README
- Makefile

### Class/Module Index

Quicksearch

- Mongrel
- Mongrel::CGIWrapper
- Mongrel::Camping
- Mongrel::Camping::CampingHandler
- Mongrel::Command
- Mongrel::Command::Base
- Mongrel::Command::Registry
- Mongrel::Configurator
- Mongrel::Const
- Mongrel::DeflateFilter
- Mongrel::DirHandler
- Mongrel::Error404Handler
- Mongrel::Gems
- Mongrel::HeaderOut
- Mongrel::HttpHandler
- Mongrel::HttpHandlerPlugin
- Mongrel::HttpParams
- Mongrel::HttpParser
- Mongrel::HttpParserError
- Mongrel::HttpRequest
- Mongrel::HttpResponse
- Mongrel::HttpServer
- Mongrel::Rails
- Mongrel::Rails::RailsConfigurator
- Mongrel::Rails::RailsHandler
- Mongrel::RedirectHandler
- Mongrel::StatisticsFilter
- Mongrel::Stats
- Mongrel::StatusHandler
- Mongrel::StopServer
- Mongrel::TimeoutError
- Mongrel::URIClassifier
- Mongrel::URIClassifier::RegistrationError
- Mongrel::URIClassifier::UsageError
- RequestLog
- RequestLog::Access
- RequestLog::Files
- RequestLog::Objects
- RequestLog::Params
- RequestLog::Threads
- IO
- Kernel
- MongrelDbg
- TCPServer

No matching classes.

# Mongrel::DeflateFilter

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.

### Constants

HTTP_ACCEPT_ENCODING

### Public Class Methods

new(ops={}) click to toggle source

    # File lib/mongrel/handlers.rb, line 293
    def initialize(ops={})
      @options = ops
      @always_deflate = ops[:always_deflate] || false
    end

### Public Instance Methods

process(request, response) click to toggle source

    # File lib/mongrel/handlers.rb, line 298
    def process(request, response)
      accepts = request.params[HTTP_ACCEPT_ENCODING]
      # only process if they support compression
      if @always_deflate or (accepts and (accepts.include? "deflate" and not response.body_sent))
        response.header["Content-Encoding"] = "deflate"
        response.body = deflate(response.body)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.