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
161 162 163 |
# File 'lib/rack/response.rb', line 161 def headers @headers end |
#original_headers ⇒ Object (readonly)
Headers
161 162 163 |
# File 'lib/rack/response.rb', line 161 def original_headers @original_headers end |
Instance Method Details
#client_error? ⇒ Boolean
150 |
# File 'lib/rack/response.rb', line 150 def client_error?; @status >= 400 && @status < 500; end |
#content_length ⇒ Object
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_type ⇒ Object
167 168 169 |
# File 'lib/rack/response.rb', line 167 def content_type headers["Content-Type"] end |
#empty? ⇒ Boolean
158 |
# File 'lib/rack/response.rb', line 158 def empty?; [201, 204, 304].include? @status; end |
#forbidden? ⇒ Boolean
154 |
# File 'lib/rack/response.rb', line 154 def forbidden?; @status == 403; end |
#include?(header) ⇒ Boolean
163 164 165 |
# File 'lib/rack/response.rb', line 163 def include?(header) !!headers[header] end |
#informational? ⇒ Boolean
147 |
# File 'lib/rack/response.rb', line 147 def informational?; @status >= 100 && @status < 200; end |
#invalid? ⇒ Boolean
145 |
# File 'lib/rack/response.rb', line 145 def invalid?; @status < 100 || @status >= 600; end |
#location ⇒ Object
176 177 178 |
# File 'lib/rack/response.rb', line 176 def location headers["Location"] end |
#not_found? ⇒ Boolean
155 |
# File 'lib/rack/response.rb', line 155 def not_found?; @status == 404; end |
#ok? ⇒ Boolean
153 |
# File 'lib/rack/response.rb', line 153 def ok?; @status == 200; end |
#redirect? ⇒ Boolean
157 |
# File 'lib/rack/response.rb', line 157 def redirect?; [301, 302, 303, 307].include? @status; end |
#redirection? ⇒ Boolean
149 |
# File 'lib/rack/response.rb', line 149 def redirection?; @status >= 300 && @status < 400; end |
#server_error? ⇒ Boolean
151 |
# File 'lib/rack/response.rb', line 151 def server_error?; @status >= 500 && @status < 600; end |
#successful? ⇒ Boolean
148 |
# File 'lib/rack/response.rb', line 148 def successful?; @status >= 200 && @status < 300; end |