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

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

Constant Summary

Constants included from Registry

Registry::Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Registry

extended, included

Constructor Details

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

Returns a new instance of Parameters.



16
17
18
19
20
# File 'lib/httpx/plugins/proxy.rb', line 16

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.



14
15
16
# File 'lib/httpx/plugins/proxy.rb', line 14

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri.



14
15
16
# File 'lib/httpx/plugins/proxy.rb', line 14

def uri
  @uri
end

#usernameObject (readonly)

Returns the value of attribute username.



14
15
16
# File 'lib/httpx/plugins/proxy.rb', line 14

def username
  @username
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/httpx/plugins/proxy.rb', line 22

def authenticated?
  @username && @password
end

#token_authenticationObject



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

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