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.
27 28 29 30 31 |
# File 'lib/httpx/plugins/proxy.rb', line 27 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.
25 26 27 |
# File 'lib/httpx/plugins/proxy.rb', line 25 def password @password end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
25 26 27 |
# File 'lib/httpx/plugins/proxy.rb', line 25 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
25 26 27 |
# File 'lib/httpx/plugins/proxy.rb', line 25 def username @username end |
Instance Method Details
#==(other) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/httpx/plugins/proxy.rb', line 43 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
33 34 35 |
# File 'lib/httpx/plugins/proxy.rb', line 33 def authenticated? @username && @password end |
#token_authentication ⇒ Object
37 38 39 40 41 |
# File 'lib/httpx/plugins/proxy.rb', line 37 def token_authentication return unless authenticated? Base64.strict_encode64("#{@username}:#{@password}") end |