Class: Ronin::Recon::Values::URL
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::URL
- Defined in:
- lib/ronin/recon/values/url.rb
Overview
Represents a discovered URL.
Instance Attribute Summary collapse
-
#body ⇒ String?
readonly
The HTTP response body for the URI.
-
#headers ⇒ Hash{String => String}?
readonly
The HTTP response headers for the URI.
-
#status ⇒ Integer?
readonly
The HTTP status of the URI.
-
#uri ⇒ URI::HTTP, URI::HTTPS
(also: #to_uri)
readonly
The parsed URI.
Class Method Summary collapse
-
.value_type ⇒ :url
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the URL value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#fragment ⇒ String?
The URL's fragment string.
-
#hash ⇒ Integer
The "hash" value of the URL.
-
#host ⇒ String
The URL's host name.
-
#initialize(url, status: nil, headers: nil, body: nil) ⇒ URL
constructor
Initializes the URL object.
-
#path ⇒ String
The URL's path.
-
#port ⇒ Integer
The URL's port.
-
#query ⇒ String?
The URL's query string.
-
#query_params ⇒ Hash{String => String}?
The URL's query params.
-
#scheme ⇒ String
The scheme of the URL.
-
#to_s ⇒ String
(also: #to_str)
Converts the URL object to a String.
-
#userinfo ⇒ String?
The URI's user information.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(url, status: nil, headers: nil, body: nil) ⇒ URL
Initializes the URL object.
69 70 71 72 73 74 75 |
# File 'lib/ronin/recon/values/url.rb', line 69 def initialize(url, status: nil, headers: nil, body: nil) @uri = URI(url) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ String? (readonly)
The HTTP response body for the URI.
53 54 55 |
# File 'lib/ronin/recon/values/url.rb', line 53 def body @body end |
#headers ⇒ Hash{String => String}? (readonly)
The HTTP response headers for the URI.
48 49 50 |
# File 'lib/ronin/recon/values/url.rb', line 48 def headers @headers end |
#status ⇒ Integer? (readonly)
The HTTP status of the URI.
43 44 45 |
# File 'lib/ronin/recon/values/url.rb', line 43 def status @status end |
#uri ⇒ URI::HTTP, URI::HTTPS (readonly) Also known as: to_uri
The parsed URI.
38 39 40 |
# File 'lib/ronin/recon/values/url.rb', line 38 def uri @uri end |
Class Method Details
.value_type ⇒ :url
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
210 211 212 |
# File 'lib/ronin/recon/values/url.rb', line 210 def self.value_type :url end |
Instance Method Details
#as_json ⇒ Hash{Symbol => Object}
Coerces the URL value into JSON.
190 191 192 193 194 195 196 197 |
# File 'lib/ronin/recon/values/url.rb', line 190 def as_json hash = {type: :url, url: @uri.to_s} hash[:status] = @status if @status hash[:headers] = @headers if @headers return hash end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
156 157 158 |
# File 'lib/ronin/recon/values/url.rb', line 156 def eql?(other) other.kind_of?(self.class) && @uri == other.uri end |
#fragment ⇒ String?
The URL's fragment string.
145 146 147 |
# File 'lib/ronin/recon/values/url.rb', line 145 def fragment @uri.fragment end |
#hash ⇒ Integer
The "hash" value of the URL.
166 167 168 |
# File 'lib/ronin/recon/values/url.rb', line 166 def hash [self.class, @uri].hash end |
#host ⇒ String
The URL's host name.
100 101 102 |
# File 'lib/ronin/recon/values/url.rb', line 100 def host @uri.host end |
#path ⇒ String
The URL's path.
118 119 120 |
# File 'lib/ronin/recon/values/url.rb', line 118 def path @uri.path end |
#port ⇒ Integer
The URL's port.
109 110 111 |
# File 'lib/ronin/recon/values/url.rb', line 109 def port @uri.port end |
#query ⇒ String?
The URL's query string.
127 128 129 |
# File 'lib/ronin/recon/values/url.rb', line 127 def query @uri.query end |
#query_params ⇒ Hash{String => String}?
The URL's query params.
136 137 138 |
# File 'lib/ronin/recon/values/url.rb', line 136 def query_params @uri.query_params end |
#scheme ⇒ String
The scheme of the URL.
82 83 84 |
# File 'lib/ronin/recon/values/url.rb', line 82 def scheme @uri.scheme end |
#to_s ⇒ String Also known as: to_str
Converts the URL object to a String.
178 179 180 |
# File 'lib/ronin/recon/values/url.rb', line 178 def to_s @uri.to_s end |
#userinfo ⇒ String?
The URI's user information.
91 92 93 |
# File 'lib/ronin/recon/values/url.rb', line 91 def userinfo @uri.userinfo end |