Method: Rack::Lint::Wrapper#response

Defined in:
lib/rack/lint.rb

#responseObject

Raises:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/rack/lint.rb', line 87

def response
  ## It takes exactly one argument, the +environment+ (representing an HTTP request)    raise LintError, "No env given" unless @env
  check_environment(@env)

  ## and returns a non-frozen +Array+ of exactly three elements:    @response = @app.call(@env)

  raise LintError, "response is not an Array, but #{@response.class}" unless @response.kind_of? Array
  raise LintError, "response is frozen" if @response.frozen?
  raise LintError, "response array has #{@response.size} elements instead of 3" unless @response.size == 3

  @status, @headers, @body = @response
  ## the +status+,    check_status(@status)

  ## the +headers+,    check_headers(@headers)

  hijack_proc = check_hijack_response(@headers, @env)
  if hijack_proc
    @headers[RACK_HIJACK] = hijack_proc
  end

  ## and the +body+ (representing an HTTP response).
  check_content_type_header(@status, @headers)
  check_content_length_header(@status, @headers)
  check_rack_protocol_header(@status, @headers)
  @head_request = @env[REQUEST_METHOD] == HEAD

  @lint = (@env['rack.lint'] ||= []) << self

  if (@env['rack.lint.body_iteration'] ||= 0) > 0
    raise LintError, "Middleware must not call #each directly"
  end

  return [@status, @headers, self]
end