excon 0.15.1 → 0.15.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 +2 -2
- data/lib/excon/connection.rb +6 -1
- data/lib/excon/constants.rb +1 -1
- data/lib/excon/socket.rb +0 -24
- data/lib/excon/ssl_socket.rb +19 -1
- data/tests/proxy_tests.rb +26 -0
- data/tests/rackups/proxy.ru +3 -2
- metadata +17 -17
data/changelog.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.15.2 07/16/12
|
2
|
+
===============
|
3
|
+
|
4
|
+
fix capitalization of EXCON constant in auth stuff
|
5
|
+
properly handle nil user/password values in auth
|
6
|
+
various fixes to proxy and related tests
|
7
|
+
|
8
|
+
0.15.1 07/16/12
|
9
|
+
===============
|
10
|
+
|
11
|
+
fix for sending user/pass to proxy
|
12
|
+
|
1
13
|
0.15.0 07/16/12
|
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.15.
|
17
|
-
s.date = '2012-07-
|
16
|
+
s.version = '0.15.2'
|
17
|
+
s.date = '2012-07-17'
|
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/connection.rb
CHANGED
@@ -44,6 +44,11 @@ module Excon
|
|
44
44
|
|
45
45
|
if @proxy
|
46
46
|
@connection[:headers]['Proxy-Connection'] ||= 'Keep-Alive'
|
47
|
+
# https credentials happen in handshake
|
48
|
+
if @connection[:scheme] == 'http' && (@proxy[:user] || @proxy[:password])
|
49
|
+
auth = ['' << @proxy[:user].to_s << ':' << @proxy[:password].to_s].pack('m').delete(Excon::CR_NL)
|
50
|
+
@connection[:headers]['Proxy-Authorization'] = 'Basic ' << auth << Excon::CR_NL
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
54
|
if ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR')
|
@@ -52,7 +57,7 @@ module Excon
|
|
52
57
|
|
53
58
|
# Use Basic Auth if url contains a login
|
54
59
|
if uri.user || uri.password
|
55
|
-
@connection[:headers]['Authorization'] ||= 'Basic ' << ['' << uri.user << ':' << uri.password].pack('m').delete(
|
60
|
+
@connection[:headers]['Authorization'] ||= 'Basic ' << ['' << uri.user.to_s << ':' << uri.password.to_s].pack('m').delete(Excon::CR_NL)
|
56
61
|
end
|
57
62
|
|
58
63
|
@socket_key = '' << @connection[:host] << ':' << @connection[:port].to_s
|
data/lib/excon/constants.rb
CHANGED
data/lib/excon/socket.rb
CHANGED
@@ -66,30 +66,6 @@ module Excon
|
|
66
66
|
# this will be our last encountered exception
|
67
67
|
raise exception
|
68
68
|
end
|
69
|
-
|
70
|
-
initialize_proxy
|
71
|
-
end
|
72
|
-
|
73
|
-
def initialize_proxy
|
74
|
-
if @proxy
|
75
|
-
request = 'CONNECT ' << @params[:host] << ':' << @params[:port] << Excon::HTTP_1_1
|
76
|
-
request << 'Host: ' << @params[:host] << ':' << @params[:port] << Excon::CR_NL
|
77
|
-
|
78
|
-
if @proxy[:password] || @proxy[:user]
|
79
|
-
auth = ['' << @proxy[:user] << ':' << @proxy[:password]].pack('m').delete(EXCON::CR_NL)
|
80
|
-
request << "Proxy-Authorization: Basic " << auth << Excon::CR_NL
|
81
|
-
end
|
82
|
-
|
83
|
-
request << Excon::CR_NL
|
84
|
-
|
85
|
-
# write out the proxy setup request
|
86
|
-
@socket.write(request)
|
87
|
-
|
88
|
-
# eat the proxy's connection response
|
89
|
-
while line = @socket.readline.strip
|
90
|
-
break if line.empty?
|
91
|
-
end
|
92
|
-
end
|
93
69
|
end
|
94
70
|
|
95
71
|
def read(max_length=nil)
|
data/lib/excon/ssl_socket.rb
CHANGED
@@ -60,7 +60,25 @@ module Excon
|
|
60
60
|
@socket = OpenSSL::SSL::SSLSocket.new(@socket, ssl_context)
|
61
61
|
@socket.sync_close = true
|
62
62
|
|
63
|
-
|
63
|
+
if @proxy
|
64
|
+
request = 'CONNECT ' << @params[:host] << ':' << @params[:port] << Excon::HTTP_1_1
|
65
|
+
request << 'Host: ' << @params[:host] << ':' << @params[:port] << Excon::CR_NL
|
66
|
+
|
67
|
+
if @proxy[:password] || @proxy[:user]
|
68
|
+
auth = ['' << @proxy[:user].to_s << ':' << @proxy[:password].to_s].pack('m').delete(Excon::CR_NL)
|
69
|
+
request << "Proxy-Authorization: Basic " << auth << Excon::CR_NL
|
70
|
+
end
|
71
|
+
|
72
|
+
request << Excon::CR_NL
|
73
|
+
|
74
|
+
# write out the proxy setup request
|
75
|
+
@socket.write(request)
|
76
|
+
|
77
|
+
# eat the proxy's connection response
|
78
|
+
while line = @socket.readline.strip
|
79
|
+
break if line.empty?
|
80
|
+
end
|
81
|
+
end
|
64
82
|
|
65
83
|
# connect the new OpenSSL::SSL::SSLSocket
|
66
84
|
@socket.connect
|
data/tests/proxy_tests.rb
CHANGED
@@ -170,6 +170,32 @@ Shindo.tests('Excon proxy support') do
|
|
170
170
|
response.headers['Sent-Request-Uri']
|
171
171
|
end
|
172
172
|
|
173
|
+
tests('sent Sent-Host header').returns('foo.com:8080') do
|
174
|
+
response.headers['Sent-Host']
|
175
|
+
end
|
176
|
+
|
177
|
+
tests('sent Proxy-Connection header').returns('Keep-Alive') do
|
178
|
+
response.headers['Sent-Proxy-Connection']
|
179
|
+
end
|
180
|
+
|
181
|
+
tests('response.body (proxied content)').returns('proxied content') do
|
182
|
+
response.body
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
tests('http proxying: http://user:pass@foo.com:8080') do
|
187
|
+
connection = Excon.new('http://foo.com:8080', :proxy => 'http://user:pass@127.0.0.1:9292')
|
188
|
+
response = connection.request(:method => :get, :path => '/bar', :query => {:alpha => 'kappa'})
|
189
|
+
|
190
|
+
tests('response.status').returns(200) do
|
191
|
+
response.status
|
192
|
+
end
|
193
|
+
|
194
|
+
# must be absolute form for proxy requests
|
195
|
+
tests('sent Request URI').returns('http://foo.com:8080/bar?alpha=kappa') do
|
196
|
+
response.headers['Sent-Request-Uri']
|
197
|
+
end
|
198
|
+
|
173
199
|
tests('sent Host header').returns('foo.com:8080') do
|
174
200
|
response.headers['Sent-Host']
|
175
201
|
end
|
data/tests/rackups/proxy.ru
CHANGED
@@ -4,8 +4,9 @@ class App < Sinatra::Base
|
|
4
4
|
get('/bar') do
|
5
5
|
headers(
|
6
6
|
"Sent-Request-Uri" => request.env['REQUEST_URI'].to_s,
|
7
|
-
"Sent-Host" => request.env['HTTP_HOST'].to_s,
|
8
|
-
"Sent-Proxy-Connection" => request.env['HTTP_PROXY_CONNECTION'].to_s
|
7
|
+
"Sent-Host" => request.env['HTTP_HOST'] || [request.env['SERVER_NAME'].to_s, request.env['SERVER_PORT']].join(':'),
|
8
|
+
"Sent-Proxy-Connection" => request.env['HTTP_PROXY_CONNECTION'].to_s,
|
9
|
+
"Env" => request.env.inspect
|
9
10
|
)
|
10
11
|
'proxied content'
|
11
12
|
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.15.
|
4
|
+
version: 0.15.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-07-
|
14
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
18
|
-
requirement: &
|
18
|
+
requirement: &70180408821740 !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: *70180408821740
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: delorean
|
29
|
-
requirement: &
|
29
|
+
requirement: &70180408821180 !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: *70180408821180
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: open4
|
40
|
-
requirement: &
|
40
|
+
requirement: &70180408820660 !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: *70180408820660
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &70180408820120 !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: *70180408820120
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rdoc
|
62
|
-
requirement: &
|
62
|
+
requirement: &70180408819600 !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: *70180408819600
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: shindo
|
73
|
-
requirement: &
|
73
|
+
requirement: &70180408819140 !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: *70180408819140
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: sinatra
|
84
|
-
requirement: &
|
84
|
+
requirement: &70180408818620 !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: *70180408818620
|
93
93
|
description: EXtended http(s) CONnections
|
94
94
|
email: geemus@gmail.com
|
95
95
|
executables: []
|
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
segments:
|
170
170
|
- 0
|
171
|
-
hash:
|
171
|
+
hash: -4082820160673762463
|
172
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
173
|
none: false
|
174
174
|
requirements:
|