excon 0.16.1 → 0.16.2
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 +12 -0
- data/excon.gemspec +3 -2
- data/lib/excon.rb +17 -10
- data/lib/excon/connection.rb +15 -2
- data/lib/excon/constants.rb +1 -1
- data/lib/excon/ssl_socket.rb +32 -26
- data/tests/authorization_header_tests.rb +20 -0
- metadata +18 -17
data/changelog.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.16.2 09/27/2012
|
2
|
+
=================
|
3
|
+
|
4
|
+
provide more helpful backtraces on connection requests
|
5
|
+
provide more helpful backtraces on one-off requests
|
6
|
+
rearrange class methods so params will pass to socket
|
7
|
+
integrate nonblock backwards compatability fix
|
8
|
+
rearrange excon.rb to initialize defaults sooner
|
9
|
+
set nonblock at init time for ssl socket
|
10
|
+
fixes around nonbleck to properly skip/warn if unavailable but selected
|
11
|
+
|
12
|
+
|
1
13
|
0.16.1 09/15/2012
|
2
14
|
=================
|
3
15
|
|
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-08-
|
16
|
+
s.version = '0.16.2'
|
17
|
+
s.date = '2012-08-27'
|
18
18
|
s.rubyforge_project = 'excon'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -98,6 +98,7 @@ Gem::Specification.new do |s|
|
|
98
98
|
lib/excon/socket.rb
|
99
99
|
lib/excon/ssl_socket.rb
|
100
100
|
lib/excon/standard_instrumentor.rb
|
101
|
+
tests/authorization_header_tests.rb
|
101
102
|
tests/bad_tests.rb
|
102
103
|
tests/basic_tests.rb
|
103
104
|
tests/data/xs
|
data/lib/excon.rb
CHANGED
@@ -9,14 +9,7 @@ require 'socket'
|
|
9
9
|
require 'timeout'
|
10
10
|
require 'uri'
|
11
11
|
|
12
|
-
|
13
|
-
require 'excon/connection'
|
14
|
-
require 'excon/errors'
|
15
|
-
require 'excon/response'
|
16
|
-
require 'excon/socket'
|
17
|
-
require 'excon/ssl_socket'
|
18
|
-
require 'excon/standard_instrumentor'
|
19
|
-
|
12
|
+
# Define defaults first so they will be available to other files
|
20
13
|
module Excon
|
21
14
|
class << self
|
22
15
|
|
@@ -42,6 +35,20 @@ module Excon
|
|
42
35
|
@defaults = new_defaults
|
43
36
|
end
|
44
37
|
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'excon/constants'
|
42
|
+
require 'excon/connection'
|
43
|
+
require 'excon/errors'
|
44
|
+
require 'excon/response'
|
45
|
+
require 'excon/socket'
|
46
|
+
require 'excon/ssl_socket'
|
47
|
+
require 'excon/standard_instrumentor'
|
48
|
+
|
49
|
+
module Excon
|
50
|
+
class << self
|
51
|
+
|
45
52
|
# Status of mocking
|
46
53
|
def mock
|
47
54
|
puts("Excon#mock is deprecated, pass Excon.defaults[:mock] instead (#{caller.first})")
|
@@ -117,9 +124,9 @@ module Excon
|
|
117
124
|
|
118
125
|
# Generic non-persistent HTTP methods
|
119
126
|
HTTP_VERBS.each do |method|
|
120
|
-
|
127
|
+
module_eval <<-DEF, __FILE__, __LINE__ + 1
|
121
128
|
def #{method}(url, params = {}, &block)
|
122
|
-
new(url).request(
|
129
|
+
new(url, params).request(:method => :#{method}, &block)
|
123
130
|
end
|
124
131
|
DEF
|
125
132
|
end
|
data/lib/excon/connection.rb
CHANGED
@@ -130,7 +130,7 @@ module Excon
|
|
130
130
|
|
131
131
|
# Generate HTTP request verb methods
|
132
132
|
Excon::HTTP_VERBS.each do |method|
|
133
|
-
|
133
|
+
class_eval <<-DEF, __FILE__, __LINE__ + 1
|
134
134
|
def #{method}(params={}, &block)
|
135
135
|
request(params.merge!(:method => :#{method}), &block)
|
136
136
|
end
|
@@ -147,7 +147,20 @@ module Excon
|
|
147
147
|
@connection[:retry_limit] ||= DEFAULT_RETRY_LIMIT
|
148
148
|
end
|
149
149
|
|
150
|
-
|
150
|
+
def inspect
|
151
|
+
c_clean = @connection.dup
|
152
|
+
c_clean[:headers] = @connection[:headers].dup
|
153
|
+
if ! @connection[:headers]['Authorization'].nil?
|
154
|
+
c_clean[:headers]['Authorization'] = 'REDACTED'
|
155
|
+
end
|
156
|
+
vars = instance_variables.map do |x|
|
157
|
+
vals = x.to_s.eql?("@connection") ? c_clean : instance_variable_get(x)
|
158
|
+
"#{x}=#{vals.inspect}"
|
159
|
+
end
|
160
|
+
"#{self.to_s}".gsub(/>\z/, " " + vars.join(", ") + '>')
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
151
164
|
|
152
165
|
def detect_content_length(body)
|
153
166
|
if body.is_a?(String)
|
data/lib/excon/constants.rb
CHANGED
data/lib/excon/ssl_socket.rb
CHANGED
@@ -1,33 +1,10 @@
|
|
1
1
|
module Excon
|
2
2
|
class SSLSocket < Socket
|
3
3
|
|
4
|
-
# backwards compatability for things lacking connect_nonblock
|
5
|
-
unless OpenSSL::SSL::SSLSocket.public_method_defined?(:connect_nonblock)
|
6
|
-
|
7
|
-
undef_method :connect
|
8
|
-
def connect
|
9
|
-
@socket = TCPSocket.new(@params[:host], @params[:port])
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
# backwards compatability for things lacking read_nonblock
|
15
|
-
unless OpenSSL::SSL::SSLSocket.public_method_defined?(:read_nonblock)
|
16
|
-
|
17
|
-
undef_method :read
|
18
|
-
def_delegators(:@socket, :read, :read)
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
# backwards compatability for things lacking write_nonblock
|
23
|
-
unless OpenSSL::SSL::SSLSocket.public_method_defined?(:write_nonblock)
|
24
|
-
|
25
|
-
undef_method :write
|
26
|
-
def_delegators(:@socket, :write, :write)
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
4
|
def initialize(params = {}, proxy = nil)
|
5
|
+
@params, @proxy = params, proxy
|
6
|
+
check_nonblock_support
|
7
|
+
|
31
8
|
super
|
32
9
|
|
33
10
|
# create ssl context
|
@@ -95,5 +72,34 @@ module Excon
|
|
95
72
|
@socket
|
96
73
|
end
|
97
74
|
|
75
|
+
def connect
|
76
|
+
check_nonblock_support
|
77
|
+
super
|
78
|
+
end
|
79
|
+
|
80
|
+
def read(max_length=nil)
|
81
|
+
check_nonblock_support
|
82
|
+
super
|
83
|
+
end
|
84
|
+
|
85
|
+
def write(data)
|
86
|
+
check_nonblock_support
|
87
|
+
super
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def check_nonblock_support
|
93
|
+
# backwards compatability for things lacking nonblock
|
94
|
+
unless OpenSSL::SSL::SSLSocket.public_method_defined?(:connect_nonblock) &&
|
95
|
+
OpenSSL::SSL::SSLSocket.public_method_defined?(:read_nonblock) &&
|
96
|
+
OpenSSL::SSL::SSLSocket.public_method_defined?(:write_nonblock)
|
97
|
+
unless params[:nonblock] == false
|
98
|
+
puts("Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket")
|
99
|
+
params[:nonblock] = false
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
98
104
|
end
|
99
105
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
with_rackup('basic_auth.ru') do
|
2
|
+
Shindo.tests('Excon basics (Authorization data redacted)') do
|
3
|
+
cases = [
|
4
|
+
['user & pass', 'http://user1:pass1@foo.com/', 'Basic dXNlcjE6cGFzczE='],
|
5
|
+
['user no pass', 'http://three_user@foo.com/', 'Basic dGhyZWVfdXNlcjo='],
|
6
|
+
['pass no user', 'http://:derppass@foo.com/', 'Basic OmRlcnBwYXNz']
|
7
|
+
]
|
8
|
+
cases.each do |desc,url,auth_header|
|
9
|
+
conn = Excon.new(url)
|
10
|
+
test("authorization header concealed for #{desc}") do
|
11
|
+
! conn.inspect.to_s.include? auth_header
|
12
|
+
end
|
13
|
+
|
14
|
+
tests("authorization header correct for #{desc}").returns(auth_header) do
|
15
|
+
conn.connection[:headers]['Authorization']
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
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.2
|
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-08-
|
14
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
18
|
-
requirement: &
|
18
|
+
requirement: &70244964150240 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70244964150240
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: delorean
|
29
|
-
requirement: &
|
29
|
+
requirement: &70244964163380 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70244964163380
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: open4
|
40
|
-
requirement: &
|
40
|
+
requirement: &70244964162220 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70244964162220
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &70244964160980 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70244964160980
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rdoc
|
62
|
-
requirement: &
|
62
|
+
requirement: &70244964159980 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70244964159980
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: shindo
|
73
|
-
requirement: &
|
73
|
+
requirement: &70244964159080 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *70244964159080
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: sinatra
|
84
|
-
requirement: &
|
84
|
+
requirement: &70244964157680 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ! '>='
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *70244964157680
|
93
93
|
description: EXtended http(s) CONnections
|
94
94
|
email: geemus@gmail.com
|
95
95
|
executables: []
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/excon/socket.rb
|
130
130
|
- lib/excon/ssl_socket.rb
|
131
131
|
- lib/excon/standard_instrumentor.rb
|
132
|
+
- tests/authorization_header_tests.rb
|
132
133
|
- tests/bad_tests.rb
|
133
134
|
- tests/basic_tests.rb
|
134
135
|
- tests/data/xs
|
@@ -168,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
169
|
version: '0'
|
169
170
|
segments:
|
170
171
|
- 0
|
171
|
-
hash:
|
172
|
+
hash: -3145610774015695237
|
172
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
174
|
none: false
|
174
175
|
requirements:
|