Sha256: 4ddd335da7d2a460357329d5ca60fb86a3a7014c7be9e028a62db578dc623901
Contents?: true
Size: 830 Bytes
Versions: 4
Compression:
Stored size: 830 Bytes
Contents
module Stickler::Middleware class Compression def initialize( app ) @app = app end def call( env ) status, headers, body = @app.call( env ) return [ status, headers, body ] unless status == 200 headers = ::Rack::Utils::HeaderHash.new( headers ) stream = body if compress_method = env['stickler.compression'] then headers.delete('Content-Length') case compress_method when :gzip headers['Content-Type'] = 'application/x-gzip' stream = Gem.gzip( body.first ) when :deflate headers['Content-Type'] = 'application/x-deflate' stream = Gem.deflate( body.first ) end end stream = [ stream.to_s ] unless stream.respond_to?( :each ) return [ status, headers, stream ] end end end
Version data entries
4 entries across 4 versions & 1 rubygems