excon 0.15.4 → 0.15.5

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/README.md CHANGED
@@ -199,7 +199,7 @@ If you don't want to add activesupport to your application, simply define a clas
199
199
 
200
200
  The #instrument method will be called for each HTTP request, response, retry, and error.
201
201
 
202
- For debugging purposes you can also use Excon::StandardInstrumentor to output all events to stderr. This can also be specified by setting the `EXCON_STANDARD_INSTRUMENTOR` ENV var.
202
+ For debugging purposes you can also use Excon::StandardInstrumentor to output all events to stderr. This can also be specified by setting the `EXCON_DEBUG` ENV var.
203
203
 
204
204
  See [the documentation for ActiveSupport::Notifications](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html) for more detail on using the subscription interface. See excon's instrumentation_test.rb for more examples of instrumenting excon.
205
205
 
@@ -1,3 +1,17 @@
1
+ 0.15.5 08/01/2012
2
+ =================
3
+
4
+ consolidate proxy handling
5
+ proxy settings should pull from connection instead of params (allows
6
+ Excon.defaults[:proxy])
7
+ properly raise connect timeout errors
8
+ change recommended standard instrumentor ENV to EXCON_DEBUG
9
+ remove readline nonblock protections (they didn't fix the windows issue)
10
+ don't swallow non-nonblock SSL exceptions
11
+ consistency fixes for ssl nonblock error handling
12
+ do SNI in ssl_socket setup
13
+ use Excon::Response#parse to read https proxy response
14
+
1
15
  0.15.4 07/16/12
2
16
  ===============
3
17
 
@@ -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.4'
17
- s.date = '2012-07-18'
16
+ s.version = '0.15.5'
17
+ s.date = '2012-08-01'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -30,16 +30,12 @@ module Excon
30
30
 
31
31
  @proxy = nil
32
32
 
33
- # use proxy from the environment if present
34
- if (ENV.has_key?('http_proxy') || ENV.has_key?('HTTP_PROXY'))
35
- @proxy = setup_proxy(ENV['http_proxy'] || ENV['HTTP_PROXY'])
36
- elsif params.has_key?(:proxy)
37
- @proxy = setup_proxy(params[:proxy])
38
- end
39
-
40
- # use https_proxy if that has been specified
41
33
  if @connection[:scheme] == HTTPS && (ENV.has_key?('https_proxy') || ENV.has_key?('HTTPS_PROXY'))
42
34
  @proxy = setup_proxy(ENV['https_proxy'] || ENV['HTTPS_PROXY'])
35
+ elsif (ENV.has_key?('http_proxy') || ENV.has_key?('HTTP_PROXY'))
36
+ @proxy = setup_proxy(ENV['http_proxy'] || ENV['HTTP_PROXY'])
37
+ elsif @connection.has_key?(:proxy)
38
+ @proxy = setup_proxy(@connection[:proxy])
43
39
  end
44
40
 
45
41
  if @proxy
@@ -51,7 +47,7 @@ module Excon
51
47
  end
52
48
  end
53
49
 
54
- if ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR')
50
+ if ENV.has_key?('EXCON_DEBUG') || ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR')
55
51
  @connection[:instrumentor] = Excon::StandardInstrumentor
56
52
  end
57
53
 
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
  unless const_defined?(:VERSION)
3
- VERSION = '0.15.4'
3
+ VERSION = '0.15.5'
4
4
  end
5
5
 
6
6
  unless const_defined?(:CHUNK_SIZE)
@@ -33,17 +33,14 @@ module Excon
33
33
 
34
34
  socket = ::Socket.new(a_family, s_type, 0)
35
35
 
36
- #secs = Integer(timeout)
37
- #usecs = Integer((timeout - secs) * 1_000_000)
38
- #optval = [secs, usecs].pack("l_2")
39
- #sock.setsockopt Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, optval
40
-
41
36
  socket.connect_nonblock(sockaddr)
42
37
 
43
38
  @socket = socket
44
39
  break
45
40
  rescue Errno::EINPROGRESS
46
- IO.select(nil, [socket], nil, @params[:connect_timeout])
41
+ unless IO.select(nil, [socket], nil, @params[:connect_timeout])
42
+ raise(Excon::Errors::Timeout.new("connect timeout reached"))
43
+ end
47
44
  begin
48
45
  socket.connect_nonblock(sockaddr)
49
46
 
@@ -88,6 +85,8 @@ module Excon
88
85
  else
89
86
  raise(Excon::Errors::Timeout.new("read timeout reached"))
90
87
  end
88
+ else
89
+ raise(error)
91
90
  end
92
91
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
93
92
  if IO.select([@socket], nil, nil, @params[:read_timeout])
@@ -106,31 +105,6 @@ module Excon
106
105
  end
107
106
  end
108
107
 
109
- def readline
110
- return nil if @eof
111
-
112
- begin
113
- @socket.readline
114
- rescue OpenSSL::SSL::SSLError => error
115
- if error.message == 'read would block'
116
- if IO.select([@socket], nil, nil, @params[:read_timeout])
117
- retry
118
- else
119
- raise(Excon::Errors::Timeout.new("read timeout reached"))
120
- end
121
- end
122
- rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
123
- if IO.select([@socket], nil, nil, @params[:read_timeout])
124
- retry
125
- else
126
- raise(Excon::Errors::Timeout.new("read timeout reached"))
127
- end
128
- rescue EOFError
129
- @eof = true
130
- nil
131
- end
132
- end
133
-
134
108
  def write(data)
135
109
  # We normally return from the return in the else block below, but
136
110
  # we guard that data is still something in case we get weird
@@ -148,11 +122,9 @@ module Excon
148
122
  else
149
123
  raise(Excon::Errors::Timeout.new("write timeout reached"))
150
124
  end
125
+ else
126
+ raise(error)
151
127
  end
152
-
153
- # If there is an unknown OpenSSL error, don't just swallow
154
- # it, raise it out.
155
- raise Excon::Errors::SocketError.new(error)
156
128
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable
157
129
  if IO.select(nil, [@socket], nil, @params[:write_timeout])
158
130
  retry
@@ -75,14 +75,17 @@ module Excon
75
75
  @socket.write(request)
76
76
 
77
77
  # eat the proxy's connection response
78
- while line = @socket.readline.strip
79
- break if line.empty?
80
- end
78
+ Excon::Response.parse(@socket, {})
81
79
  end
82
80
 
83
81
  # connect the new OpenSSL::SSL::SSLSocket
84
82
  @socket.connect
85
83
 
84
+ # Server Name Indication (SNI) RFC 3546
85
+ if @socket.respond_to?(:hostname=)
86
+ @socket.hostname = @params[:host]
87
+ end
88
+
86
89
  # verify connection
87
90
  if params[:ssl_verify_peer]
88
91
  @socket.post_connection_check(@params[:host])
@@ -2,7 +2,7 @@ require 'sinatra'
2
2
 
3
3
  class App < Sinatra::Base
4
4
  get('/timeout') do
5
- sleep(1)
5
+ sleep(2)
6
6
  end
7
7
  end
8
8
 
@@ -3,7 +3,7 @@ with_rackup('timeout.ru') do
3
3
  connection = Excon.new('http://127.0.0.1:9292')
4
4
 
5
5
  tests('hits read_timeout').raises(Excon::Errors::Timeout) do
6
- connection.request(:method => :get, :path => '/timeout', :read_timeout => 0)
6
+ connection.request(:method => :get, :path => '/timeout', :read_timeout => 1)
7
7
  end
8
8
 
9
9
  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
4
+ version: 0.15.5
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-18 00:00:00.000000000 Z
14
+ date: 2012-08-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70201249148480 !ruby/object:Gem::Requirement
18
+ requirement: &70157967898360 !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: *70201249148480
26
+ version_requirements: *70157967898360
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: delorean
29
- requirement: &70201249147600 !ruby/object:Gem::Requirement
29
+ requirement: &70157967894540 !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: *70201249147600
37
+ version_requirements: *70157967894540
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: open4
40
- requirement: &70201249145740 !ruby/object:Gem::Requirement
40
+ requirement: &70157967906920 !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: *70201249145740
48
+ version_requirements: *70157967906920
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
- requirement: &70201249137360 !ruby/object:Gem::Requirement
51
+ requirement: &70157967905100 !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: *70201249137360
59
+ version_requirements: *70157967905100
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rdoc
62
- requirement: &70201249128100 !ruby/object:Gem::Requirement
62
+ requirement: &70157967902880 !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: *70201249128100
70
+ version_requirements: *70157967902880
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: shindo
73
- requirement: &70201249123000 !ruby/object:Gem::Requirement
73
+ requirement: &70157967902120 !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: *70201249123000
81
+ version_requirements: *70157967902120
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sinatra
84
- requirement: &70201249117960 !ruby/object:Gem::Requirement
84
+ requirement: &70157967917600 !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: *70201249117960
92
+ version_requirements: *70157967917600
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: -3281686677193752386
171
+ hash: 3311072793664556069
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements: