class StupidCache::SerializableBody

Public Class Methods

new(app) click to toggle source
  # File lib/stupid_cache/serializable_body.rb
7 def initialize(app)
8   @app = app
9 end

Public Instance Methods

call(env) click to toggle source
   # File lib/stupid_cache/serializable_body.rb
11 def call(env)
12   code, headers, body = @app.call(env)
13   headers = Rack::Utils::HeaderHash.new(headers)
14 
15   new_body = ""
16   body.each { |part| new_body << part }
17   body.respond_to?(:close) and body.close rescue nil
18   body = [ new_body ]
19   headers.delete("Transfer-Encoding")
20   headers["Content-Length"] = new_body.size.to_s
21 
22   [ code.to_i , headers.to_hash, body ]
23 end