Module: Rack::Response::Helpers

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) headers (readonly)

Headers



137
138
139
# File 'lib/rack/response.rb', line 137

def headers
  @headers
end

- (Object) original_headers (readonly)

Headers



137
138
139
# File 'lib/rack/response.rb', line 137

def original_headers
  @original_headers
end

Instance Method Details

- (Boolean) accepted?

Returns:

  • (Boolean)


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

def accepted?;           status == 202;                        end

- (Boolean) bad_request?

Returns:

  • (Boolean)


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

def bad_request?;        status == 400;                        end

- (Boolean) client_error?

Returns:

  • (Boolean)


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

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

- (Object) content_length



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

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

- (Object) content_type



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

def content_type
  headers["Content-Type"]
end

- (Boolean) created?

Returns:

  • (Boolean)


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

def created?;            status == 201;                        end

- (Boolean) forbidden?

Returns:

  • (Boolean)


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

def forbidden?;          status == 403;                        end

- (Boolean) include?(header)

Returns:

  • (Boolean)


139
140
141
# File 'lib/rack/response.rb', line 139

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

- (Boolean) informational?

Returns:

  • (Boolean)


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

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

- (Boolean) invalid?

Returns:

  • (Boolean)


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

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

- (Object) location



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

def location
  headers["Location"]
end

- (Boolean) method_not_allowed?

Returns:

  • (Boolean)


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

def method_not_allowed?; status == 405;                        end

- (Boolean) not_found?

Returns:

  • (Boolean)


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

def not_found?;          status == 404;                        end

- (Boolean) ok?

Returns:

  • (Boolean)


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

def ok?;                 status == 200;                        end

- (Boolean) redirect?

Returns:

  • (Boolean)


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

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

- (Boolean) redirection?

Returns:

  • (Boolean)


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

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

- (Boolean) server_error?

Returns:

  • (Boolean)


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

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

- (Boolean) successful?

Returns:

  • (Boolean)


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

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

- (Boolean) unauthorized?

Returns:

  • (Boolean)


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

def unauthorized?;       status == 401;                        end

- (Boolean) unprocessable?

Returns:

  • (Boolean)


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

def unprocessable?;      status == 422;                        end