Methods
Public Class
Public Instance
Public Class methods
new(uri:, scheme: nil, username: nil, password: nil, **extra)
[show source]
# File lib/httpx/plugins/proxy.rb 36 def initialize(uri:, scheme: nil, username: nil, password: nil, **extra) 37 @uri = uri.is_a?(URI::Generic) ? uri : URI(uri) 38 @username = username || @uri.user 39 @password = password || @uri.password 40 41 return unless @username && @password 42 43 scheme ||= case @uri.scheme 44 when "socks5" 45 @uri.scheme 46 when "http", "https" 47 "basic" 48 else 49 return 50 end 51 52 @scheme = scheme 53 54 auth_scheme = scheme.to_s.capitalize 55 56 require_relative "auth/#{scheme}" unless defined?(Authentication) && Authentication.const_defined?(auth_scheme, false) 57 58 @authenticator = Authentication.const_get(auth_scheme).new(@username, @password, **extra) 59 end
Public Instance methods
==(other)
[show source]
# File lib/httpx/plugins/proxy.rb 73 def ==(other) 74 case other 75 when Parameters 76 @uri == other.uri && 77 @username == other.username && 78 @password == other.password && 79 @scheme == other.scheme 80 when URI::Generic, String 81 proxy_uri = @uri.dup 82 proxy_uri.user = @username 83 proxy_uri.password = @password 84 other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other) 85 proxy_uri == other_uri 86 else 87 super 88 end 89 end
authenticate(*args)
[show source]
# File lib/httpx/plugins/proxy.rb 67 def authenticate(*args) 68 return unless @authenticator 69 70 @authenticator.authenticate(*args) 71 end
can_authenticate?(*args)
[show source]
# File lib/httpx/plugins/proxy.rb 61 def can_authenticate?(*args) 62 return false unless @authenticator 63 64 @authenticator.can_authenticate?(*args) 65 end