class Rack::Response

Required as Rack 1.5.x series removed the default content type of text/html for some unknown reason, something about “adhering to standards for HTTP 1.0 and 1.1 protocols” Was removed in this commit: github.com/rack/rack/commit/3623d04526b953a63bfb3e72de2d6920a042563f#L2L21

Public Class Methods

new(body=[], status=200, header={}) { |self| ... } click to toggle source
# File lib/contour/fixes/rack.rb, line 21
def initialize(body=[], status=200, header={})
  @status = status.to_i
  @header = Utils::HeaderHash.new("Content-Type" => "text/html").merge(header) # This is the modified line that requires Content-Type set to text/html.

  @chunked = "chunked" == @header['Transfer-Encoding']
  @writer  = lambda { |x| @body << x }
  @block   = nil
  @length  = 0

  @body = []

  if body.respond_to? :to_str
    write body.to_str
  elsif body.respond_to?(:each)
    body.each { |part|
      write part.to_s
    }
  else
    raise TypeError, "stringable or iterable required"
  end

  yield self  if block_given?
end