excon 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of excon might be problematic. Click here for more details.
- checksums.yaml +8 -8
- data/CONTRIBUTORS.md +2 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -5
- data/changelog.txt +10 -0
- data/excon.gemspec +3 -2
- data/lib/excon.rb +2 -2
- data/lib/excon/constants.rb +2 -1
- data/lib/excon/errors.rb +1 -1
- data/lib/excon/response.rb +3 -1
- data/lib/excon/socket.rb +7 -4
- data/lib/excon/ssl_socket.rb +4 -0
- data/lib/excon/standard_instrumentor.rb +35 -1
- data/tests/basic_tests.rb +46 -1
- data/tests/middlewares/instrumentation_tests.rb +1 -1
- data/tests/rackups/streaming.ru +20 -0
- data/tests/test_helper.rb +5 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2M4Mjg5MGIyMmMzZmU0MzU3MWQ3MzkwMWMxNzk1NWI3N2NjYmEyNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmIwZDllZDA5YWE5YTc4OTgyNTA5MDJhZmU3ZGVmYjBkNTFkYTNkZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzZmZDc4ZDFhMjRkM2IxNWRmMzM3ZGFlNWQ3YWFiYmEzM2UwOWUwYTQzNjU0
|
10
|
+
NGU1NzllYzNkNDBhYjE3ZWFlMGMwNTBjNDI2NDBlZmYwYzAzMjMxYTBiNzlh
|
11
|
+
YTU0MjU4OGJmYzc0MjNmYmVhMzVkNzZiN2NiZTI5ZWE2Y2M5MDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWU4NGRiM2RjMmY5OGVlYWQzMjFjY2Q3OThhMjBjY2UwNmY5MDllNTk5NGEx
|
14
|
+
MTYzNmU4Y2MzNDBjNzA4ZWU4M2QyOTM2YTc3YTBmZDAwMDllNDc2MWQ0ODMz
|
15
|
+
OWY0MTExMTIyOWU5ZDk5ZTI1OWI4MmEzNTZjNTA0ODVlOWJkMTA=
|
data/CONTRIBUTORS.md
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
* Dave Myron <therealdave.myron@gmail.com>
|
18
18
|
* Dave Newton <davelnewton@gmail.com>
|
19
19
|
* Dimitrij Denissenko <dimitrij@blacksquaremedia.com>
|
20
|
+
* Dominik Richter <dominik.richter@gmail.com>
|
20
21
|
* Eugene Howe <eugene@xtreme-computers.net>
|
21
22
|
* Evan Phoenix <evan@fallingsnow.net>
|
22
23
|
* Fabian Wiesel <fabian.wiesel@sap.com>
|
@@ -37,6 +38,7 @@
|
|
37
38
|
* Joshua Napoli <jnapoli@swipely-napoli.local>
|
38
39
|
* Konstantin Shabanov <etehtsea@gmail.com>
|
39
40
|
* Kyle Rames <kyle.rames@rackspace.com>
|
41
|
+
* Lewis Marshall <lewis@lmars.net>
|
40
42
|
* Lincoln Stoll <me@lstoll.net>
|
41
43
|
* Louis Sobel <sobel@mit.edu>
|
42
44
|
* Mathias Meyer <meyer@paperplanes.de>
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
excon (0.
|
4
|
+
excon (0.34.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -22,14 +22,14 @@ GEM
|
|
22
22
|
bouncy-castle-java (>= 1.5.0147)
|
23
23
|
json (1.7.3)
|
24
24
|
json (1.7.3-java)
|
25
|
-
kgio (2.
|
25
|
+
kgio (2.9.2)
|
26
26
|
minitest (4.7.5)
|
27
27
|
multi_json (1.3.6)
|
28
28
|
open4 (1.3.0)
|
29
|
-
rack (1.
|
29
|
+
rack (1.5.2)
|
30
30
|
rack-protection (1.2.0)
|
31
31
|
rack
|
32
|
-
raindrops (0.
|
32
|
+
raindrops (0.13.0)
|
33
33
|
rake (0.9.2.2)
|
34
34
|
rdoc (3.12)
|
35
35
|
json (~> 1.4)
|
@@ -245,7 +245,7 @@ GEM
|
|
245
245
|
rack-protection (~> 1.2)
|
246
246
|
tilt (~> 1.3, >= 1.3.3)
|
247
247
|
tilt (1.3.3)
|
248
|
-
unicorn (4.
|
248
|
+
unicorn (4.8.3)
|
249
249
|
kgio (~> 2.6)
|
250
250
|
rack
|
251
251
|
raindrops (~> 0.7)
|
@@ -261,6 +261,7 @@ DEPENDENCIES
|
|
261
261
|
excon!
|
262
262
|
jruby-openssl
|
263
263
|
open4
|
264
|
+
rack (~> 1.5)
|
264
265
|
rake
|
265
266
|
rdoc
|
266
267
|
rubysl (~> 2.0)
|
data/changelog.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.34.0 05/29/2014
|
2
|
+
=================
|
3
|
+
|
4
|
+
add support for setting ssl_verify_callback
|
5
|
+
stream partial results imediately, when available
|
6
|
+
update rack/unicorn in tests to support streaming tests
|
7
|
+
skip streaming tests on jruby (as they depend on unicorn)
|
8
|
+
update travis tests to use newest rubinius
|
9
|
+
improve formatting/readibility of standard instrumentor output
|
10
|
+
|
1
11
|
0.33.0 05/15/2014
|
2
12
|
=================
|
3
13
|
|
data/excon.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'excon'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '2014-
|
16
|
+
s.version = '0.34.0'
|
17
|
+
s.date = '2014-05-29'
|
18
18
|
s.rubyforge_project = 'excon'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -145,6 +145,7 @@ Gem::Specification.new do |s|
|
|
145
145
|
tests/rackups/response_header.ru
|
146
146
|
tests/rackups/ssl.ru
|
147
147
|
tests/rackups/ssl_verify_peer.ru
|
148
|
+
tests/rackups/streaming.ru
|
148
149
|
tests/rackups/thread_safety.ru
|
149
150
|
tests/rackups/timeout.ru
|
150
151
|
tests/rackups/webrick_patch.rb
|
data/lib/excon.rb
CHANGED
@@ -157,13 +157,13 @@ module Excon
|
|
157
157
|
end
|
158
158
|
if url = request_params.delete(:url)
|
159
159
|
uri = URI.parse(url)
|
160
|
-
request_params
|
160
|
+
request_params = {
|
161
161
|
:host => uri.host,
|
162
162
|
:path => uri.path,
|
163
163
|
:port => uri.port,
|
164
164
|
:query => uri.query,
|
165
165
|
:scheme => uri.scheme
|
166
|
-
)
|
166
|
+
}.merge!(request_params)
|
167
167
|
if uri.user || uri.password
|
168
168
|
request_params[:headers] ||= {}
|
169
169
|
user, pass = Utils.unescape_form(uri.user.to_s), Utils.unescape_form(uri.password.to_s)
|
data/lib/excon/constants.rb
CHANGED
data/lib/excon/errors.rb
CHANGED
@@ -9,7 +9,7 @@ module Excon
|
|
9
9
|
|
10
10
|
def initialize(socket_error=nil)
|
11
11
|
if socket_error.message =~ /certificate verify failed/
|
12
|
-
super("Unable to verify certificate, please set `Excon.defaults[:ssl_ca_path] = path_to_certs`, `ENV['SSL_CERT_DIR'] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, `ENV['SSL_CERT_FILE'] = path_to_file` or `Excon.defaults[:ssl_verify_peer] = false` (less secure).")
|
12
|
+
super("Unable to verify certificate, please set `Excon.defaults[:ssl_ca_path] = path_to_certs`, `ENV['SSL_CERT_DIR'] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, `ENV['SSL_CERT_FILE'] = path_to_file`, `Excon.defaults[:ssl_verify_callback] = callback` (see OpenSSL::SSL::SSLContext#verify_callback), or `Excon.defaults[:ssl_verify_peer] = false` (less secure).")
|
13
13
|
else
|
14
14
|
super("#{socket_error.message} (#{socket_error.class})")
|
15
15
|
end
|
data/lib/excon/response.rb
CHANGED
data/lib/excon/socket.rb
CHANGED
@@ -53,10 +53,13 @@ module Excon
|
|
53
53
|
raise(error)
|
54
54
|
end
|
55
55
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
|
56
|
-
if
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
if @read_buffer.empty?
|
57
|
+
# if we didn't read anything, try again...
|
58
|
+
if IO.select([@socket], nil, nil, @data[:read_timeout])
|
59
|
+
retry
|
60
|
+
else
|
61
|
+
raise(Excon::Errors::Timeout.new("read timeout reached"))
|
62
|
+
end
|
60
63
|
end
|
61
64
|
rescue EOFError
|
62
65
|
@eof = true
|
data/lib/excon/ssl_socket.rb
CHANGED
@@ -47,6 +47,10 @@ module Excon
|
|
47
47
|
Excon.display_warning("Excon unable to add file to cert store, ignoring: #{ca_file}\n[#{e.class}] #{e.message}")
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
if verify_callback = @data[:ssl_verify_callback]
|
52
|
+
ssl_context.verify_callback = verify_callback
|
53
|
+
end
|
50
54
|
else
|
51
55
|
# turn verification off
|
52
56
|
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -2,14 +2,48 @@ module Excon
|
|
2
2
|
class StandardInstrumentor
|
3
3
|
def self.instrument(name, params = {}, &block)
|
4
4
|
params = params.dup
|
5
|
+
|
6
|
+
# reduce duplication/noise of output
|
7
|
+
params.delete(:connection)
|
8
|
+
params.delete(:stack)
|
9
|
+
|
5
10
|
if params.has_key?(:headers) && params[:headers].has_key?('Authorization')
|
6
11
|
params[:headers] = params[:headers].dup
|
7
12
|
params[:headers]['Authorization'] = REDACTED
|
8
13
|
end
|
14
|
+
|
9
15
|
if params.has_key?(:password)
|
10
16
|
params[:password] = REDACTED
|
11
17
|
end
|
12
|
-
|
18
|
+
|
19
|
+
$stderr.puts(name)
|
20
|
+
indent = 0
|
21
|
+
pretty_printer = lambda do |hash|
|
22
|
+
indent += 2
|
23
|
+
max_key_length = hash.keys.map {|key| key.inspect.length}.max
|
24
|
+
hash.keys.sort_by {|key| key.to_s}.each do |key|
|
25
|
+
value = hash[key]
|
26
|
+
$stderr.write("#{' ' * indent}#{key.inspect.ljust(max_key_length)} => ")
|
27
|
+
case value
|
28
|
+
when Array
|
29
|
+
$stderr.puts("[")
|
30
|
+
value.each do |v|
|
31
|
+
$stderr.puts("#{' ' * indent} #{v.inspect}")
|
32
|
+
end
|
33
|
+
$stderr.write("#{' ' * indent}]")
|
34
|
+
when Hash
|
35
|
+
$stderr.puts("{")
|
36
|
+
pretty_printer.call(value)
|
37
|
+
$stderr.write("#{' ' * indent}}")
|
38
|
+
else
|
39
|
+
$stderr.write("#{value.inspect}")
|
40
|
+
end
|
41
|
+
$stderr.puts
|
42
|
+
end
|
43
|
+
indent -= 2
|
44
|
+
end
|
45
|
+
pretty_printer.call(params)
|
46
|
+
|
13
47
|
if block_given?
|
14
48
|
yield
|
15
49
|
end
|
data/tests/basic_tests.rb
CHANGED
@@ -18,6 +18,51 @@ Shindo.tests('Excon basics') do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
Shindo.tests('Excon streaming basics') do
|
22
|
+
pending if RUBY_PLATFORM == 'java' # need to find suitable server for jruby
|
23
|
+
with_unicorn('streaming.ru') do
|
24
|
+
# expected values: the response, in pieces, and a timeout after each piece
|
25
|
+
res = %w{Hello streamy world}
|
26
|
+
timeout = 1
|
27
|
+
|
28
|
+
# expect the full response as a string
|
29
|
+
# and expect it to take a (timeout * pieces) seconds
|
30
|
+
tests('simple blocking request on streaming endpoint').returns([res.join(''),'response time ok']) do
|
31
|
+
start = Time.now
|
32
|
+
ret = Excon.get('http://127.0.0.1:9292/streamed/simple').body
|
33
|
+
|
34
|
+
if Time.now - start <= timeout*3
|
35
|
+
[ret, 'streaming response came too quickly']
|
36
|
+
else
|
37
|
+
[ret, 'response time ok']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# expect each response piece to arrive to the body right away
|
42
|
+
# and wait for timeout until next one arrives
|
43
|
+
tests('simple request with response_block on streaming endpoint').returns([res,'response times ok']) do
|
44
|
+
ret = []
|
45
|
+
timing = 'response times ok'
|
46
|
+
start = Time.now
|
47
|
+
Excon.get('http://127.0.0.1:9292/streamed/simple', :response_block => lambda do |c,r,t|
|
48
|
+
# check if the timing is ok
|
49
|
+
# each response arrives after timeout and before timeout + 1
|
50
|
+
cur_time = Time.now - start
|
51
|
+
if cur_time < ret.length * timeout or cur_time > (ret.length+1) * timeout
|
52
|
+
timing = 'response time not ok!'
|
53
|
+
end
|
54
|
+
# add the response
|
55
|
+
ret.push(c)
|
56
|
+
end)
|
57
|
+
# validate the final timing
|
58
|
+
if Time.now - start <= timeout*3
|
59
|
+
timing = 'final timing was not ok!'
|
60
|
+
end
|
61
|
+
[ret, timing]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
21
66
|
Shindo.tests('Excon basics (Basic Auth Pass)') do
|
22
67
|
with_rackup('basic_auth.ru') do
|
23
68
|
basic_tests('http://test_user:test_password@127.0.0.1:9292')
|
@@ -102,7 +147,7 @@ Shindo.tests('Excon basics (Unix socket)') do
|
|
102
147
|
pending if RUBY_PLATFORM == 'java' # need to find suitable server for jruby
|
103
148
|
|
104
149
|
file_name = '/tmp/unicorn.sock'
|
105
|
-
with_unicorn('basic.ru', file_name) do
|
150
|
+
with_unicorn('basic.ru', 'unix://'+file_name) do
|
106
151
|
basic_tests("unix:/", :socket => file_name)
|
107
152
|
|
108
153
|
tests('explicit uri passed to connection') do
|
@@ -155,7 +155,7 @@ Shindo.tests('Excon instrumentation') do
|
|
155
155
|
connection.get(:idempotent => true)
|
156
156
|
end
|
157
157
|
|
158
|
-
captured_stderr.string.split("\n").map {|event| event.split(' ').first}
|
158
|
+
captured_stderr.string.split("\n").reject {|line| line =~ %r{^ }}.map {|event| event.split(' ').first}
|
159
159
|
ensure
|
160
160
|
$stderr = original_stderr
|
161
161
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
use Rack::ContentType, "text/plain"
|
2
|
+
|
3
|
+
app = lambda do |env|
|
4
|
+
response_headers = {}
|
5
|
+
response_headers["rack.hijack"] = lambda do |io|
|
6
|
+
# Write directly to IO of the response
|
7
|
+
begin
|
8
|
+
['Hello','streamy','world'].each do |x|
|
9
|
+
io.write(x)
|
10
|
+
io.flush
|
11
|
+
sleep 1
|
12
|
+
end
|
13
|
+
ensure
|
14
|
+
io.close
|
15
|
+
end
|
16
|
+
end
|
17
|
+
[200, response_headers, nil]
|
18
|
+
end
|
19
|
+
|
20
|
+
run app
|
data/tests/test_helper.rb
CHANGED
@@ -263,10 +263,11 @@ ensure
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
def with_unicorn(name,
|
266
|
+
def with_unicorn(name, listen='127.0.0.1:9292')
|
267
267
|
unless RUBY_PLATFORM == 'java'
|
268
268
|
GC.disable if RUBY_VERSION < '1.9'
|
269
|
-
|
269
|
+
unix_socket = listen.sub('unix://', '') if listen.start_with? 'unix://'
|
270
|
+
pid, w, r, e = Open4.popen4("unicorn", "--no-default-middleware","-l", listen, rackup_path(name))
|
270
271
|
until e.gets =~ /worker=0 ready/; end
|
271
272
|
else
|
272
273
|
# need to find suitable server for jruby
|
@@ -278,8 +279,8 @@ ensure
|
|
278
279
|
GC.enable if RUBY_VERSION < '1.9'
|
279
280
|
Process.wait(pid)
|
280
281
|
end
|
281
|
-
if File.exist?(
|
282
|
-
File.delete(
|
282
|
+
if not unix_socket.nil? and File.exist?(unix_socket)
|
283
|
+
File.delete(unix_socket)
|
283
284
|
end
|
284
285
|
end
|
285
286
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.34.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dpiddy (Dan Peterson)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- tests/rackups/response_header.ru
|
209
209
|
- tests/rackups/ssl.ru
|
210
210
|
- tests/rackups/ssl_verify_peer.ru
|
211
|
+
- tests/rackups/streaming.ru
|
211
212
|
- tests/rackups/thread_safety.ru
|
212
213
|
- tests/rackups/timeout.ru
|
213
214
|
- tests/rackups/webrick_patch.rb
|