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.
HTTP_ACCEPT_ENCODING | = | "HTTP_ACCEPT_ENCODING" |
HTTP_ACCEPT_ENCODING | = | "HTTP_ACCEPT_ENCODING" |
# File lib/mongrel/handlers.rb, line 293 293: def initialize(ops={}) 294: @options = ops 295: @always_deflate = ops[:always_deflate] || false 296: end
# File lib/mongrel/handlers.rb, line 293 293: def initialize(ops={}) 294: @options = ops 295: @always_deflate = ops[:always_deflate] || false 296: end
# 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
# 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