Class: Mongrel::DeflateFilter

Class | Mongrel::DeflateFilter
In: | lib/mongrel/handlers.rb lib/mongrel/handlers.rb
Parent: | HttpHandler

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.

### Methods

new new process process

### Included Modules

Zlib Zlib

### Constants

HTTP_ACCEPT_ENCODING | = | "HTTP_ACCEPT_ENCODING"
HTTP_ACCEPT_ENCODING | = | "HTTP_ACCEPT_ENCODING"

### Public Class methods

new(ops={})

[Source]

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

new(ops={})

[Source]

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

### Public Instance methods

process(request, response)

[Source]

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

process(request, response)

[Source]

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

[Validate]