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
43 def initialize(uri: nil, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra)
44   @no_proxy = Array(no_proxy) if no_proxy
45   @uris = Array(uri)
46   uri = @uris.first
47 
48   @username = username
49   @password = password
50 
51   @ns = 0
52 
53   if uri
54     @uri = uri.is_a?(URI::Generic) ? uri : URI(uri)
55     @username ||= @uri.user
56     @password ||= @uri.password
57   end
58 
59   @scheme = scheme
60 
61   return unless @uri && @username && @password
62 
63   @authenticator = nil
64   @scheme ||= infer_default_auth_scheme(@uri)
65 
66   return unless @scheme
67 
68   @authenticator = load_authenticator(@scheme, @username, @password, **extra)
69 end

Public Instance methods

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