Module: Rack::Response::Helpers
- Included in:
- MockResponse, Rack::Response
- Defined in:
- lib/rack/response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Headers.
-
#original_headers ⇒ Object
readonly
Headers.
Instance Method Summary collapse
- #client_error? ⇒ Boolean
- #content_length ⇒ Object
- #content_type ⇒ Object
- #empty? ⇒ Boolean
- #forbidden? ⇒ Boolean
- #include?(header) ⇒ Boolean
- #informational? ⇒ Boolean
- #invalid? ⇒ Boolean
- #location ⇒ Object
- #not_found? ⇒ Boolean
- #ok? ⇒ Boolean
- #redirect? ⇒ Boolean
- #redirection? ⇒ Boolean
- #server_error? ⇒ Boolean
- #successful? ⇒ Boolean
Instance Attribute Details
#headers ⇒ Object (readonly)
Headers
144 145 146 |
# File 'lib/rack/response.rb', line 144 def headers @headers end |
#original_headers ⇒ Object (readonly)
Headers
144 145 146 |
# File 'lib/rack/response.rb', line 144 def original_headers @original_headers end |
Instance Method Details
#client_error? ⇒ Boolean
133 |
# File 'lib/rack/response.rb', line 133 def client_error?; @status >= 400 && @status < 500; end |
#content_length ⇒ Object
154 155 156 157 |
# File 'lib/rack/response.rb', line 154 def content_length cl = headers["Content-Length"] cl ? cl.to_i : cl end |
#content_type ⇒ Object
150 151 152 |
# File 'lib/rack/response.rb', line 150 def content_type headers["Content-Type"] end |
#empty? ⇒ Boolean
141 |
# File 'lib/rack/response.rb', line 141 def empty?; [201, 204, 304].include? @status; end |
#forbidden? ⇒ Boolean
137 |
# File 'lib/rack/response.rb', line 137 def forbidden?; @status == 403; end |
#include?(header) ⇒ Boolean
146 147 148 |
# File 'lib/rack/response.rb', line 146 def include?(header) !!headers[header] end |
#informational? ⇒ Boolean
130 |
# File 'lib/rack/response.rb', line 130 def informational?; @status >= 100 && @status < 200; end |
#invalid? ⇒ Boolean
128 |
# File 'lib/rack/response.rb', line 128 def invalid?; @status < 100 || @status >= 600; end |
#location ⇒ Object
159 160 161 |
# File 'lib/rack/response.rb', line 159 def location headers["Location"] end |
#not_found? ⇒ Boolean
138 |
# File 'lib/rack/response.rb', line 138 def not_found?; @status == 404; end |
#ok? ⇒ Boolean
136 |
# File 'lib/rack/response.rb', line 136 def ok?; @status == 200; end |
#redirect? ⇒ Boolean
140 |
# File 'lib/rack/response.rb', line 140 def redirect?; [301, 302, 303, 307].include? @status; end |
#redirection? ⇒ Boolean
132 |
# File 'lib/rack/response.rb', line 132 def redirection?; @status >= 300 && @status < 400; end |
#server_error? ⇒ Boolean
134 |
# File 'lib/rack/response.rb', line 134 def server_error?; @status >= 500 && @status < 600; end |
#successful? ⇒ Boolean
131 |
# File 'lib/rack/response.rb', line 131 def successful?; @status >= 200 && @status < 300; end |