Class: Cybertrain::HttpClient::Response
- Inherits:
-
Object
- Object
- Cybertrain::HttpClient::Response
- Defined in:
- cybertrain/http_client.rb
Overview
A response: the status, the headers (names in lowercase) and the body.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
The body as received (chunked transfer coding removed), a byte String: binary under CRuby, as Net::HTTP’s is.
-
#headers ⇒ Hash{String => String}
readonly
Header names are lowercase; a header sent more than once has its values joined with “, “.
-
#status ⇒ Integer
readonly
E.g.
Instance Method Summary collapse
-
#header(name) ⇒ String?
-
#success? ⇒ Boolean
True for a 2xx status.
Instance Attribute Details
#body ⇒ String (readonly)
The body as received (chunked transfer coding removed), a byte String: binary under CRuby, as Net::HTTP’s is.
107 108 109 |
# File 'cybertrain/http_client.rb', line 107 def body @body end |
#headers ⇒ Hash{String => String} (readonly)
Header names are lowercase; a header sent more than once has its values joined with “, “.
101 102 103 |
# File 'cybertrain/http_client.rb', line 101 def headers @headers end |
#status ⇒ Integer (readonly)
Returns e.g. 200.
95 96 97 |
# File 'cybertrain/http_client.rb', line 95 def status @status end |
Instance Method Details
#header(name) ⇒ String?
118 119 120 |
# File 'cybertrain/http_client.rb', line 118 def header(name) @headers[name.to_s.downcase] end |
#success? ⇒ Boolean
Returns true for a 2xx status.
124 125 126 |
# File 'cybertrain/http_client.rb', line 124 def success? @status >= 200 && @status <= 299 end |