Class: Milo::Main::Response
- Inherits:
-
Object
- Object
- Milo::Main::Response
- Defined in:
- lib/milo/main.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#curl ⇒ Object
readonly
Returns the value of attribute curl.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#headers_raw ⇒ Object
readonly
Returns the value of attribute headers_raw.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(curl) ⇒ Response
constructor
A new instance of Response.
- #parse_headers ⇒ Object
Constructor Details
#initialize(curl) ⇒ Response
Returns a new instance of Response.
25 26 27 28 29 30 31 32 |
# File 'lib/milo/main.rb', line 25 def initialize(curl) @curl = curl @url = curl.url @status = curl.response_code @body = curl.body_str @headers_raw = curl.header_str parse_headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def body @body end |
#curl ⇒ Object (readonly)
Returns the value of attribute curl.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def curl @curl end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def headers @headers end |
#headers_raw ⇒ Object (readonly)
Returns the value of attribute headers_raw.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def headers_raw @headers_raw end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
23 24 25 |
# File 'lib/milo/main.rb', line 23 def url @url end |
Instance Method Details
#parse_headers ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/milo/main.rb', line 34 def parse_headers hs={} return hs if headers_raw.nil? or headers_raw=="" headers_raw.split("\r\n")[1..-1].each do |h| # Rails.logger.info h m=h.match(/([^:]+):\s?(.*)/) next if m.nil? or m[2].nil? # Rails.logger.info m.inspect hs[m[1]]=m[2] end @headers=hs end |