Class: Async::HTTP::Response
- Inherits:
-
Struct
- Object
- Struct
- Async::HTTP::Response
- Includes:
- Body::Buffered::Reader
- Defined in:
- lib/async/http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#status ⇒ Object
Returns the value of attribute status.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #continue? ⇒ Boolean
- #failure? ⇒ Boolean
- #preserve_method? ⇒ Boolean
- #redirection? ⇒ Boolean
- #success? ⇒ Boolean
Methods included from Body::Buffered::Reader
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
25 26 27 |
# File 'lib/async/http/response.rb', line 25 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
25 26 27 |
# File 'lib/async/http/response.rb', line 25 def headers @headers end |
#reason ⇒ Object
Returns the value of attribute reason
25 26 27 |
# File 'lib/async/http/response.rb', line 25 def reason @reason end |
#status ⇒ Object
Returns the value of attribute status
25 26 27 |
# File 'lib/async/http/response.rb', line 25 def status @status end |
#version ⇒ Object
Returns the value of attribute version
25 26 27 |
# File 'lib/async/http/response.rb', line 25 def version @version end |
Class Method Details
.[](status, headers = {}, body = []) ⇒ Object
48 49 50 51 52 |
# File 'lib/async/http/response.rb', line 48 def self.[](status, headers = {}, body = []) body = Body::Buffered.wrap(body) self.new(nil, status, nil, headers, body) end |
.for_exception(exception) ⇒ Object
54 55 56 |
# File 'lib/async/http/response.rb', line 54 def self.for_exception(exception) Async::HTTP::Response[500, {'content-type' => 'text/plain'}, ["#{exception.class}: #{exception.message}"]] end |
Instance Method Details
#continue? ⇒ Boolean
28 29 30 |
# File 'lib/async/http/response.rb', line 28 def continue? status == 100 end |
#failure? ⇒ Boolean
44 45 46 |
# File 'lib/async/http/response.rb', line 44 def failure? status >= 400 && status < 600 end |
#preserve_method? ⇒ Boolean
40 41 42 |
# File 'lib/async/http/response.rb', line 40 def preserve_method? status == 307 || status == 308 end |
#redirection? ⇒ Boolean
36 37 38 |
# File 'lib/async/http/response.rb', line 36 def redirection? status >= 300 && status < 400 end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/async/http/response.rb', line 32 def success? status >= 200 && status < 300 end |