Skip to content
Snippets Groups Projects
Verified Commit aaace4e2 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Allow setting an open timeout for client

parent fbf589ee
Branches develop_new
No related tags found
No related merge requests found
Pipeline #95810 failed
......@@ -11,7 +11,7 @@ module Passwordstate
}.freeze
attr_accessor :server_url, :auth_data, :headers, :validate_certificate
attr_reader :timeout
attr_reader :open_timeout, :timeout
attr_writer :api_type
def initialize(url, options = {})
......@@ -20,6 +20,7 @@ module Passwordstate
@headers = DEFAULT_HEADERS
@auth_data = options.select { |k, _v| %i[apikey username password].include? k }
@api_type = options.fetch(:api_type) if options.key? :api_type
@open_timeout = options.fetch(:open_timeout, 5)
@timeout = options.fetch(:timeout, 15)
end
......@@ -155,6 +156,7 @@ module Passwordstate
@http ||= Net::HTTP.new server_url.host, server_url.port
return @http if @http.active?
@http.open_timeout = @open_timeout if @open_timeout
@http.read_timeout = @timeout if @timeout
@http.use_ssl = server_url.scheme == 'https'
@http.verify_mode = validate_certificate ? ::OpenSSL::SSL::VERIFY_NONE : nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment