Module: Rack::Response::Helpers
- Included in:
- 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
- #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
129 130 131 |
# File 'lib/rack/response.rb', line 129 def headers @headers end |
#original_headers ⇒ Object (readonly)
Headers
129 130 131 |
# File 'lib/rack/response.rb', line 129 def original_headers @original_headers end |
Instance Method Details
#client_error? ⇒ Boolean
119 |
# File 'lib/rack/response.rb', line 119 def client_error?; @status >= 400 && @status < 500; end |
#content_length ⇒ Object
139 140 141 142 |
# File 'lib/rack/response.rb', line 139 def content_length cl = headers["Content-Length"] cl ? cl.to_i : cl end |
#content_type ⇒ Object
135 136 137 |
# File 'lib/rack/response.rb', line 135 def content_type headers["Content-Type"] end |
#forbidden? ⇒ Boolean
123 |
# File 'lib/rack/response.rb', line 123 def forbidden?; @status == 403; end |
#include?(header) ⇒ Boolean
131 132 133 |
# File 'lib/rack/response.rb', line 131 def include?(header) !!headers[header] end |
#informational? ⇒ Boolean
116 |
# File 'lib/rack/response.rb', line 116 def informational?; @status >= 100 && @status < 200; end |
#invalid? ⇒ Boolean
114 |
# File 'lib/rack/response.rb', line 114 def invalid?; @status < 100 || @status >= 600; end |
#location ⇒ Object
144 145 146 |
# File 'lib/rack/response.rb', line 144 def location headers["Location"] end |
#not_found? ⇒ Boolean
124 |
# File 'lib/rack/response.rb', line 124 def not_found?; @status == 404; end |
#ok? ⇒ Boolean
122 |
# File 'lib/rack/response.rb', line 122 def ok?; @status == 200; end |
#redirect? ⇒ Boolean
126 |
# File 'lib/rack/response.rb', line 126 def redirect?; [301, 302, 303, 307].include? @status; end |
#redirection? ⇒ Boolean
118 |
# File 'lib/rack/response.rb', line 118 def redirection?; @status >= 300 && @status < 400; end |
#server_error? ⇒ Boolean
120 |
# File 'lib/rack/response.rb', line 120 def server_error?; @status >= 500 && @status < 600; end |
#successful? ⇒ Boolean
117 |
# File 'lib/rack/response.rb', line 117 def successful?; @status >= 200 && @status < 300; end |