Class: WhatWeb::Target
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#raw_headers ⇒ Object
readonly
Returns the value of attribute raw_headers.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#response ⇒ Object
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(url, opts = {}) ⇒ Target
constructor
A new instance of Target.
- #md5sum ⇒ Object
- #open_url ⇒ Object
- #set_cookie ⇒ Object
- #tag_pattern ⇒ Object
- #text ⇒ Object
Constructor Details
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def headers @headers end |
#raw_headers ⇒ Object (readonly)
Returns the value of attribute raw_headers.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def raw_headers @raw_headers end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def raw_response @raw_response end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/whatweb/target.rb', line 7 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def status @status end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def uri @uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/whatweb/target.rb', line 9 def url @url end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
8 9 10 |
# File 'lib/whatweb/target.rb', line 8 def user_agent @user_agent end |
Class Method Details
.meta_refresh_regex ⇒ Object
49 50 51 |
# File 'lib/whatweb/target.rb', line 49 def self. /<meta[\s]+http\-equiv[\s]*=[\s]*['"]?refresh['"]?[^>]+content[\s]*=[^>]*[0-9]+;[\s]*url=['"]?([^"'>]+)['"]?[^>]*>/i end |
Instance Method Details
#build ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/whatweb/target.rb', line 22 def build @body = response.body.to_s @headers = response.headers.to_a.map { |k, v| [k.downcase, v] }.to_h @headers["set-cookie"] = if response.headers["Set-Cookie"] @raw_headers = response.headers.to_a.map { |h| h.join(":") }.join("\n") @raw_response = body + raw_headers @status = response.status @uri = response.uri end |
#md5sum ⇒ Object
37 38 39 |
# File 'lib/whatweb/target.rb', line 37 def md5sum @md5sum ||= response.md5sum end |
#open_url ⇒ Object
18 19 20 |
# File 'lib/whatweb/target.rb', line 18 def open_url HTTP.headers(user_agent: user_agent).get url end |
#set_cookie ⇒ Object
32 33 34 35 |
# File 'lib/whatweb/target.rb', line 32 def = response.headers["Set-Cookie"] .is_a?(String) ? : .join("\n") end |
#tag_pattern ⇒ Object
41 42 43 |
# File 'lib/whatweb/target.rb', line 41 def tag_pattern @tag_pattern ||= response.tag_pattern end |
#text ⇒ Object
45 46 47 |
# File 'lib/whatweb/target.rb', line 45 def text @text ||= response.text end |