Class: DeepL::HTTPClientOptions
- Inherits:
-
Object
- Object
- DeepL::HTTPClientOptions
- Defined in:
- lib/http_client_options.rb
Instance Attribute Summary collapse
-
#cert_path ⇒ Object
readonly
Returns the value of attribute cert_path.
-
#enable_ssl_verification ⇒ Object
readonly
Returns the value of attribute enable_ssl_verification.
-
#open_timeout ⇒ Object
readonly
Returns the value of attribute open_timeout.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#send_platform_info ⇒ Object
readonly
Returns the value of attribute send_platform_info.
-
#ssl_timeout ⇒ Object
readonly
Returns the value of attribute ssl_timeout.
-
#write_timeout ⇒ Object
readonly
Returns the value of attribute write_timeout.
Class Method Summary collapse
-
.redact_proxy(proxy) ⇒ Object
Hides the user info of a proxy URL:
http://user:pass@host:portbecomeshttp://[REDACTED]@host:port, and//user:pass@host:port//[REDACTED]@host:port.
Instance Method Summary collapse
-
#initialize(proxy = {}, cert_path = nil, enable_ssl_verification: true, open_timeout: nil, read_timeout: nil, write_timeout: nil, ssl_timeout: nil) ⇒ HTTPClientOptions
constructor
rubocop:disable Metrics/ParameterLists.
-
#inspect ⇒ Object
Leaves out the proxy credentials.
Constructor Details
#initialize(proxy = {}, cert_path = nil, enable_ssl_verification: true, open_timeout: nil, read_timeout: nil, write_timeout: nil, ssl_timeout: nil) ⇒ HTTPClientOptions
rubocop:disable Metrics/ParameterLists
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/http_client_options.rb', line 11 def initialize(proxy = {}, cert_path = nil, enable_ssl_verification: true, open_timeout: nil, # rubocop:disable Metrics/ParameterLists read_timeout: nil, write_timeout: nil, ssl_timeout: nil) @proxy = proxy @enable_ssl_verification = enable_ssl_verification @cert_path = cert_path @open_timeout = open_timeout @read_timeout = read_timeout @write_timeout = write_timeout @ssl_timeout = ssl_timeout end |
Instance Attribute Details
#cert_path ⇒ Object (readonly)
Returns the value of attribute cert_path.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def cert_path @cert_path end |
#enable_ssl_verification ⇒ Object (readonly)
Returns the value of attribute enable_ssl_verification.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def enable_ssl_verification @enable_ssl_verification end |
#open_timeout ⇒ Object (readonly)
Returns the value of attribute open_timeout.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def open_timeout @open_timeout end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def proxy @proxy end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def read_timeout @read_timeout end |
#send_platform_info ⇒ Object (readonly)
Returns the value of attribute send_platform_info.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def send_platform_info @send_platform_info end |
#ssl_timeout ⇒ Object (readonly)
Returns the value of attribute ssl_timeout.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def ssl_timeout @ssl_timeout end |
#write_timeout ⇒ Object (readonly)
Returns the value of attribute write_timeout.
8 9 10 |
# File 'lib/http_client_options.rb', line 8 def write_timeout @write_timeout end |
Class Method Details
.redact_proxy(proxy) ⇒ Object
Hides the user info of a proxy URL: http://user:pass@host:port becomes
http://[REDACTED]@host:port, and //user:pass@host:port //[REDACTED]@host:port.
24 25 26 27 28 29 30 31 32 |
# File 'lib/http_client_options.rb', line 24 def self.redact_proxy(proxy) if proxy.is_a?(String) return proxy.sub(%r{\A((?:[a-z][a-z0-9+.-]*:)?//)?[^/@]*@}i, '\1[REDACTED]@') end return proxy unless proxy.is_a?(Hash) proxy.to_h { |key, value| [key, key.to_s =~ /user|pass/i ? '[REDACTED]' : value] } end |
Instance Method Details
#inspect ⇒ Object
Leaves out the proxy credentials.
35 36 37 38 39 40 |
# File 'lib/http_client_options.rb', line 35 def inspect shown = { proxy: self.class.redact_proxy(proxy), cert_path: cert_path, enable_ssl_verification: enable_ssl_verification, open_timeout: open_timeout, read_timeout: read_timeout, write_timeout: write_timeout, ssl_timeout: ssl_timeout } "#<#{self.class.name} #{shown.map { |name, value| "#{name}=#{value.inspect}" }.join(', ')}>" end |