Class: Rack::ContentType

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
rack/rack/content_type.rb

Overview

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.

Constant Summary

Class Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ContentType) initialize(app, content_type = "text/html")

Returns a new instance of ContentType



14
15
16
# File 'rack/rack/content_type.rb', line 14

def initialize(app, content_type = "text/html")
  @app, @content_type = app, content_type
end

Class Attribute Details

+ (void) key_space_limit Originally defined in module Utils

Returns the value of attribute key_space_limit

Instance Method Details

- (void) call(env)



18
19
20
21
22
23
24
25
26
27
# File 'rack/rack/content_type.rb', line 18

def call(env)
  status, headers, body = @app.call(env)
  headers = Utils::HeaderHash.new(headers)

  unless STATUS_WITH_NO_ENTITY_BODY.include?(status)
    headers['Content-Type'] ||= @content_type
  end

  [status, headers, body]
end