Updated README.rdoc again
[feedcatcher.git] / vendor / rails / actionpack / lib / action_controller / vendor / rack-1.0 / rack / content_type.rb
1 require 'rack/utils'
2
3 module Rack
4
5 # Sets the Content-Type header on responses which don't have one.
6 #
7 # Builder Usage:
8 # use Rack::ContentType, "text/plain"
9 #
10 # When no content type argument is provided, "text/html" is assumed.
11 class ContentType
12 def initialize(app, content_type = "text/html")
13 @app, @content_type = app, content_type
14 end
15
16 def call(env)
17 status, headers, body = @app.call(env)
18 headers = Utils::HeaderHash.new(headers)
19 headers['Content-Type'] ||= @content_type
20 [status, headers.to_hash, body]
21 end
22 end
23 end