class HTTPX::Plugins::Proxy::Parameters

  1. lib/httpx/plugins/proxy.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. ==
  2. authenticate
  3. can_authenticate?
  4. no_proxy
  5. password
  6. scheme
  7. shift
  8. uri
  9. username

Attributes

no_proxy [R]
password [R]
scheme [R]
uri [R]
username [R]

Public Class methods

new(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra)
[show source]
   # File lib/httpx/plugins/proxy.rb
36 def initialize(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra)
37   @no_proxy = Array(no_proxy) if no_proxy
38   @uris = Array(uri)
39   uri = @uris.first
40 
41   @username = username
42   @password = password
43 
44   @ns = 0
45 
46   if uri
47     @uri = uri.is_a?(URI::Generic) ? uri : URI(uri)
48     @username ||= @uri.user
49     @password ||= @uri.password
50   end
51 
52   @scheme = scheme
53 
54   return unless @uri && @username && @password
55 
56   @authenticator = nil
57   @scheme ||= infer_default_auth_scheme(@uri)
58 
59   return unless @scheme
60 
61   @authenticator = load_authenticator(@scheme, @username, @password, **extra)
62 end

Public Instance methods

==(other)
[show source]
    # File lib/httpx/plugins/proxy.rb
 95 def ==(other)
 96   case other
 97   when Parameters
 98     @uri == other.uri &&
 99       @username == other.username &&
100       @password == other.password &&
101       @scheme == other.scheme
102   when URI::Generic, String
103     proxy_uri = @uri.dup
104     proxy_uri.user = @username
105     proxy_uri.password = @password
106     other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other)
107     proxy_uri == other_uri
108   else
109     super
110   end
111 end
authenticate(*args)
[show source]
   # File lib/httpx/plugins/proxy.rb
89 def authenticate(*args)
90   return unless @authenticator
91 
92   @authenticator.authenticate(*args)
93 end
can_authenticate?(*args)
[show source]
   # File lib/httpx/plugins/proxy.rb
83 def can_authenticate?(*args)
84   return false unless @authenticator
85 
86   @authenticator.can_authenticate?(*args)
87 end
shift()
[show source]
   # File lib/httpx/plugins/proxy.rb
64 def shift
65   # TODO: this operation must be synchronized
66   @ns += 1
67   @uri = @uris[@ns]
68 
69   return unless @uri
70 
71   @uri = URI(@uri) unless @uri.is_a?(URI::Generic)
72 
73   scheme = infer_default_auth_scheme(@uri)
74 
75   return unless scheme != @scheme
76 
77   @scheme = scheme
78   @username = username || @uri.user
79   @password = password || @uri.password
80   @authenticator = load_authenticator(scheme, @username, @password)
81 end