Class: EasyHTTP::Response
- Inherits:
-
Object
- Object
- EasyHTTP::Response
- Defined in:
- lib/easy_http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#charset ⇒ Object
readonly
Returns the value of attribute charset.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, response, default_charset = nil) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
Constructor Details
#initialize(url, response, default_charset = nil) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/easy_http/response.rb', line 8 def initialize url, response, default_charset = nil default_charset = "ASCII-8BIT" unless default_charset @url = url @status = response.code.to_i @status_message = response. @body = response.body @body = @body.encode default_charset if String.method_defined? :encode @headers = {} response.each_header { |k, v| @headers[k] = v} if response['Content-type'].nil? @charset = default_charset else @charset = determine_charset(response['Content-type'], response.body) || default_charset end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def body @body end |
#charset ⇒ Object (readonly)
Returns the value of attribute charset.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def charset @charset end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def @status_message end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/easy_http/response.rb', line 6 def url @url end |
Instance Method Details
#inspect ⇒ Object
27 28 29 |
# File 'lib/easy_http/response.rb', line 27 def inspect "#<EasyHTTP::Response @status_message='#{@status_message}'>" end |