class ProxyTester::HttpProxy
Attributes
host[R]
port[R]
user[R]
Public Class Methods
new(connection_string)
click to toggle source
# File lib/proxy_tester/http_proxy.rb, line 13 def initialize(connection_string) match = connection_string_pattern.match(connection_string) || {} raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:host].blank? raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:port].blank? @host = match[:host] @port = match[:port] end
Public Instance Methods
to_string(options = {})
click to toggle source
# File lib/proxy_tester/http_proxy.rb, line 27 def to_string(options = {}) result = [] result << 'http://' if user and options[:cleartext] == true result << "#{user.name}:#{user.password}@" elsif user result << "#{user.name}:#{'*' * 4}@" if user end result << "#{host}:#{port}" result.join end
use_user(user)
click to toggle source
# File lib/proxy_tester/http_proxy.rb, line 23 def use_user(user) @user = user end
Private Instance Methods
connection_string_pattern()
click to toggle source
# File lib/proxy_tester/http_proxy.rb, line 44 def connection_string_pattern /(?<host>[[:alnum:]._-]+):(?<port>\d+{1,5})/ end