diff --git a/lib/passwordstate/client.rb b/lib/passwordstate/client.rb index e43576d1aef3396a7bd5d21b4ddfd50076626909..2fe9b2c212429f9ebd30a2d68b5847aaaba113a8 100644 --- a/lib/passwordstate/client.rb +++ b/lib/passwordstate/client.rb @@ -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