Class: HTTPX::Plugins::Proxy::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/plugins/proxy.rb,
sig/plugins/proxy.rbs

Overview

Manages the proxy parameters and the proxy authentication flow.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#no_proxy ⇒ Array[String]? (readonly)

Returns the value of attribute no_proxy.

Returns:

  • (Array[String], nil)


45
46
47
# File 'lib/httpx/plugins/proxy.rb', line 45

def no_proxy
  @no_proxy
end

#password ⇒ String? (readonly)

Returns the value of attribute password.

Returns:

  • (String, nil)


45
46
47
# File 'lib/httpx/plugins/proxy.rb', line 45

def password
  @password
end

#scheme ⇒ String? (readonly)

Returns the value of attribute scheme.

Returns:

  • (String, nil)


45
46
47
# File 'lib/httpx/plugins/proxy.rb', line 45

def scheme
  @scheme
end

#uri ⇒ URI::Generic? (readonly)

Returns the value of attribute uri.

Returns:

  • (URI::Generic, nil)


45
46
47
# File 'lib/httpx/plugins/proxy.rb', line 45

def uri
  @uri
end

#username ⇒ String? (readonly)

Returns the value of attribute username.

Returns:

  • (String, nil)


45
46
47
# File 'lib/httpx/plugins/proxy.rb', line 45

def username
  @username
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • (Object)

Returns:

  • (Boolean)


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/httpx/plugins/proxy.rb', line 104

def ==(other)
  case other
  when Parameters
    @uri == other.uri &&
      @username == other.username &&
      @password == other.password &&
      @scheme == other.scheme
  when URI::Generic, String
    proxy_uri = @uri.dup
    proxy_uri.user = @username
    proxy_uri.password = @password
    other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other)
    proxy_uri == other_uri
  else
    super
  end
end

#authenticate ⇒ String?

Parameters:

  • (Object)

Returns:

  • (String, nil)


98
99
100
101
102
# File 'lib/httpx/plugins/proxy.rb', line 98

def authenticate(...)
  return unless @authenticator

  @authenticator.authenticate(...)
end

#can_authenticate? ⇒ Boolean

Parameters:

  • (Object)

Returns:

  • (Boolean)


92
93
94
95
96
# File 'lib/httpx/plugins/proxy.rb', line 92

def can_authenticate?(...)
  return false unless @authenticator && @authenticator.respond_to?(:can_authenticate?)

  @authenticator.can_authenticate?(...)
end

#shift ⇒ void

This method returns an undefined value.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/httpx/plugins/proxy.rb', line 80

def shift
  return if @ns >= @uris.size - 1

  Parameters.new(
    uri: @uris,
    ns: @ns + 1,
    username: (@username if @initial_credentials),
    password: (@password if @initial_credentials),
    no_proxy: @no_proxy
  )
end