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.



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

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.



12
13
14
# File 'lib/httpx/plugins/proxy.rb', line 12

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri.



12
13
14
# File 'lib/httpx/plugins/proxy.rb', line 12

def uri
  @uri
end

#usernameObject (readonly)

Returns the value of attribute username.



12
13
14
# File 'lib/httpx/plugins/proxy.rb', line 12

def username
  @username
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/httpx/plugins/proxy.rb', line 20

def authenticated?
  @username && @password
end

#token_authenticationObject



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

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