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
- #accepted? ⇒ Boolean
- #bad_request? ⇒ Boolean
- #client_error? ⇒ Boolean
- #content_length ⇒ Object
- #content_type ⇒ Object
- #created? ⇒ Boolean
- #forbidden? ⇒ Boolean
- #i_m_a_teapot? ⇒ Boolean
- #include?(header) ⇒ Boolean
- #informational? ⇒ Boolean
- #invalid? ⇒ Boolean
- #location ⇒ Object
- #method_not_allowed? ⇒ Boolean
- #not_found? ⇒ Boolean
- #ok? ⇒ Boolean
- #redirect? ⇒ Boolean
- #redirection? ⇒ Boolean
- #server_error? ⇒ Boolean
- #successful? ⇒ Boolean
- #unauthorized? ⇒ Boolean
- #unprocessable? ⇒ Boolean
Instance Attribute Details
#headers ⇒ Object (readonly)
Headers
140 141 142 |
# File 'lib/rack/response.rb', line 140 def headers @headers end |
#original_headers ⇒ Object (readonly)
Headers
140 141 142 |
# File 'lib/rack/response.rb', line 140 def original_headers @original_headers end |
Instance Method Details
#accepted? ⇒ Boolean
128 |
# File 'lib/rack/response.rb', line 128 def accepted?; status == 202; end |
#bad_request? ⇒ Boolean
129 |
# File 'lib/rack/response.rb', line 129 def bad_request?; status == 400; end |
#client_error? ⇒ Boolean
123 |
# File 'lib/rack/response.rb', line 123 def client_error?; status >= 400 && status < 500; end |
#content_length ⇒ Object
150 151 152 153 |
# File 'lib/rack/response.rb', line 150 def content_length cl = headers[CONTENT_LENGTH] cl ? cl.to_i : cl end |
#content_type ⇒ Object
146 147 148 |
# File 'lib/rack/response.rb', line 146 def content_type headers[CONTENT_TYPE] end |
#created? ⇒ Boolean
127 |
# File 'lib/rack/response.rb', line 127 def created?; status == 201; end |
#forbidden? ⇒ Boolean
131 |
# File 'lib/rack/response.rb', line 131 def forbidden?; status == 403; end |
#i_m_a_teapot? ⇒ Boolean
134 |
# File 'lib/rack/response.rb', line 134 def i_m_a_teapot?; status == 418; end |
#include?(header) ⇒ Boolean
142 143 144 |
# File 'lib/rack/response.rb', line 142 def include?(header) !!headers[header] end |
#informational? ⇒ Boolean
120 |
# File 'lib/rack/response.rb', line 120 def informational?; status >= 100 && status < 200; end |
#invalid? ⇒ Boolean
118 |
# File 'lib/rack/response.rb', line 118 def invalid?; status < 100 || status >= 600; end |
#location ⇒ Object
155 156 157 |
# File 'lib/rack/response.rb', line 155 def location headers["Location"] end |
#method_not_allowed? ⇒ Boolean
133 |
# File 'lib/rack/response.rb', line 133 def method_not_allowed?; status == 405; end |
#not_found? ⇒ Boolean
132 |
# File 'lib/rack/response.rb', line 132 def not_found?; status == 404; end |
#ok? ⇒ Boolean
126 |
# File 'lib/rack/response.rb', line 126 def ok?; status == 200; end |
#redirect? ⇒ Boolean
137 |
# File 'lib/rack/response.rb', line 137 def redirect?; [301, 302, 303, 307].include? status; end |
#redirection? ⇒ Boolean
122 |
# File 'lib/rack/response.rb', line 122 def redirection?; status >= 300 && status < 400; end |
#server_error? ⇒ Boolean
124 |
# File 'lib/rack/response.rb', line 124 def server_error?; status >= 500 && status < 600; end |
#successful? ⇒ Boolean
121 |
# File 'lib/rack/response.rb', line 121 def successful?; status >= 200 && status < 300; end |
#unauthorized? ⇒ Boolean
130 |
# File 'lib/rack/response.rb', line 130 def ; status == 401; end |
#unprocessable? ⇒ Boolean
135 |
# File 'lib/rack/response.rb', line 135 def unprocessable?; status == 422; end |