Manages the proxy parameters and the proxy authentication flow.
Methods
Public Class
Public Instance
Public Class methods
new(uri: nil, ns: 0, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra)
[show source]
# File lib/httpx/plugins/proxy.rb 47 def initialize(uri: nil, ns: 0, scheme: nil, username: nil, password: nil, no_proxy: nil, **extra) 48 @no_proxy = Array(no_proxy) if no_proxy 49 @uris = Array(uri) 50 uri = @uris[ns] 51 52 @username = username 53 @password = password 54 55 @initial_credentials = @username && @password 56 57 @ns = ns 58 59 if uri 60 @uri = URI(uri) 61 @username ||= @uri.user 62 @password ||= @uri.password 63 end 64 65 @scheme = scheme 66 67 return unless @uri && @username && @password 68 69 @authenticator = nil 70 @scheme ||= infer_default_auth_scheme(@uri) 71 72 return unless @scheme 73 74 @username = CGI.unescape(@username) if @username 75 @password = CGI.unescape(@password) if @password 76 77 @authenticator = load_authenticator(@scheme, @username, @password, **extra) 78 end
Public Instance methods
==(other)
[show source]
# File lib/httpx/plugins/proxy.rb 104 def ==(other) 105 case other 106 when Parameters 107 @uri == other.uri && 108 @username == other.username && 109 @password == other.password && 110 @scheme == other.scheme 111 when URI::Generic, String 112 proxy_uri = @uri.dup 113 proxy_uri.user = @username 114 proxy_uri.password = @password 115 other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other) 116 proxy_uri == other_uri 117 else 118 super 119 end 120 end
authenticate(...)
[show source]
# File lib/httpx/plugins/proxy.rb 98 def authenticate(...) 99 return unless @authenticator 100 101 @authenticator.authenticate(...) 102 end
can_authenticate?(...)
[show source]
# File lib/httpx/plugins/proxy.rb 92 def can_authenticate?(...) 93 return false unless @authenticator && @authenticator.respond_to?(:can_authenticate?) 94 95 @authenticator.can_authenticate?(...) 96 end
shift()
[show source]
# File lib/httpx/plugins/proxy.rb 80 def shift 81 return if @ns >= @uris.size - 1 82 83 Parameters.new( 84 uri: @uris, 85 ns: @ns + 1, 86 username: (@username if @initial_credentials), 87 password: (@password if @initial_credentials), 88 no_proxy: @no_proxy 89 ) 90 end