Module: Rack::Response::Helpers

Included in:
MockResponse, Rack::Response
Defined in:
lib/rack/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersObject (readonly)

Headers



161
162
163
# File 'lib/rack/response.rb', line 161

def headers
  @headers
end

#original_headersObject (readonly)

Headers



161
162
163
# File 'lib/rack/response.rb', line 161

def original_headers
  @original_headers
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


150
# File 'lib/rack/response.rb', line 150

def client_error?;  @status >= 400 && @status < 500;       end

#content_lengthObject



171
172
173
174
# File 'lib/rack/response.rb', line 171

def content_length
  cl = headers["Content-Length"]
  cl ? cl.to_i : cl
end

#content_typeObject



167
168
169
# File 'lib/rack/response.rb', line 167

def content_type
  headers["Content-Type"]
end

#empty?Boolean

Returns:

  • (Boolean)


158
# File 'lib/rack/response.rb', line 158

def empty?;         [201, 204, 304].include?      @status; end

#forbidden?Boolean

Returns:

  • (Boolean)


154
# File 'lib/rack/response.rb', line 154

def forbidden?;     @status == 403;                        end

#include?(header) ⇒ Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/rack/response.rb', line 163

def include?(header)
  !!headers[header]
end

#informational?Boolean

Returns:

  • (Boolean)


147
# File 'lib/rack/response.rb', line 147

def informational?; @status >= 100 && @status < 200;       end

#invalid?Boolean

Returns:

  • (Boolean)


145
# File 'lib/rack/response.rb', line 145

def invalid?;       @status < 100 || @status >= 600;       end

#locationObject



176
177
178
# File 'lib/rack/response.rb', line 176

def location
  headers["Location"]
end

#not_found?Boolean

Returns:

  • (Boolean)


155
# File 'lib/rack/response.rb', line 155

def not_found?;     @status == 404;                        end

#ok?Boolean

Returns:

  • (Boolean)


153
# File 'lib/rack/response.rb', line 153

def ok?;            @status == 200;                        end

#redirect?Boolean

Returns:

  • (Boolean)


157
# File 'lib/rack/response.rb', line 157

def redirect?;      [301, 302, 303, 307].include? @status; end

#redirection?Boolean

Returns:

  • (Boolean)


149
# File 'lib/rack/response.rb', line 149

def redirection?;   @status >= 300 && @status < 400;       end

#server_error?Boolean

Returns:

  • (Boolean)


151
# File 'lib/rack/response.rb', line 151

def server_error?;  @status >= 500 && @status < 600;       end

#successful?Boolean

Returns:

  • (Boolean)


148
# File 'lib/rack/response.rb', line 148

def successful?;    @status >= 200 && @status < 300;       end