Class: HTTP::Response
- Defined in:
- lib/http_client/mri/response.rb,
lib/http_client/jruby/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(native_response, cookies) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(native_response, cookies) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/http_client/mri/response.rb', line 5 def initialize(native_response) @native_response = native_response @status_code = native_response.code.to_i @body = native_response.body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/http_client/mri/response.rb', line 3 def body @body end |
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
15 16 17 18 19 20 |
# File 'lib/http_client/mri/response.rb', line 15 def = CGI::Cookie.parse(@native_response['set-cookie']) = {} .each {|name, | [name] = .value.first} end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/http_client/mri/response.rb', line 11 def headers @native_response end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
3 4 5 |
# File 'lib/http_client/mri/response.rb', line 3 def status_code @status_code end |