Class: Typhoeus::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cms_scanner/typhoeus/response.rb

Overview

Custom Response class

Instance Method Summary collapse

Instance Method Details

#htmlNokogiri::XML

Returns The response’s body parsed by Nokogiri::HTML.

Returns:

  • (Nokogiri::XML)

    The response’s body parsed by Nokogiri::HTML



7
8
9
# File 'lib/cms_scanner/typhoeus/response.rb', line 7

def html
  @html ||= Nokogiri::HTML(body.encode('UTF-8', invalid: :replace, undef: :replace))
end

#request_sizeInteger

Override of the original to ensure an integer is returned

Returns:

  • (Integer)


18
19
20
# File 'lib/cms_scanner/typhoeus/response.rb', line 18

def request_size
  super || 0
end

#sizeInteger

Returns:

  • (Integer)


23
24
25
# File 'lib/cms_scanner/typhoeus/response.rb', line 23

def size
  (body.nil? ? 0 : body.size) + (response_headers.nil? ? 0 : response_headers.size)
end

#xmlNokogiri::XML

Returns The response’s body parsed by Nokogiri::XML.

Returns:

  • (Nokogiri::XML)

    The response’s body parsed by Nokogiri::XML



12
13
14
# File 'lib/cms_scanner/typhoeus/response.rb', line 12

def xml
  @xml ||= Nokogiri::XML(body.encode('UTF-8', invalid: :replace, undef: :replace))
end