Class: HTTPX::Plugins::Proxy::Parameters
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Proxy::Parameters
- Defined in:
- lib/httpx/plugins/proxy.rb
Instance Attribute Summary collapse
-
#no_proxy ⇒ Object
readonly
Returns the value of attribute no_proxy.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #authenticate(*args) ⇒ Object
- #can_authenticate?(*args) ⇒ Boolean
-
#initialize(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra) ⇒ Parameters
constructor
A new instance of Parameters.
- #shift ⇒ Object
Constructor Details
#initialize(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra) ⇒ Parameters
Returns a new instance of Parameters.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/httpx/plugins/proxy.rb', line 36 def initialize(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra) @no_proxy = Array(no_proxy) if no_proxy @uris = Array(uri) uri = @uris.first @username = username @password = password @ns = 0 if uri @uri = uri.is_a?(URI::Generic) ? uri : URI(uri) @username ||= @uri.user @password ||= @uri.password end @scheme = scheme return unless @uri && @username && @password @authenticator = nil @scheme ||= infer_default_auth_scheme(@uri) return unless @scheme @authenticator = load_authenticator(@scheme, @username, @password, **extra) end |
Instance Attribute Details
#no_proxy ⇒ Object (readonly)
Returns the value of attribute no_proxy.
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def no_proxy @no_proxy end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def password @password end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def scheme @scheme end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
34 35 36 |
# File 'lib/httpx/plugins/proxy.rb', line 34 def username @username end |
Instance Method Details
#==(other) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/httpx/plugins/proxy.rb', line 95 def ==(other) case other when Parameters @uri == other.uri && @username == other.username && @password == other.password && @scheme == other.scheme 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 |
#authenticate(*args) ⇒ Object
89 90 91 92 93 |
# File 'lib/httpx/plugins/proxy.rb', line 89 def authenticate(*args) return unless @authenticator @authenticator.authenticate(*args) end |
#can_authenticate?(*args) ⇒ Boolean
83 84 85 86 87 |
# File 'lib/httpx/plugins/proxy.rb', line 83 def can_authenticate?(*args) return false unless @authenticator @authenticator.can_authenticate?(*args) end |
#shift ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/httpx/plugins/proxy.rb', line 64 def shift # TODO: this operation must be synchronized @ns += 1 @uri = @uris[@ns] return unless @uri @uri = URI(@uri) unless @uri.is_a?(URI::Generic) scheme = infer_default_auth_scheme(@uri) return unless scheme != @scheme @scheme = scheme @username = username || @uri.user @password = password || @uri.password @authenticator = load_authenticator(scheme, @username, @password) end |