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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, username: nil, password: nil) ⇒ Parameters

Returns a new instance of Parameters.



26
27
28
29
30
# File 'lib/httpx/plugins/proxy.rb', line 26

def initialize(uri:, username: nil, password: nil)
  @uri = uri.is_a?(URI::Generic) ? uri : URI(uri)
  @username = username || @uri.user
  @password = password || @uri.password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



24
25
26
# File 'lib/httpx/plugins/proxy.rb', line 24

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri.



24
25
26
# File 'lib/httpx/plugins/proxy.rb', line 24

def uri
  @uri
end

#usernameObject (readonly)

Returns the value of attribute username.



24
25
26
# File 'lib/httpx/plugins/proxy.rb', line 24

def username
  @username
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/httpx/plugins/proxy.rb', line 40

def ==(other)
  if other.is_a?(Parameters)
    @uri == other.uri &&
      @username == other.username &&
      @password == other.password
  else
    super
  end
end

#authenticated?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/httpx/plugins/proxy.rb', line 32

def authenticated?
  @username && @password
end

#token_authenticationObject



36
37
38
# File 'lib/httpx/plugins/proxy.rb', line 36

def token_authentication
  Base64.strict_encode64("#{user}:#{password}")
end