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 +4 -4
- data/Gemfile +1 -1
- data/lib/elasticsearch/transport/transport/http/manticore.rb +10 -5
- data/lib/elasticsearch/transport/transport/response.rb +1 -1
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/spec/elasticsearch/transport/http/manticore_spec.rb +19 -1
- data/test/unit/transport_manticore_test.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa58b200c57b9fffe2bd1f4d1b1665c7155e472168b25c46f39204d575c8851d
|
4
|
+
data.tar.gz: bd07e27115bf220d45fe68c116b7074257cdeb15b2abf1107c9f4956e9bbee47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41c06e083d55da44b859644eaa75f57bf25aec8c3ba6a9c7617487d9d62453a1ae06f8326c354711105544193bdc231de060d47ecff627277267fd8361f8285b
|
7
|
+
data.tar.gz: 0b47cc13fd1e3b4c0663256d547793efd7031ecb7888c200c5abbb40d8e7e0b8a49a3d5a614707f63cbf766644dca76ce102c77c24bb2d3fa701fb011e9c1fb1
|
data/Gemfile
CHANGED
@@ -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,
|
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
|
-
|
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
|
|
@@ -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
|
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
|
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.
|
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:
|
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.
|
436
|
+
rubygems_version: 3.4.19
|
437
437
|
signing_key:
|
438
438
|
specification_version: 4
|
439
439
|
summary: Ruby client for Elasticsearch.
|