Module: Rack::Response::Helpers

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersObject (readonly)

Headers



149
150
151
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 149

def headers
  @headers
end

#original_headersObject (readonly)

Headers



149
150
151
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 149

def original_headers
  @original_headers
end

Instance Method Details

#client_error?Boolean

Returns:

  • (Boolean)


138
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 138

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

#content_lengthObject



159
160
161
162
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 159

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

#content_typeObject



155
156
157
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 155

def content_type
  headers["Content-Type"]
end

#empty?Boolean

Returns:

  • (Boolean)


146
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 146

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

#forbidden?Boolean

Returns:

  • (Boolean)


142
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 142

def forbidden?;     @status == 403;                        end

#include?(header) ⇒ Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 151

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

#informational?Boolean

Returns:

  • (Boolean)


135
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 135

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

#invalid?Boolean

Returns:

  • (Boolean)


133
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 133

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

#locationObject



164
165
166
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 164

def location
  headers["Location"]
end

#not_found?Boolean

Returns:

  • (Boolean)


143
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 143

def not_found?;     @status == 404;                        end

#ok?Boolean

Returns:

  • (Boolean)


141
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 141

def ok?;            @status == 200;                        end

#redirect?Boolean

Returns:

  • (Boolean)


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

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

#redirection?Boolean

Returns:

  • (Boolean)


137
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 137

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

#server_error?Boolean

Returns:

  • (Boolean)


139
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 139

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

#successful?Boolean

Returns:

  • (Boolean)


136
# File 'lib/gems/rack-0.9.1/lib/rack/response.rb', line 136

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