logstash-input-elasticsearch 5.2.2 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7492197c24e31559240f18287c9ca4d45c8b9cf86aba977ee100bee6eec8ab1b
4
- data.tar.gz: 7bc9bf7a118dd6594d299536341239c1a87484fc7b0cec617e33879a5a77d524
3
+ metadata.gz: 90dc46d1bcadf70173792a9c2319925ea5e78bd3e6322e7c323de178afb72fa4
4
+ data.tar.gz: 21548a5935b0aa5b153b6e1bc00c7f9f3f6ade7f6546a0beb0ce7cc6cef5a984
5
5
  SHA512:
6
- metadata.gz: 41faaed2909e00cac9b58fa9347a5d53a81eaee27c4f4e548cec637bc37a448d63664918c4535f280b9df2202a9b494f372f97e2aee970e496f14620f70b5282
7
- data.tar.gz: 997380a42e67e2f66bd60883ee1362842edb405607710a1a58241114277c5f2c7c1c3316c162920cbce6346554bac9d2d111dd777c79451f4c6a0edce364ee48
6
+ metadata.gz: 59e8a03c25d8ee9a1a02014b75d1096b81250b85c7f6bd7e78114764534d9ad244d5d758e974c84bc20d9aa0c8fad669a3ef636b17037426c30f2705d74083d2
7
+ data.tar.gz: 8b986365b25b8884e3aae581b37ce35f9190e50bf3ce4d17263887c31721efe16f16b97dcf2571dcb446991f7ea4406c6011a1d1dbd3afd7f3e07ec0c4b9b743
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
+ ## 5.3.0
2
+ - Drop a support for Logstash 7.x by requiring elasticsearch gem >= 8. Logstash 8+ continues to work as before [#252](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/252)
3
+
1
4
  ## 5.2.2
2
- - [DOC] Note that `search_after` requires permissions on underlying indices/data streams, not aliases [#251](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/TBD)
5
+ - [DOC] Note that `search_after` requires permissions on underlying indices/data streams, not aliases [#251](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/251)
3
6
 
4
7
  ## 5.2.1
5
8
  - Added support for encoded and non encoded api-key formats on plugin configuration [#237](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/237)
@@ -13,6 +13,7 @@ require "logstash/plugin_mixins/normalize_config_support"
13
13
  require "base64"
14
14
 
15
15
  require "elasticsearch"
16
+ require "elastic/transport/transport/http/manticore"
16
17
  require "manticore"
17
18
 
18
19
  # .Compatibility Note
@@ -350,7 +351,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
350
351
  @client_options = {
351
352
  :hosts => hosts,
352
353
  :transport_options => transport_options,
353
- :transport_class => get_transport_client_class,
354
+ :transport_class => ::Elastic::Transport::Transport::HTTP::Manticore,
354
355
  :ssl => ssl_options
355
356
  }
356
357
 
@@ -728,20 +729,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
728
729
  last_run_metadata_path
729
730
  end
730
731
 
731
- def get_transport_client_class
732
- # LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport`
733
- # And now `elasticsearch-transport` is old, instead we have `elastic-transport`.
734
- # LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161
735
- # Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems
736
- require "elasticsearch/transport/transport/http/manticore"
737
- require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore"
738
- require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector"
739
- ::Elasticsearch::Transport::Transport::HTTP::Manticore
740
- rescue ::LoadError
741
- require "elastic/transport/transport/http/manticore"
742
- ::Elastic::Transport::Transport::HTTP::Manticore
743
- end
744
-
745
732
  def validate_ls_version_for_esql_support!
746
733
  if Gem::Version.create(LOGSTASH_VERSION) < Gem::Version.create(LS_ESQL_SUPPORT_VERSION)
747
734
  fail("Current version of Logstash does not include Elasticsearch client which supports ES|QL. Please upgrade Logstash to at least #{LS_ESQL_SUPPORT_VERSION}")
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-elasticsearch'
4
- s.version = '5.2.2'
4
+ s.version = ::File.read('version').split("\n").first
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads query results from an Elasticsearch cluster"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
27
27
  s.add_runtime_dependency "logstash-mixin-scheduler", '~> 1.0'
28
28
 
29
- s.add_runtime_dependency 'elasticsearch', '>= 7.17.9', '< 9'
29
+ s.add_runtime_dependency 'elasticsearch', '>= 8', '< 10'
30
30
  s.add_runtime_dependency 'logstash-mixin-ca_trusted_fingerprint_support', '~> 1.0'
31
31
  s.add_runtime_dependency 'logstash-mixin-normalize_config_support', '~>1.0'
32
32
 
@@ -18,16 +18,9 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
18
18
  let(:plugin) { described_class.new(config) }
19
19
  let(:queue) { Queue.new }
20
20
  let(:build_flavor) { "default" }
21
- let(:es_version) { "7.5.0" }
21
+ let(:es_version) { "8.19.10" }
22
22
  let(:cluster_info) { {"version" => {"number" => es_version, "build_flavor" => build_flavor}, "tagline" => "You Know, for Search"} }
23
23
 
24
- def elastic_ruby_v8_client_available?
25
- Elasticsearch::Transport
26
- false
27
- rescue NameError # NameError: uninitialized constant Elasticsearch::Transport if Elastic Ruby client is not available
28
- true
29
- end
30
-
31
24
  before(:each) do
32
25
  Elasticsearch::Client.send(:define_method, :ping) { } # define no-action ping method
33
26
  allow_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(cluster_info)
@@ -36,7 +29,8 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
36
29
  let(:base_config) do
37
30
  {
38
31
  'hosts' => ["localhost"],
39
- 'query' => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }'
32
+ 'query' => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }',
33
+ 'search_api' => 'scroll'
40
34
  }
41
35
  end
42
36
 
@@ -55,13 +49,13 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
55
49
  it "does not set header Elastic-Api-Version" do
56
50
  plugin.register
57
51
  client = plugin.send(:client)
58
- expect( extract_transport(client).options[:transport_options][:headers] ).not_to match hash_including("Elastic-Api-Version" => "2023-10-31")
52
+ expect( client.transport.options[:transport_options][:headers] ).not_to match hash_including("Elastic-Api-Version" => "2023-10-31")
59
53
  end
60
54
 
61
55
  it "sets an x-elastic-product-origin header identifying this as an internal plugin request" do
62
56
  plugin.register
63
57
  client = plugin.send(:client)
64
- expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including("x-elastic-product-origin"=>"logstash-input-elasticsearch")
58
+ expect( client.transport.options[:transport_options][:headers] ).to match hash_including("x-elastic-product-origin"=>"logstash-input-elasticsearch")
65
59
  end
66
60
  end
67
61
 
@@ -99,11 +93,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
99
93
 
100
94
  before do
101
95
  allow(Elasticsearch::Client).to receive(:new).and_return(es_client)
102
- if elastic_ruby_v8_client_available?
103
- allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
104
- else
105
- allow(es_client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Errors::BadRequest.new)
106
- end
96
+ allow(es_client).to receive(:info).and_raise(Elastic::Transport::Transport::Errors::BadRequest.new)
107
97
  end
108
98
 
109
99
  it "raises an exception" do
@@ -116,13 +106,13 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
116
106
  expect_any_instance_of(Elasticsearch::Client).to receive(:info).and_return(true)
117
107
  plugin.register
118
108
  client = plugin.send(:client)
119
- expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including("Elastic-Api-Version" => "2023-10-31")
109
+ expect( client.transport.options[:transport_options][:headers] ).to match hash_including("Elastic-Api-Version" => "2023-10-31")
120
110
  end
121
111
 
122
112
  it "sets an x-elastic-product-origin header identifying this as an internal plugin request" do
123
113
  plugin.register
124
114
  client = plugin.send(:client)
125
- expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including("x-elastic-product-origin"=>"logstash-input-elasticsearch")
115
+ expect( client.transport.options[:transport_options][:headers] ).to match hash_including("x-elastic-product-origin"=>"logstash-input-elasticsearch")
126
116
  end
127
117
  end
128
118
 
@@ -138,7 +128,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
138
128
  it "sets custom headers" do
139
129
  plugin.register
140
130
  client = plugin.send(:client)
141
- expect( extract_transport(client).options[:transport_options][:headers] ).to match hash_including(config["custom_headers"])
131
+ expect( client.transport.options[:transport_options][:headers] ).to match hash_including(config["custom_headers"])
142
132
  end
143
133
  end
144
134
  end
@@ -190,11 +180,12 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
190
180
  "_type" => "logs",
191
181
  "_id" => "C5b2xLQwTZa76jBmHIbwHQ",
192
182
  "_score" => 1.0,
193
- "_source" => { "message" => ["ohayo"] }
183
+ "_source" => { "message" => ["ohayo"] },
184
+ "sort" => [1]
194
185
  }
195
186
  allow(@esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
196
- allow(@esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
197
- allow(@esclient).to receive(:clear_scroll).and_return(nil)
187
+ allow(@esclient).to receive(:open_point_in_time).and_return({"id" => "test-pit-id"})
188
+ allow(@esclient).to receive(:close_point_in_time).and_return(nil)
198
189
  allow(@esclient).to receive(:ping)
199
190
  allow(@esclient).to receive(:info).and_return(cluster_info)
200
191
  end
@@ -210,7 +201,8 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
210
201
  let(:config) do
211
202
  {
212
203
  'hosts' => ["localhost"],
213
- 'query' => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }'
204
+ 'query' => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }',
205
+ 'search_api' => 'scroll'
214
206
  }
215
207
  end
216
208
 
@@ -269,7 +261,8 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
269
261
  {
270
262
  'hosts' => ["localhost"],
271
263
  'query' => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }',
272
- 'target' => "[@metadata][_source]"
264
+ 'target' => "[@metadata][_source]",
265
+ 'search_api' => 'scroll'
273
266
  }
274
267
  end
275
268
 
@@ -293,7 +286,8 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
293
286
  'query' => "#{LogStash::Json.dump(query)}",
294
287
  'slices' => slices,
295
288
  'docinfo' => true, # include ids
296
- 'docinfo_target' => '[@metadata]'
289
+ 'docinfo_target' => '[@metadata]',
290
+ 'search_api' => 'scroll'
297
291
  }
298
292
  end
299
293
  let(:query) do
@@ -753,13 +747,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
753
747
  it "should set host(s)" do
754
748
  plugin.register
755
749
  client = plugin.send(:client)
756
- target_field = :@seeds
757
- begin
758
- Elasticsearch::Transport::Client
759
- rescue
760
- target_field = :@hosts
761
- end
762
- expect( client.transport.instance_variable_get(target_field) ).to eql [{
750
+ expect( client.transport.instance_variable_get(:@hosts) ).to eql [{
763
751
  :scheme => "https",
764
752
  :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
765
753
  :port => 9243,
@@ -791,7 +779,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
791
779
  it "should set authorization" do
792
780
  plugin.register
793
781
  client = plugin.send(:client)
794
- auth_header = extract_transport(client).options[:transport_options][:headers]['Authorization']
782
+ auth_header = client.transport.options[:transport_options][:headers]['Authorization']
795
783
 
796
784
  expect( auth_header ).to eql "Basic #{Base64.encode64('elastic:my-passwd-00').rstrip}"
797
785
  end
@@ -831,7 +819,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
831
819
  it "correctly sets the Authorization header" do
832
820
  plugin.register
833
821
  client = plugin.send(:client)
834
- auth_header = extract_transport(client).options[:transport_options][:headers]['Authorization']
822
+ auth_header = client.transport.options[:transport_options][:headers]['Authorization']
835
823
 
836
824
  expect(auth_header).to eql("ApiKey #{encoded_api_key}")
837
825
  end
@@ -871,7 +859,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
871
859
  it "should set proxy" do
872
860
  plugin.register
873
861
  client = plugin.send(:client)
874
- proxy = extract_transport(client).options[:transport_options][:proxy]
862
+ proxy = client.transport.options[:transport_options][:proxy]
875
863
 
876
864
  expect( proxy ).to eql "http://localhost:1234"
877
865
  end
@@ -883,7 +871,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
883
871
  plugin.register
884
872
  client = plugin.send(:client)
885
873
 
886
- expect( extract_transport(client).options[:transport_options] ).to_not include(:proxy)
874
+ expect( client.transport.options[:transport_options] ).to_not include(:proxy)
887
875
  end
888
876
  end
889
877
  end
@@ -911,15 +899,15 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
911
899
  "cluster_name": "docker-cluster",
912
900
  "cluster_uuid": "DyR1hN03QvuCWXRy3jtb0g",
913
901
  "version": {
914
- "number": "7.13.1",
902
+ "number": "8.13.1",
915
903
  "build_flavor": "default",
916
904
  "build_type": "docker",
917
905
  "build_hash": "9a7758028e4ea59bcab41c12004603c5a7dd84a9",
918
- "build_date": "2021-05-28T17:40:59.346932922Z",
906
+ "build_date": "2024-05-28T17:40:59.346932922Z",
919
907
  "build_snapshot": false,
920
- "lucene_version": "8.8.2",
921
- "minimum_wire_compatibility_version": "6.8.0",
922
- "minimum_index_compatibility_version": "6.0.0-beta1"
908
+ "lucene_version": "9.10.0",
909
+ "minimum_wire_compatibility_version": "7.17.0",
910
+ "minimum_index_compatibility_version": "7.0.0"
923
911
  },
924
912
  "tagline": "You Know, for Search"
925
913
  }
@@ -1020,8 +1008,6 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
1020
1008
  let(:plugin) { described_class.new(config) }
1021
1009
  let(:event) { LogStash::Event.new({}) }
1022
1010
 
1023
- # elasticsearch-ruby 7.17.9 initialize two user agent headers, `user-agent` and `User-Agent`
1024
- # hence, fail this header size test case
1025
1011
  xit "client should sent the expect user-agent" do
1026
1012
  plugin.register
1027
1013
 
@@ -1220,6 +1206,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
1220
1206
  end
1221
1207
 
1222
1208
  describe "scroll" do
1209
+ let(:config) { super().merge({ "search_api" => "scroll" }) }
1223
1210
  let(:search_response) do
1224
1211
  {
1225
1212
  "_scroll_id" => "cXVlcnlUaGVuRmV0Y2g",
@@ -1379,11 +1366,6 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
1379
1366
  end
1380
1367
  end
1381
1368
 
1382
- # @note can be removed once we depends on elasticsearch gem >= 6.x
1383
- def extract_transport(client) # on 7.x client.transport is a ES::Transport::Client
1384
- client.transport.respond_to?(:transport) ? client.transport.transport : client.transport
1385
- end
1386
-
1387
1369
  describe "#ESQL" do
1388
1370
  let(:config) do
1389
1371
  {
@@ -14,7 +14,7 @@ describe "SSL options" do
14
14
  before do
15
15
  allow(es_client_double).to receive(:close)
16
16
  allow(es_client_double).to receive(:ping).with(any_args).and_return(double("pong").as_null_object)
17
- allow(es_client_double).to receive(:info).and_return({"version" => {"number" => "7.5.0", "build_flavor" => "default"},
17
+ allow(es_client_double).to receive(:info).and_return({"version" => {"number" => "8.19.0", "build_flavor" => "default"},
18
18
  "tagline" => "You Know, for Search"})
19
19
  allow(Elasticsearch::Client).to receive(:new).and_return(es_client_double)
20
20
  end
@@ -77,11 +77,7 @@ describe LogStash::Inputs::Elasticsearch do
77
77
  it_behaves_like 'an elasticsearch index plugin'
78
78
 
79
79
  let(:unauth_exception_class) do
80
- begin
81
- Elasticsearch::Transport::Transport::Errors::Unauthorized
82
- rescue
83
- Elastic::Transport::Transport::Errors::Unauthorized
84
- end
80
+ Elastic::Transport::Transport::Errors::Unauthorized
85
81
  end
86
82
 
87
83
  context "incorrect auth credentials" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.2
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-05-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: logstash-core-plugin-api
@@ -91,20 +91,20 @@ dependencies:
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 7.17.9
94
+ version: '8'
95
95
  - - "<"
96
96
  - !ruby/object:Gem::Version
97
- version: '9'
97
+ version: '10'
98
98
  type: :runtime
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 7.17.9
104
+ version: '8'
105
105
  - - "<"
106
106
  - !ruby/object:Gem::Version
107
- version: '9'
107
+ version: '10'
108
108
  - !ruby/object:Gem::Dependency
109
109
  name: logstash-mixin-ca_trusted_fingerprint_support
110
110
  requirement: !ruby/object:Gem::Requirement
@@ -266,8 +266,6 @@ files:
266
266
  - lib/logstash/inputs/elasticsearch/cursor_tracker.rb
267
267
  - lib/logstash/inputs/elasticsearch/esql.rb
268
268
  - lib/logstash/inputs/elasticsearch/paginated_search.rb
269
- - lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_connections_selector.rb
270
- - lib/logstash/inputs/elasticsearch/patches/_elasticsearch_transport_http_manticore.rb
271
269
  - logstash-input-elasticsearch.gemspec
272
270
  - spec/es_helper.rb
273
271
  - spec/fixtures/test_certs/GENERATED_AT
@@ -305,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
303
  - !ruby/object:Gem::Version
306
304
  version: '0'
307
305
  requirements: []
308
- rubygems_version: 3.6.3
306
+ rubygems_version: 3.7.2
309
307
  specification_version: 4
310
308
  summary: Reads query results from an Elasticsearch cluster
311
309
  test_files:
@@ -1,51 +0,0 @@
1
- require 'elasticsearch'
2
- require 'elasticsearch/transport/transport/connections/selector'
3
-
4
- if Gem.loaded_specs['elasticsearch-transport'].version < Gem::Version.new("7.2.0")
5
- # elasticsearch-transport versions prior to 7.2.0 suffered of a race condition on accessing
6
- # the connection pool. This issue was fixed (in 7.2.0) with
7
- # https://github.com/elastic/elasticsearch-ruby/commit/15f9d78591a6e8823948494d94b15b0ca38819d1
8
- #
9
- # This plugin, at the moment, is using elasticsearch >= 5.0.5
10
- # When this requirement ceases, this patch could be removed.
11
- module Elasticsearch
12
- module Transport
13
- module Transport
14
- module Connections
15
- module Selector
16
-
17
- # "Round-robin" selector strategy (default).
18
- #
19
- class RoundRobin
20
- include Base
21
-
22
- # @option arguments [Connections::Collection] :connections Collection with connections.
23
- #
24
- def initialize(arguments = {})
25
- super
26
- @mutex = Mutex.new
27
- @current = nil
28
- end
29
-
30
- # Returns the next connection from the collection, rotating them in round-robin fashion.
31
- #
32
- # @return [Connections::Connection]
33
- #
34
- def select(options={})
35
- @mutex.synchronize do
36
- conns = connections
37
- if @current && (@current < conns.size-1)
38
- @current += 1
39
- else
40
- @current = 0
41
- end
42
- conns[@current]
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,43 +0,0 @@
1
- # encoding: utf-8
2
- require "elasticsearch"
3
- require "elasticsearch/transport/transport/http/manticore"
4
-
5
- es_client_version = Gem.loaded_specs['elasticsearch-transport'].version
6
- if es_client_version >= Gem::Version.new('7.2') && es_client_version < Gem::Version.new('7.16')
7
- # elasticsearch-transport 7.2.0 - 7.14.0 had a bug where setting http headers
8
- # ES::Client.new ..., transport_options: { headers: { 'Authorization' => ... } }
9
- # would be lost https://github.com/elastic/elasticsearch-ruby/issues/1428
10
- #
11
- # NOTE: needs to be idempotent as filter ES plugin might apply the same patch!
12
- #
13
- # @private
14
- module Elasticsearch
15
- module Transport
16
- module Transport
17
- module HTTP
18
- class Manticore
19
-
20
- def apply_headers(request_options, options)
21
- headers = (options && options[:headers]) || {}
22
- headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
23
-
24
- # this code is necessary to grab the correct user-agent header
25
- # when this method is invoked with apply_headers(@request_options, options)
26
- # from https://github.com/elastic/elasticsearch-ruby/blob/v7.14.0/elasticsearch-transport/lib/elasticsearch/transport/transport/http/manticore.rb#L113-L114
27
- transport_user_agent = nil
28
- if (options && options[:transport_options] && options[:transport_options][:headers])
29
- transport_headers = options[:transport_options][:headers]
30
- transport_user_agent = find_value(transport_headers, USER_AGENT_REGEX)
31
- end
32
-
33
- headers[USER_AGENT_STR] = transport_user_agent || find_value(headers, USER_AGENT_REGEX) || user_agent_header
34
- headers[ACCEPT_ENCODING] = GZIP if use_compression?
35
- (request_options[:headers] ||= {}).merge!(headers) # this line was changed
36
- end
37
-
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end