Method: Rack::Lint#check_content_type

Defined in:
lib/rack/lint.rb

#check_content_type(status, headers) ⇒ Object

The Content-Type



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/rack/lint.rb', line 437

def check_content_type(status, headers)
  headers.each { |key, value|
    ## There must be a <tt>Content-Type</tt>, except when the
    ## +Status+ is 1xx, 204 or 304, in which case there must be none
    ## given.
    if key.downcase == "content-type"
      assert("Content-Type header found in #{status} response, not allowed") {
        not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
      }
      return
    end
  }
  assert("No Content-Type header found") {
    Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
  }
end