excon 0.16.3 → 0.16.4
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.
- data/changelog.txt +17 -4
- data/excon.gemspec +2 -2
- data/lib/excon.rb +7 -7
- data/lib/excon/connection.rb +16 -11
- data/lib/excon/constants.rb +7 -1
- data/lib/excon/ssl_socket.rb +3 -7
- data/lib/excon/standard_instrumentor.rb +5 -0
- data/tests/authorization_header_tests.rb +3 -3
- data/tests/instrumentation_tests.rb +51 -17
- metadata +18 -53
data/changelog.txt
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
0.16.
|
1
|
+
0.16.4 09/25/2012
|
2
|
+
=================
|
3
|
+
|
4
|
+
better behavior nonblock and use DEFAULT_NONBLOCK constant
|
5
|
+
update deprecation/warnings to use $stderr
|
6
|
+
consistency fixes for REDACT
|
7
|
+
add REDACT behavior to standard_instrumentor
|
8
|
+
|
9
|
+
0.16.3 09/20/2012
|
10
|
+
=================
|
11
|
+
|
12
|
+
remove overly paranoid const checking
|
13
|
+
change chunk_size to be a param for consistency
|
14
|
+
|
15
|
+
0.16.2 08/27/2012
|
2
16
|
=================
|
3
17
|
|
4
18
|
provide more helpful backtraces on connection requests
|
@@ -9,13 +23,12 @@ rearrange excon.rb to initialize defaults sooner
|
|
9
23
|
set nonblock at init time for ssl socket
|
10
24
|
fixes around nonbleck to properly skip/warn if unavailable but selected
|
11
25
|
|
12
|
-
|
13
|
-
0.16.1 09/15/2012
|
26
|
+
0.16.1 08/15/2012
|
14
27
|
=================
|
15
28
|
|
16
29
|
default to SSLv3 usage
|
17
30
|
|
18
|
-
0.16.0
|
31
|
+
0.16.0 08/14/2012
|
19
32
|
=================
|
20
33
|
|
21
34
|
add nonblock => false to use blocking requests with Timeout.timeout
|
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.16.
|
17
|
-
s.date = '2012-09-
|
16
|
+
s.version = '0.16.4'
|
17
|
+
s.date = '2012-09-25'
|
18
18
|
s.rubyforge_project = 'excon'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/excon.rb
CHANGED
@@ -21,7 +21,7 @@ module Excon
|
|
21
21
|
:headers => {},
|
22
22
|
:instrumentor_name => 'excon',
|
23
23
|
:mock => false,
|
24
|
-
:nonblock =>
|
24
|
+
:nonblock => DEFAULT_NONBLOCK,
|
25
25
|
:read_timeout => 60,
|
26
26
|
:retry_limit => DEFAULT_RETRY_LIMIT,
|
27
27
|
:ssl_ca_file => DEFAULT_CA_FILE,
|
@@ -52,7 +52,7 @@ module Excon
|
|
52
52
|
|
53
53
|
# Status of mocking
|
54
54
|
def mock
|
55
|
-
puts("Excon#mock is deprecated, pass Excon.defaults[:mock] instead (#{caller.first})")
|
55
|
+
$stderr.puts("Excon#mock is deprecated, pass Excon.defaults[:mock] instead (#{caller.first})")
|
56
56
|
self.defaults[:mock]
|
57
57
|
end
|
58
58
|
|
@@ -60,33 +60,33 @@ module Excon
|
|
60
60
|
# false is the default and works as expected
|
61
61
|
# true returns a value from stubs or raises
|
62
62
|
def mock=(new_mock)
|
63
|
-
puts("Excon#mock is deprecated, pass Excon.defaults[:mock]= instead (#{caller.first})")
|
63
|
+
$stderr.puts("Excon#mock is deprecated, pass Excon.defaults[:mock]= instead (#{caller.first})")
|
64
64
|
self.defaults[:mock] = new_mock
|
65
65
|
end
|
66
66
|
|
67
67
|
# @return [String] The filesystem path to the SSL Certificate Authority
|
68
68
|
def ssl_ca_path
|
69
|
-
puts("Excon#ssl_ca_path is deprecated, use Excon.defaults[:ssl_ca_path] instead (#{caller.first})")
|
69
|
+
$stderr.puts("Excon#ssl_ca_path is deprecated, use Excon.defaults[:ssl_ca_path] instead (#{caller.first})")
|
70
70
|
self.defaults[:ssl_ca_path]
|
71
71
|
end
|
72
72
|
|
73
73
|
# Change path to the SSL Certificate Authority
|
74
74
|
# @return [String] The filesystem path to the SSL Certificate Authority
|
75
75
|
def ssl_ca_path=(new_ssl_ca_path)
|
76
|
-
puts("Excon#ssl_ca_path= is deprecated, use Excon.defaults[:ssl_ca_path]= instead (#{caller.first})")
|
76
|
+
$stderr.puts("Excon#ssl_ca_path= is deprecated, use Excon.defaults[:ssl_ca_path]= instead (#{caller.first})")
|
77
77
|
self.defaults[:ssl_ca_path] = new_ssl_ca_path
|
78
78
|
end
|
79
79
|
|
80
80
|
# @return [true, false] Whether or not to verify the peer's SSL certificate / chain
|
81
81
|
def ssl_verify_peer
|
82
|
-
puts("Excon#ssl_verify_peer= is deprecated, use Excon.defaults[:ssl_verify_peer]= instead (#{caller.first})")
|
82
|
+
$stderr.puts("Excon#ssl_verify_peer= is deprecated, use Excon.defaults[:ssl_verify_peer]= instead (#{caller.first})")
|
83
83
|
self.defaults[:ssl_verify_peer]
|
84
84
|
end
|
85
85
|
|
86
86
|
# Change the status of ssl peer verification
|
87
87
|
# @see Excon#ssl_verify_peer (attr_reader)
|
88
88
|
def ssl_verify_peer=(new_ssl_verify_peer)
|
89
|
-
puts("Excon#ssl_verify_peer is deprecated, use Excon.defaults[:ssl_verify_peer] instead (#{caller.first})")
|
89
|
+
$stderr.puts("Excon#ssl_verify_peer is deprecated, use Excon.defaults[:ssl_verify_peer] instead (#{caller.first})")
|
90
90
|
self.defaults[:ssl_verify_peer] = new_ssl_verify_peer
|
91
91
|
end
|
92
92
|
|
data/lib/excon/connection.rb
CHANGED
@@ -82,7 +82,7 @@ module Excon
|
|
82
82
|
end
|
83
83
|
|
84
84
|
if block_given?
|
85
|
-
puts("Excon requests with a block are deprecated, pass :response_block instead (#{caller.first})")
|
85
|
+
$stderr.puts("Excon requests with a block are deprecated, pass :response_block instead (#{caller.first})")
|
86
86
|
params[:response_block] = Proc.new
|
87
87
|
end
|
88
88
|
|
@@ -138,26 +138,31 @@ module Excon
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def retry_limit=(new_retry_limit)
|
141
|
-
puts("Excon::Connection#retry_limit= is deprecated, pass :retry_limit to the initializer (#{caller.first})")
|
141
|
+
$stderr.puts("Excon::Connection#retry_limit= is deprecated, pass :retry_limit to the initializer (#{caller.first})")
|
142
142
|
@connection[:retry_limit] = new_retry_limit
|
143
143
|
end
|
144
144
|
|
145
145
|
def retry_limit
|
146
|
-
puts("Excon::Connection#retry_limit is deprecated, pass :retry_limit to the initializer (#{caller.first})")
|
146
|
+
$stderr.puts("Excon::Connection#retry_limit is deprecated, pass :retry_limit to the initializer (#{caller.first})")
|
147
147
|
@connection[:retry_limit] ||= DEFAULT_RETRY_LIMIT
|
148
148
|
end
|
149
149
|
|
150
150
|
def inspect
|
151
|
-
|
152
|
-
|
153
|
-
if ! @connection[:headers]['Authorization'].nil?
|
154
|
-
c_clean[:headers]['Authorization'] = 'REDACTED'
|
151
|
+
vars = instance_variables.inject({}) do |accum, var|
|
152
|
+
accum.merge!(var.to_sym => instance_variable_get(var))
|
155
153
|
end
|
156
|
-
vars
|
157
|
-
|
158
|
-
|
154
|
+
if vars[:'@connection'][:headers].has_key?('Authorization')
|
155
|
+
vars[:'@connection'] = vars[:'@connection'].dup
|
156
|
+
vars[:'@connection'][:headers] = vars[:'@connection'][:headers].dup
|
157
|
+
vars[:'@connection'][:headers]['Authorization'] = REDACTED
|
159
158
|
end
|
160
|
-
|
159
|
+
inspection = '#<Excon::Connection:'
|
160
|
+
inspection << (object_id << 1).to_s(16)
|
161
|
+
vars.each do |key, value|
|
162
|
+
inspection << ' ' << key.to_s << '=' << value.inspect
|
163
|
+
end
|
164
|
+
inspection << '>'
|
165
|
+
inspection
|
161
166
|
end
|
162
167
|
|
163
168
|
private
|
data/lib/excon/constants.rb
CHANGED
@@ -11,6 +11,10 @@ module Excon
|
|
11
11
|
CHUNK_SIZE = DEFAULT_CHUNK_SIZE
|
12
12
|
end
|
13
13
|
|
14
|
+
DEFAULT_NONBLOCK = OpenSSL::SSL::SSLSocket.public_method_defined?(:connect_nonblock) &&
|
15
|
+
OpenSSL::SSL::SSLSocket.public_method_defined?(:read_nonblock) &&
|
16
|
+
OpenSSL::SSL::SSLSocket.public_method_defined?(:write_nonblock)
|
17
|
+
|
14
18
|
DEFAULT_RETRY_LIMIT = 4
|
15
19
|
|
16
20
|
FORCE_ENC = CR_NL.respond_to?(:force_encoding)
|
@@ -23,7 +27,9 @@ module Excon
|
|
23
27
|
|
24
28
|
NO_ENTITY = [204, 205, 304].freeze
|
25
29
|
|
26
|
-
|
30
|
+
REDACTED = 'REDACTED'
|
31
|
+
|
32
|
+
VERSION = '0.16.4'
|
27
33
|
|
28
34
|
unless ::IO.const_defined?(:WaitReadable)
|
29
35
|
class ::IO
|
data/lib/excon/ssl_socket.rb
CHANGED
@@ -91,13 +91,9 @@ module Excon
|
|
91
91
|
|
92
92
|
def check_nonblock_support
|
93
93
|
# backwards compatability for things lacking nonblock
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
unless params[:nonblock] == false
|
98
|
-
puts("Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket")
|
99
|
-
params[:nonblock] = false
|
100
|
-
end
|
94
|
+
if !DEFAULT_NONBLOCK && params[:nonblock]
|
95
|
+
$stderr.puts("Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket")
|
96
|
+
params[:nonblock] = false
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Excon
|
2
2
|
class StandardInstrumentor
|
3
3
|
def self.instrument(name, params = {}, &block)
|
4
|
+
if params.has_key?(:headers) && params[:headers].has_key?('Authorization')
|
5
|
+
params = params.dup
|
6
|
+
params[:headers] = params[:headers].dup
|
7
|
+
params[:headers]['Authorization'] = REDACTED
|
8
|
+
end
|
4
9
|
$stderr.puts("#{name} #{params}")
|
5
10
|
if block_given?
|
6
11
|
yield
|
@@ -8,11 +8,11 @@ with_rackup('basic_auth.ru') do
|
|
8
8
|
cases.each do |desc,url,auth_header|
|
9
9
|
conn = Excon.new(url)
|
10
10
|
test("authorization header concealed for #{desc}") do
|
11
|
-
!
|
11
|
+
!conn.inspect.include?(auth_header)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
conn.connection[:headers]['Authorization']
|
14
|
+
test("authorization header remains correct for #{desc}") do
|
15
|
+
conn.connection[:headers]['Authorization'] == auth_header
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
@@ -136,26 +136,60 @@ Shindo.tests('Excon instrumentation') do
|
|
136
136
|
(@events.first.duration/1000 - REQUEST_DELAY_SECONDS).abs < 1
|
137
137
|
end
|
138
138
|
|
139
|
-
tests('standard instrumentor')
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
139
|
+
tests('standard instrumentor') do
|
140
|
+
|
141
|
+
tests('success').returns(
|
142
|
+
['excon.request', 'excon.retry', 'excon.retry', 'excon.retry', 'excon.error']) do
|
143
|
+
|
144
|
+
begin
|
145
|
+
original_stderr = $stderr
|
146
|
+
$stderr = captured_stderr = StringIO.new
|
147
|
+
stub_failure
|
148
|
+
connection = Excon.new(
|
149
|
+
'http://127.0.0.1:9292',
|
150
|
+
:instrumentor => Excon::StandardInstrumentor,
|
151
|
+
:mock => true
|
152
|
+
)
|
153
|
+
raises(Excon::Errors::SocketError) do
|
154
|
+
connection.get(:idempotent => true)
|
155
|
+
end
|
156
|
+
|
157
|
+
captured_stderr.string.split("\n").map {|event| event.split(' ').first}
|
158
|
+
ensure
|
159
|
+
$stderr = original_stderr
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
tests('authorization header REDACT') do
|
164
|
+
|
165
|
+
begin
|
166
|
+
original_stderr = $stderr
|
167
|
+
$stderr = @captured_stderr = StringIO.new
|
168
|
+
stub_failure
|
169
|
+
@connection = Excon.new(
|
170
|
+
'http://user:pass@127.0.0.1:9292',
|
171
|
+
:instrumentor => Excon::StandardInstrumentor,
|
172
|
+
:mock => true
|
173
|
+
)
|
174
|
+
raises(Excon::Errors::SocketError) do
|
175
|
+
@connection.get(:idempotent => true)
|
176
|
+
end
|
177
|
+
ensure
|
178
|
+
$stderr = original_stderr
|
179
|
+
end
|
180
|
+
|
181
|
+
@auth_header = 'Basic dXNlcjpwYXNz'
|
182
|
+
|
183
|
+
tests('does not appear in response') do
|
184
|
+
!@captured_stderr.include?(@auth_header)
|
185
|
+
end
|
186
|
+
|
187
|
+
test('does not mutate Authorization value') do
|
188
|
+
@connection.connection[:headers]['Authorization'] == @auth_header
|
153
189
|
end
|
154
190
|
|
155
|
-
captured_stderr.string.split("\n").map {|event| event.split(' ').first}
|
156
|
-
ensure
|
157
|
-
$stderr = original_stderr
|
158
191
|
end
|
192
|
+
|
159
193
|
end
|
160
194
|
|
161
195
|
tests('use our own instrumentor').returns(
|
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.16.
|
4
|
+
version: 0.16.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirement: &70229726929200 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,15 +23,10 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ! '>='
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '0'
|
26
|
+
version_requirements: *70229726929200
|
32
27
|
- !ruby/object:Gem::Dependency
|
33
28
|
name: delorean
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirement: &70229726928740 !ruby/object:Gem::Requirement
|
35
30
|
none: false
|
36
31
|
requirements:
|
37
32
|
- - ! '>='
|
@@ -39,15 +34,10 @@ dependencies:
|
|
39
34
|
version: '0'
|
40
35
|
type: :development
|
41
36
|
prerelease: false
|
42
|
-
version_requirements:
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
37
|
+
version_requirements: *70229726928740
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
39
|
name: open4
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &70229726928320 !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
42
|
requirements:
|
53
43
|
- - ! '>='
|
@@ -55,15 +45,10 @@ dependencies:
|
|
55
45
|
version: '0'
|
56
46
|
type: :development
|
57
47
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ! '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
48
|
+
version_requirements: *70229726928320
|
64
49
|
- !ruby/object:Gem::Dependency
|
65
50
|
name: rake
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &70229726927900 !ruby/object:Gem::Requirement
|
67
52
|
none: false
|
68
53
|
requirements:
|
69
54
|
- - ! '>='
|
@@ -71,15 +56,10 @@ dependencies:
|
|
71
56
|
version: '0'
|
72
57
|
type: :development
|
73
58
|
prerelease: false
|
74
|
-
version_requirements:
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ! '>='
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '0'
|
59
|
+
version_requirements: *70229726927900
|
80
60
|
- !ruby/object:Gem::Dependency
|
81
61
|
name: rdoc
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirement: &70229726927480 !ruby/object:Gem::Requirement
|
83
63
|
none: false
|
84
64
|
requirements:
|
85
65
|
- - ! '>='
|
@@ -87,15 +67,10 @@ dependencies:
|
|
87
67
|
version: '0'
|
88
68
|
type: :development
|
89
69
|
prerelease: false
|
90
|
-
version_requirements:
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ! '>='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
70
|
+
version_requirements: *70229726927480
|
96
71
|
- !ruby/object:Gem::Dependency
|
97
72
|
name: shindo
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirement: &70229726943440 !ruby/object:Gem::Requirement
|
99
74
|
none: false
|
100
75
|
requirements:
|
101
76
|
- - ! '>='
|
@@ -103,15 +78,10 @@ dependencies:
|
|
103
78
|
version: '0'
|
104
79
|
type: :development
|
105
80
|
prerelease: false
|
106
|
-
version_requirements:
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ! '>='
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '0'
|
81
|
+
version_requirements: *70229726943440
|
112
82
|
- !ruby/object:Gem::Dependency
|
113
83
|
name: sinatra
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirement: &70229726943020 !ruby/object:Gem::Requirement
|
115
85
|
none: false
|
116
86
|
requirements:
|
117
87
|
- - ! '>='
|
@@ -119,12 +89,7 @@ dependencies:
|
|
119
89
|
version: '0'
|
120
90
|
type: :development
|
121
91
|
prerelease: false
|
122
|
-
version_requirements:
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ! '>='
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '0'
|
92
|
+
version_requirements: *70229726943020
|
128
93
|
description: EXtended http(s) CONnections
|
129
94
|
email: geemus@gmail.com
|
130
95
|
executables: []
|
@@ -204,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
169
|
version: '0'
|
205
170
|
segments:
|
206
171
|
- 0
|
207
|
-
hash:
|
172
|
+
hash: 2397568301879595027
|
208
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
174
|
none: false
|
210
175
|
requirements:
|
@@ -213,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
178
|
version: '0'
|
214
179
|
requirements: []
|
215
180
|
rubyforge_project: excon
|
216
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.15
|
217
182
|
signing_key:
|
218
183
|
specification_version: 2
|
219
184
|
summary: speed, persistence, http(s)
|