algolia/algoliasearch-client-ruby

Timeouts not being passed to http_requester

jmccormick11 opened this issue · 1 comments

  • Algolia Client Version: 2.3.1
  • Language Version: All

Description

Timeout's are not being sent to the http_requester for sending a request

The intention is to end up with the timeout and connect_timeout keys present in the request object that is later passed to send_request

def request(call_type, method, path, body = {}, opts = {})
@retry_strategy.get_tryable_hosts(call_type).each do |host|
opts[:timeout] ||= get_timeout(call_type) * (host.retry_count + 1)
opts[:connect_timeout] ||= @config.connect_timeout * (host.retry_count + 1)
request_options = RequestOptions.new(@config)
request_options.create(opts)
request_options.params.merge!(request_options.data) if method == :GET
request = build_request(method, path, body, request_options)
response = @http_requester.send_request(
host,
request[:method],
request[:path],
request[:body],
request[:headers],
request[:timeout],
request[:connect_timeout]
)

But in fact those keys are not being added in the build_request method

def build_request(method, path, body, request_options)
request = {}
request[:method] = method.downcase
request[:path] = build_uri_path(path, request_options.params)
request[:body] = build_body(body, request_options, method)
request[:headers] = generate_headers(request_options)
request
end

I created a work in progress PR that shows the fix: #493

PR has been merged and changes have been released in version 2.3.2! Thank you again for your contribution 😄