Class: Net::HTTPOK
- Inherits:
-
Object
- Object
- Net::HTTPOK
- Defined in:
- lib/tiny_grabber/http.rb
Overview
Success response class
Instance Method Summary collapse
-
#cookies ⇒ Object
Response Cookies.
-
#headers ⇒ Object
Response Headers.
-
#ng(html_version = 4) ⇒ Object
Nokogiri object of response.
Instance Method Details
#cookies ⇒ Object
Response Cookies
20 21 22 23 |
# File 'lib/tiny_grabber/http.rb', line 20 def = get_fields('set-cookie') .map { || .gsub(/\A([^;]+).*\Z/, '\1') }.join('&') if end |
#headers ⇒ Object
Response Headers
27 28 29 30 31 |
# File 'lib/tiny_grabber/http.rb', line 27 def headers header.to_hash.each_with_object({}) do |header_key, header_value| header_value[header_key] = header_value.first end end |
#ng(html_version = 4) ⇒ Object
Nokogiri object of response
10 11 12 13 14 15 16 |
# File 'lib/tiny_grabber/http.rb', line 10 def ng(html_version = 4) if html_version == 5 Nokogiri::HTML5(body) else body.encoding.to_s != 'UTF-8' ? Nokogiri::HTML(body, 'UTF-8') : Nokogiri::HTML(body) end end |