Sha256: 8f418e2b284fa67eb6e7a14e31b70ff29f5533182553cc3c45026f83f71f3654

Contents?: true

Size: 576 Bytes

Versions: 43

Compression:

Stored size: 576 Bytes

Contents

require 'rack/utils'

module Rack

  # Sets the Content-Type header on responses which don't have one.
  #
  # Builder Usage:
  #   use Rack::ContentType, "text/plain"
  #
  # When no content type argument is provided, "text/html" is assumed.
  class ContentType
    def initialize(app, content_type = "text/html")
      @app, @content_type = app, content_type
    end

    def call(env)
      status, headers, body = @app.call(env)
      headers = Utils::HeaderHash.new(headers)
      headers['Content-Type'] ||= @content_type
      [status, headers, body]
    end
  end
end

Version data entries

43 entries across 40 versions & 9 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/content_type.rb
candlepin-api-0.4.0 bundle/ruby/gems/rack-1.3.5/lib/rack/content_type.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/rack-1.3.5/lib/rack/content_type.rb
rack-1.3.10 lib/rack/content_type.rb
rack-1.2.8 lib/rack/content_type.rb
rack-1.1.6 lib/rack/content_type.rb
rack-1.3.9 lib/rack/content_type.rb
rack-1.2.7 lib/rack/content_type.rb
rack-1.1.5 lib/rack/content_type.rb
rack-1.3.8 lib/rack/content_type.rb
rack-1.3.7 lib/rack/content_type.rb
rack-1.2.6 lib/rack/content_type.rb
rack-1.1.4 lib/rack/content_type.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/lib/rack/content_type.rb
rack-1.3.6 lib/rack/content_type.rb
rack-1.2.5 lib/rack/content_type.rb
rack-1.1.3 lib/rack/content_type.rb
rack-1.3.5 lib/rack/content_type.rb
rack-1.3.4 lib/rack/content_type.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/lib/rack/content_type.rb