Skip to content

Commit

Permalink
[Ruby][Faraday][#10137] Fix config request options and timeout (#10405)
Browse files Browse the repository at this point in the history
* Update default timeout of Faraday request to 60 seconds

* Fix request options of Ruby Faraday client
  • Loading branch information
NivathaSV8 committed Oct 2, 2021
1 parent 68285bc commit 0eb7189
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,20 @@
update_params_for_auth! header_params, query_params, opts[:auth_names]

req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:verbose => @config.debugging
}

if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request.headers = header_params
request.body = req_body
request.options = OpenStruct.new(req_opts)
request.url url
request.params = query_params
download_file(request) if opts[:return_type] == 'File'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,22 @@ module {{moduleName}}
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@timeout = 0
@client_side_validation = true
{{#isFaraday}}
@ssl_verify = true
@ssl_verify_mode = nil
@ssl_ca_file = nil
@ssl_client_cert = nil
@ssl_client_key = nil
@timeout = 60
{{/isFaraday}}
{{^isFaraday}}
@verify_ssl = true
@verify_ssl_host = true
@params_encoding = nil
@cert_file = nil
@key_file = nil
@timeout = 0
{{/isFaraday}}
@debugging = false
@inject_format = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,20 @@ def build_request(http_method, path, request, opts = {})
update_params_for_auth! header_params, query_params, opts[:auth_names]

req_opts = {
:method => http_method,
:headers => header_params,
:params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:verbose => @config.debugging
}

if [:post, :patch, :put, :delete].include?(http_method)
req_body = build_request_body(header_params, form_params, opts[:body])
req_opts.update :body => req_body
if @config.debugging
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
end
end
request.headers = header_params
request.body = req_body
request.options = OpenStruct.new(req_opts)
request.url url
request.params = query_params
download_file(request) if opts[:return_type] == 'File'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ def initialize
@server_operation_variables = {}
@api_key = {}
@api_key_prefix = {}
@timeout = 0
@client_side_validation = true
@ssl_verify = true
@ssl_verify_mode = nil
@ssl_ca_file = nil
@ssl_client_cert = nil
@ssl_client_key = nil
@timeout = 60
@debugging = false
@inject_format = false
@force_ending_format = false
Expand Down

0 comments on commit 0eb7189

Please sign in to comment.