elasticsearch-transport 7.17.7 → 7.17.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 515176cfbf829f3153d85e4975eebed91424aaa14256d332f0dc3f87030ce671
4
- data.tar.gz: c8bdcb22a2f81446f55d4d3025f05863020629eb0ff139e80832a3dc8f43eb8b
3
+ metadata.gz: aa58b200c57b9fffe2bd1f4d1b1665c7155e472168b25c46f39204d575c8851d
4
+ data.tar.gz: bd07e27115bf220d45fe68c116b7074257cdeb15b2abf1107c9f4956e9bbee47
5
5
  SHA512:
6
- metadata.gz: 850fc6102767844a698044cbc3cef9e63f01895ef5735e9c9e831db4e62dac9f448c71cc6eac591f5ce3e225b35106a083366ead9e3267d24f8723f81a792f8c
7
- data.tar.gz: 18ba115ba8d1b55866806c75845c8a39dd920c9bd227b64e586ecdedc7274530c28dcc3f62bfb70f61510091f2acc3aa67511323e0b6b70c5afdbf5df035f175
6
+ metadata.gz: 41c06e083d55da44b859644eaa75f57bf25aec8c3ba6a9c7617487d9d62453a1ae06f8326c354711105544193bdc231de060d47ecff627277267fd8361f8285b
7
+ data.tar.gz: 0b47cc13fd1e3b4c0663256d547793efd7031ecb7888c200c5abbb40d8e7e0b8a49a3d5a614707f63cbf766644dca76ce102c77c24bb2d3fa701fb011e9c1fb1
data/Gemfile CHANGED
@@ -33,6 +33,6 @@ group :development, :test do
33
33
  if defined?(JRUBY_VERSION)
34
34
  gem 'pry-nav'
35
35
  else
36
- gem 'pry-byebug'
36
+ gem 'pry-byebug', '~> 3.9'
37
37
  end
38
38
  end
@@ -87,14 +87,13 @@ module Elasticsearch
87
87
  # @return [Response]
88
88
  # @see Transport::Base#perform_request
89
89
  #
90
- def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
90
+ def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {})
91
91
  super do |connection, url|
92
92
  body = body ? __convert_to_json(body) : nil
93
- body, headers = compress_request(body, @request_options[:headers])
94
-
93
+ body, headers = compress_request(body, parse_headers(headers))
95
94
  params[:body] = body if body
96
95
  params[:headers] = headers if headers
97
- params = params.merge(@request_options)
96
+
98
97
  case method
99
98
  when 'GET'
100
99
  resp = connection.connection.get(url, params)
@@ -161,8 +160,14 @@ module Elasticsearch
161
160
 
162
161
  private
163
162
 
163
+ def parse_headers(headers)
164
+ request_headers = @request_options.fetch(:headers, {})
165
+ headers = request_headers.merge(headers || {})
166
+ headers.empty? ? nil : headers
167
+ end
168
+
164
169
  def apply_headers(options)
165
- headers = options[:headers] || options.dig(:transport_options, :headers) || {}
170
+ headers = options[:headers].clone || options.dig(:transport_options, :headers).clone || {}
166
171
  headers[CONTENT_TYPE_STR] = find_value(headers, CONTENT_TYPE_REGEX) || DEFAULT_CONTENT_TYPE
167
172
  headers[USER_AGENT_STR] = find_value(headers, USER_AGENT_REGEX) || find_value(@request_options[:headers], USER_AGENT_REGEX) || user_agent_header
168
173
  headers[ACCEPT_ENCODING] = GZIP if use_compression?
@@ -28,7 +28,7 @@ module Elasticsearch
28
28
  # @param headers [Hash] Response headers
29
29
  def initialize(status, body, headers={})
30
30
  @status, @body, @headers = status, body, headers
31
- @body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
31
+ @body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding) && !body.frozen?
32
32
  end
33
33
  end
34
34
 
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module Transport
20
- VERSION = '7.17.7'.freeze
20
+ VERSION = '7.17.9'.freeze
21
21
  end
22
22
  end
@@ -53,7 +53,7 @@ if defined?(JRUBY_VERSION)
53
53
  expect(perform_request).to be_kind_of(Elasticsearch::Transport::Transport::Response)
54
54
  end
55
55
 
56
- it 'run body with preper params' do
56
+ it 'run body with proper params' do
57
57
  expect(
58
58
  client.transport.connections.first.connection
59
59
  ).to receive(:post).with('http://localhost:9200/', { body: body, headers: expected_headers }).and_return(response)
@@ -138,6 +138,24 @@ if defined?(JRUBY_VERSION)
138
138
  end
139
139
  end
140
140
  end
141
+
142
+ context 'headers' do
143
+ it 'sends custom headers' do
144
+ client = Elasticsearch::Transport::Client.new(
145
+ transport_class: described_class,
146
+ transport_options: { headers: { 'Elastic-Api-Version'=>'2023-10-31' } }
147
+ )
148
+ expect(
149
+ client.transport.connections.first.connection
150
+ ).to receive(:get).with(
151
+ 'http://localhost:9200/',
152
+ {
153
+ headers: expected_headers.merge({ 'Elastic-Api-Version'=>'2023-10-31' })
154
+ }
155
+ ).and_return(response)
156
+ client.perform_request('GET', '/', {}, nil, headers)
157
+ end
158
+ end
141
159
  end
142
160
  end
143
161
  end
@@ -111,7 +111,7 @@ if JRUBY
111
111
  {
112
112
  body: '{"foo":"bar"}',
113
113
  headers: {
114
- 'Content-Type' => 'application/json',
114
+ 'Content-Type' => 'application/x-ndjson',
115
115
  'User-Agent' => @transport.send(:user_agent_header)
116
116
  }
117
117
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.17.7
4
+ version: 7.17.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-25 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -433,7 +433,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
433
  - !ruby/object:Gem::Version
434
434
  version: '0'
435
435
  requirements: []
436
- rubygems_version: 3.3.7
436
+ rubygems_version: 3.4.19
437
437
  signing_key:
438
438
  specification_version: 4
439
439
  summary: Ruby client for Elasticsearch.