Class: Api2Convert::Http::Response
- Inherits:
-
Object
- Object
- Api2Convert::Http::Response
- Defined in:
- lib/api2convert/http/response.rb
Overview
A transport-agnostic HTTP response. Headers are stored with downcased keys so #header lookups are case-insensitive regardless of the sender.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#header(name) ⇒ Object
Case-insensitive header lookup.
-
#initialize(status, headers, body, reason = "") ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(status, headers, body, reason = "") ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 |
# File 'lib/api2convert/http/response.rb', line 10 def initialize(status, headers, body, reason = "") @status = status @headers = headers || {} @body = body || "" @reason = reason || "" end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/api2convert/http/response.rb', line 8 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/api2convert/http/response.rb', line 8 def headers @headers end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
8 9 10 |
# File 'lib/api2convert/http/response.rb', line 8 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/api2convert/http/response.rb', line 8 def status @status end |
Instance Method Details
#header(name) ⇒ Object
Case-insensitive header lookup. Returns nil when absent.
18 19 20 |
# File 'lib/api2convert/http/response.rb', line 18 def header(name) @headers[name.to_s.downcase] end |