Class: HTTPX::Plugins::Proxy::Parameters
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Proxy::Parameters
- Defined in:
- lib/httpx/plugins/proxy.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #authenticated? ⇒ Boolean
-
#initialize(uri:, username: nil, password: nil) ⇒ Parameters
constructor
A new instance of Parameters.
- #token_authentication ⇒ Object
Constructor Details
#initialize(uri:, username: nil, password: nil) ⇒ Parameters
Returns a new instance of Parameters.
28 29 30 31 32 |
# File 'lib/httpx/plugins/proxy.rb', line 28 def initialize(uri:, username: nil, password: nil) @uri = uri.is_a?(URI::Generic) ? uri : URI(uri) @username = username || @uri.user @password = password || @uri.password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
26 27 28 |
# File 'lib/httpx/plugins/proxy.rb', line 26 def password @password end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
26 27 28 |
# File 'lib/httpx/plugins/proxy.rb', line 26 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
26 27 28 |
# File 'lib/httpx/plugins/proxy.rb', line 26 def username @username end |
Instance Method Details
#==(other) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/httpx/plugins/proxy.rb', line 44 def ==(other) case other when Parameters @uri == other.uri && @username == other.username && @password == other.password when URI::Generic, String proxy_uri = @uri.dup proxy_uri.user = @username proxy_uri.password = @password other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other) proxy_uri == other_uri else super end end |
#authenticated? ⇒ Boolean
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def authenticated? @username && @password end |
#token_authentication ⇒ Object
38 39 40 41 42 |
# File 'lib/httpx/plugins/proxy.rb', line 38 def token_authentication return unless authenticated? Base64.strict_encode64("#{@username}:#{@password}") end |