Skip to content

Commit

Permalink
Add http_options to Net::HTTP object when initialize new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangtuanictvn committed Jan 3, 2021
1 parent e5574b3 commit aeecc0a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/ruby_http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def make_request(http, request)
def build_http(host, port)
params = [host, port]
params += @proxy_options.values_at(:host, :port, :user, :pass) unless @proxy_options.empty?
add_ssl(Net::HTTP.new(*params))
http = add_ssl(Net::HTTP.new(*params))
http = add_http_options(http) unless @http_options.empty?
http
end

# Allow for https calls
Expand All @@ -245,6 +247,20 @@ def add_ssl(http)
http
end

# Add others http options to http object
#
# * *Args* :
# - +http+ -> HTTP::NET object
# * *Returns* :
# - HTTP::NET object
#
def add_http_options(http)
@http_options.each do |attribute, value|
http.send("#{attribute}=", value)
end
http
end

# Add variable values to the url.
# (e.g. /your/api/{variable_value}/call)
# Another example: if you have a ruby reserved word, such as true,
Expand Down

0 comments on commit aeecc0a

Please sign in to comment.