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