elasticsearch-transport 5.0.1 → 5.0.2

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
  SHA1:
3
- metadata.gz: 2b270a67bd3d6c3566fb5503a86965472087c5ef
4
- data.tar.gz: 629cce04c30b1968ce0d7fab0e4347cd99b70bda
3
+ metadata.gz: e41972a48c8437f78891cb2d82ec8b2a623d825f
4
+ data.tar.gz: 7093946c35ecfe27353f4678b7194951c378addf
5
5
  SHA512:
6
- metadata.gz: 5849da863dfc15089eb5f443c9364cdbe476cebc8e02b9db89d95c5c225622b694fd40e3fedc71c18f94e8a62702c099ade7931a708cd271481c47dbb02b910c
7
- data.tar.gz: e3824c7169dfdc5061fb4b1dd2e4ad0919cc9ac33180c1c3220027ea08e92c0ee8224cad3e0ea128f76da14757a21c8eec97b469eb949c3b5191165b8acc3551
6
+ metadata.gz: 14f15746ec09b0ea4389298e15326ef3026a8adf683198d5b2fdc2b40114bf5390d76b60ae8cd5a587e05b5776a22b365ccd0736ef0a348a56db7c63760c3b68
7
+ data.tar.gz: 355d03fafbeb574b421448e683bfe6c34b5fac51be774513ee3c62ed397b0769de90ee422d1bb8627e73ca4646fc465feb6e45fd082dff66572ddec11051bab0
@@ -102,6 +102,9 @@ module Elasticsearch
102
102
 
103
103
  @arguments[:transport_options].update(:request => { :timeout => @arguments[:request_timeout] } ) if @arguments[:request_timeout]
104
104
 
105
+ @arguments[:transport_options][:headers] ||= {}
106
+ @arguments[:transport_options][:headers].update 'Content-Type' => 'application/json' unless @arguments[:transport_options][:headers].keys.any? {|k| k.to_s.downcase =~ /content\-?\_?type/}
107
+
105
108
  @send_get_body_as = @arguments[:send_get_body_as] || 'GET'
106
109
 
107
110
  transport_class = @arguments[:transport_class] || DEFAULT_TRANSPORT_CLASS
@@ -43,7 +43,11 @@ module Elasticsearch
43
43
  #
44
44
  def __build_connection(host, options={}, block=nil)
45
45
  client = ::Curl::Easy.new
46
- client.headers = {'User-Agent' => "Curb #{Curl::CURB_VERSION}"}
46
+
47
+ headers = options[:headers] || {}
48
+ headers.update('User-Agent' => "Curb #{Curl::CURB_VERSION}")
49
+
50
+ client.headers = headers
47
51
  client.url = __full_url(host)
48
52
 
49
53
  if host[:user]
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Transport
3
- VERSION = "5.0.1"
3
+ VERSION = "5.0.2"
4
4
  end
5
5
  end
@@ -73,6 +73,11 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
73
73
  assert_equal 120, client.transport.options[:transport_options][:request][:timeout]
74
74
  end
75
75
 
76
+ should "set the 'Content-Type' header to 'application/json' by default" do
77
+ client = Elasticsearch::Transport::Client.new
78
+ assert_equal 'application/json', client.transport.options[:transport_options][:headers]['Content-Type']
79
+ end
80
+
76
81
  context "when passed hosts" do
77
82
  should "have localhost by default" do
78
83
  c = Elasticsearch::Transport::Client.new
@@ -77,6 +77,12 @@ else
77
77
  assert_raise(ArgumentError) { @transport.perform_request 'FOOBAR', '/' }
78
78
  end
79
79
 
80
+ should "properly pass the Content-Type header option" do
81
+ transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => { :transport_options => { :headers => { 'Content-Type' => 'foo/bar' } } }
82
+
83
+ assert_equal "foo/bar", transport.connections.first.connection.headers["Content-Type"]
84
+ end
85
+
80
86
  should "allow to set options for Curb" do
81
87
  transport = Curb.new :hosts => [ { :host => 'foobar', :port => 1234 } ] do |curl|
82
88
  curl.headers["User-Agent"] = "myapp-0.0"
@@ -42,6 +42,17 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
42
42
  @transport.perform_request 'POST', '/', {}, {:foo => 'bar'}
43
43
  end
44
44
 
45
+ should "properly pass the Content-Type header option" do
46
+ transport = Faraday.new :hosts => [ { :host => 'foobar', :port => 1234 } ], :options => { :transport_options => { :headers => { 'Content-Type' => 'foo/bar' } } }
47
+
48
+ transport.connections.first.connection.expects(:run_request).with do |method, url, body, headers|
49
+ assert_equal 'foo/bar', headers['Content-Type']
50
+ true
51
+ end.returns(stub_everything)
52
+
53
+ transport.perform_request 'GET', '/'
54
+ end
55
+
45
56
  should "serialize the request body" do
46
57
  @transport.connections.first.connection.expects(:run_request).returns(stub_everything)
47
58
  @transport.serializer.expects(:dump)
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: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-21 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -332,8 +332,24 @@ dependencies:
332
332
  - - ">="
333
333
  - !ruby/object:Gem::Version
334
334
  version: '0'
335
- description: |
336
- Ruby client for Elasticsearch. See the `elasticsearch` gem for full integration.
335
+ - !ruby/object:Gem::Dependency
336
+ name: test-unit
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '2'
342
+ type: :development
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '2'
349
+ description: 'Ruby client for Elasticsearch. See the `elasticsearch` gem for full
350
+ integration.
351
+
352
+ '
337
353
  email:
338
354
  - karel.minarik@elasticsearch.org
339
355
  executables: []
@@ -399,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
415
  version: '0'
400
416
  requirements: []
401
417
  rubyforge_project:
402
- rubygems_version: 2.2.2
418
+ rubygems_version: 2.6.8
403
419
  signing_key:
404
420
  specification_version: 4
405
421
  summary: Ruby client for Elasticsearch.