Sha256: cfb4d7656806717f4d52425000887f7d4ec6473af20247e47bfad4a280946f33

Contents?: true

Size: 666 Bytes

Versions: 3

Compression:

Stored size: 666 Bytes

Contents

module Innate

  # In order to reset the body contents we also need to reset the length set by
  # Response#write - until I can submit a patch to Rack and the next release we
  # just do this.

  class Response < Rack::Response
    include Optioned

    options.dsl do
      o "Default headers, will not override headers already set",
        :headers, {'Content-Type' => 'text/html'}
    end

    attr_accessor :length

    def reset
      self.status = 200
      self.header.delete('Content-Type')
      body.clear
      self.length = 0
      self
    end

    def finish
      options.headers.each{|key, value| self[key] ||= value }
      super
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
manveru-innate-2009.04.01 lib/innate/response.rb
manveru-innate-2009.04.08 lib/innate/response.rb
innate-2009.04.12 lib/innate/response.rb