Skip to content

Commit

Permalink
Fixes instantiating Client in Manticore implementation.
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
picandocodigo committed Sep 21, 2023
1 parent 5a63daf commit 53a4370
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/elastic/transport/transport/http/manticore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def build_client(options = {})
# @return [Response]
# @see Transport::Base#perform_request
#
def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {})
def perform_request(method, path, params = {}, body = nil, headers = {}, opts = {})
super do |connection, url|
body = body ? __convert_to_json(body) : nil
body, headers = compress_request(body, @request_options[:headers])
body, headers = compress_request(body, @request_options[:headers].merge(headers))

params[:body] = body if body
params[:headers] = headers if headers
Expand Down
18 changes: 18 additions & 0 deletions spec/elastic/transport/http/manticore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@
end
end
end

context 'headers' do
it 'sends custom headers' do
client = Elastic::Transport::Client.new(
transport_class: described_class,
transport_options: { headers: { 'Elastic-Api-Version'=>'2023-10-31' } }
)
expect(
client.transport.connections.first.connection
).to receive(:get).with(
'http://localhost:9200/',
{
headers: expected_headers.merge({ 'Elastic-Api-Version'=>'2023-10-31' })
}
).and_return(response)
client.perform_request('GET', '/', {}, nil, headers)
end
end
end
end
end

0 comments on commit 53a4370

Please sign in to comment.