class Net::HTTPOK

Success response class

Public Instance Methods

cookies() click to toggle source

Response Cookies

# File lib/tiny_grabber/http.rb, line 20
def cookies
  cookies = get_fields('set-cookie')
  cookies.map { |cookie| cookie.gsub(/\A([^;]+).*\Z/, '\1') }.join('&') if cookies
end
headers() click to toggle source

Response Headers

# 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) click to toggle source

Nokogiri object of response

# 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