Skip to content

Commit be65147

Browse files
authored
Fix/small typos (#429)
* chore(request-options): use string instead of symbol for headers * chore(transport): simplify header merge
1 parent 9d7522a commit be65147

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/algolia/transport/request_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def create(opts = {})
3434
def add_headers(opts = {})
3535
unless opts[:headers].nil?
3636
opts[:headers].each do |opt, value|
37-
@headers[opt.to_sym] = value
37+
@headers[opt.to_s] = value
3838
end
3939
opts.delete(:headers)
4040
end

lib/algolia/transport/transport.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,12 @@ def build_body(body, request_options, method)
127127

128128
# Generates headers from config headers and optional parameters
129129
#
130-
# @option options [String] :headers
130+
# @param request_options [RequestOptions]
131131
#
132132
# @return [Hash] merged headers
133133
#
134134
def generate_headers(request_options = {})
135-
headers = {}
136-
extra_headers = request_options.headers || {}
137-
@config.headers.each { |key, val| headers[key.to_s] = val }
138-
extra_headers.each { |key, val| headers[key.to_s] = val }
135+
headers = @config.headers.merge(request_options.headers)
139136
if request_options.compression_type == Defaults::GZIP_ENCODING
140137
headers['Accept-Encoding'] = Defaults::GZIP_ENCODING
141138
end

0 commit comments

Comments
 (0)