class HTTPX::Plugins::Proxy::Parameters

  1. lib/httpx/plugins/proxy.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. ==
  2. authenticated?
  3. password
  4. token_authentication
  5. uri
  6. username

Attributes

password [R]
uri [R]
username [R]

Public Class methods

new (uri:, username: nil, password: nil)
[show source]
   # File lib/httpx/plugins/proxy.rb
27 def initialize(uri:, username: nil, password: nil)
28   @uri = uri.is_a?(URI::Generic) ? uri : URI(uri)
29   @username = username || @uri.user
30   @password = password || @uri.password
31 end

Public Instance methods

== (other)
[show source]
   # File lib/httpx/plugins/proxy.rb
43 def ==(other)
44   case other
45   when Parameters
46     @uri == other.uri &&
47       @username == other.username &&
48       @password == other.password
49   when URI::Generic, String
50     proxy_uri = @uri.dup
51     proxy_uri.user = @username
52     proxy_uri.password = @password
53     other_uri = other.is_a?(URI::Generic) ? other : URI.parse(other)
54     proxy_uri == other_uri
55   else
56     super
57   end
58 end
authenticated? ()
[show source]
   # File lib/httpx/plugins/proxy.rb
33 def authenticated?
34   @username && @password
35 end
token_authentication ()
[show source]
   # File lib/httpx/plugins/proxy.rb
37 def token_authentication
38   return unless authenticated?
39 
40   Base64.strict_encode64("#{@username}:#{@password}")
41 end