elasticsearch-transport 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mjg2ZWE4ZDY1YzIzNGQxMDAyOTEwNzc4MjYzZmZjYTJmZmZmZTY4Yg==
4
+ ZWFlNjhjYzk0N2Q0NGE0OTVkNzc5ODY3Y2Q2YTQ0YTVmMjgwOWYwYg==
5
5
  data.tar.gz: !binary |-
6
- YzgwYzI0MjYzMGFhZWI2N2Y4ZjEwYTFiNGEwMzExOTI0ODViMGIxOA==
6
+ ZTIyNzc1OGM0YzE3YWNiMDYzZjcyZjljYjMzNzA4OWI5MDNhMGM0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDRlODJhYjlhOGMzMTljZWI5YWRlOTcwY2JmNjM1M2NkNzA3ZTU1OTgwYzcx
10
- YTYxYWRkODZhYzk3ZmVmODRjMzI3NDQwZjFiYTJkYTBlMGNkNzg0MTY2ODdh
11
- ZjQzYmFjMDA4ODZlMjUwZTc5NGE0NDBmYzIxMWViYzg2ZjAxM2E=
9
+ YmQzY2JiODk5Yjg3Njc0ZmY3MWU4N2IwOTRmN2IzYjhmYjExYjczNGI2M2Rj
10
+ OTE5NDVkNTNkNGY1N2E4MDRmN2FlODI1MTQ5OGE0MDU5MTg2YWIyMTU0MGY5
11
+ NjY2ZWRmMmZmYmE0MmVjNGMzMGQyMGEwYjk1YWFjMjgxNmIyNTY=
12
12
  data.tar.gz: !binary |-
13
- YTdjYmUzMGI0NzU0ZGJkOTYxMTAzYmVhM2U4MzEwYmI2YmJiYjEyNzAzM2I4
14
- ZTcwOTcyMDNkZjdlZTg0YTRlYzk2OWQ3MWI2ZTVlZmJmNWI5MmU3ZWNjOWZj
15
- MDMzMDhlOWIyNjBjODI4ZGZiMzYwNjQxYTVkMWI2YWU5MjAzYTA=
13
+ YjEwZmI5YjIyYWNlMzM0ZGY1NmU3MzRiNDZmMGJlZjhmMTNjMDNjOTZiNGQx
14
+ ZDI1MjYyMjhkN2U3NjJkOTE5ZjNhMmQ2MDkxMzIxODQxYmZjYzdhY2UyZTk2
15
+ YWQyYzc0OGE2NWJmZDMzMTNmMGExZGEzN2I5MGJmNDFmMDQ0OGE=
data/README.md CHANGED
@@ -28,8 +28,12 @@ Features overview:
28
28
  * Node reloading (based on cluster state) on errors or on demand
29
29
 
30
30
  For optimal performance, you should use a HTTP library which supports persistent ("keep-alive") connections,
31
- e.g. [Typhoeus](https://github.com/typhoeus/typhoeus) or [Patron](https://github.com/toland/patron).
32
- Just `require 'typhoeus'` or `require 'patron'` in your code, and it will be used.
31
+ e.g. [Patron](https://github.com/toland/patron) or [Typhoeus](https://github.com/typhoeus/typhoeus).
32
+ Just `require 'patron'` or `require 'typhoeus'; require 'typhoeus/adapters/faraday'` in your code,
33
+ and it will be automatically used; other automatically used libraries are
34
+ [HTTPClient](https://rubygems.org/gems/httpclient) and
35
+ [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent).
36
+
33
37
  For detailed information, see example configurations [below](#transport-implementations).
34
38
 
35
39
  ## Installation
@@ -18,11 +18,12 @@ module Elasticsearch
18
18
  #
19
19
  def perform_request(method, path, params={}, body=nil)
20
20
  super do |connection, url|
21
- connection.connection.run_request \
21
+ response = connection.connection.run_request \
22
22
  method.downcase.to_sym,
23
23
  url,
24
24
  ( body ? __convert_to_json(body) : nil ),
25
25
  {}
26
+ Response.new response.status, response.body, response.headers
26
27
  end
27
28
  end
28
29
 
@@ -12,6 +12,7 @@ module Elasticsearch
12
12
  # @param headers [Hash] Response headers
13
13
  def initialize(status, body, headers={})
14
14
  @status, @body, @headers = status, body, headers
15
+ @body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
15
16
  end
16
17
  end
17
18
 
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Transport
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class Elasticsearch::Transport::Transport::ResponseTest < Test::Unit::TestCase
4
+ context "Response" do
5
+
6
+ should "force-encode the body into UTF" do
7
+ body = "Hello Encoding!".encode(Encoding::ISO_8859_1)
8
+ assert_equal 'ISO-8859-1', body.encoding.name
9
+
10
+ response = Elasticsearch::Transport::Transport::Response.new 200, body
11
+ assert_equal 'UTF-8', response.body.encoding.name
12
+ end unless RUBY_1_8
13
+
14
+ end
15
+ end
@@ -25,6 +25,12 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
25
25
  @transport.perform_request 'GET', '/'
26
26
  end
27
27
 
28
+ should "return a Response" do
29
+ @transport.connections.first.connection.expects(:run_request).returns(stub_everything)
30
+ response = @transport.perform_request 'GET', '/'
31
+ assert_instance_of Elasticsearch::Transport::Transport::Response, response
32
+ end
33
+
28
34
  should "properly prepare the request" do
29
35
  @transport.connections.first.connection.expects(:run_request).with do |method, url, body, headers|
30
36
  :post == method && '{"foo":"bar"}' == body
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: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -358,6 +358,7 @@ files:
358
358
  - test/unit/connection_collection_test.rb
359
359
  - test/unit/connection_selector_test.rb
360
360
  - test/unit/connection_test.rb
361
+ - test/unit/response_test.rb
361
362
  - test/unit/serializer_test.rb
362
363
  - test/unit/sniffer_test.rb
363
364
  - test/unit/transport_base_test.rb
@@ -397,6 +398,7 @@ test_files:
397
398
  - test/unit/connection_collection_test.rb
398
399
  - test/unit/connection_selector_test.rb
399
400
  - test/unit/connection_test.rb
401
+ - test/unit/response_test.rb
400
402
  - test/unit/serializer_test.rb
401
403
  - test/unit/sniffer_test.rb
402
404
  - test/unit/transport_base_test.rb