excon 0.14.0 → 0.14.1

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.

@@ -1,3 +1,10 @@
1
+ 0.14.1 07/19/12
2
+ ===============
3
+
4
+ accept port as a separate option
5
+ ensure first read from socket is nonblock (fixes read_timeouts)
6
+ respect upper case env vars
7
+
1
8
  0.14.0 05/31/12
2
9
  ===============
3
10
 
@@ -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.14.0'
17
- s.date = '2012-05-31'
16
+ s.version = '0.14.1'
17
+ s.date = '2012-06-19'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -115,11 +115,13 @@ Gem::Specification.new do |s|
115
115
  tests/rackups/response_header.ru
116
116
  tests/rackups/ssl.ru
117
117
  tests/rackups/thread_safety.ru
118
+ tests/rackups/timeout.ru
118
119
  tests/request_method_tests.rb
119
120
  tests/servers/bad.rb
120
121
  tests/stub_tests.rb
121
122
  tests/test_helper.rb
122
123
  tests/thread_safety_tests.rb
124
+ tests/timeout_tests.rb
123
125
  ]
124
126
  # = MANIFEST =
125
127
 
@@ -31,15 +31,15 @@ module Excon
31
31
  @proxy = nil
32
32
 
33
33
  # use proxy from the environment if present
34
- if ENV.has_key?('http_proxy')
35
- @proxy = setup_proxy(ENV['http_proxy'])
34
+ if (ENV.has_key?('http_proxy') || ENV.has_key?('HTTP_PROXY'))
35
+ @proxy = setup_proxy(ENV['http_proxy'] || ENV['HTTP_PROXY'])
36
36
  elsif params.has_key?(:proxy)
37
37
  @proxy = setup_proxy(params[:proxy])
38
38
  end
39
39
 
40
40
  # use https_proxy if that has been specified
41
- if @connection[:scheme] == HTTPS && ENV.has_key?('https_proxy')
42
- @proxy = setup_proxy(ENV['https_proxy'])
41
+ if @connection[:scheme] == HTTPS && (ENV.has_key?('https_proxy') || ENV.has_key?('HTTPS_PROXY'))
42
+ @proxy = setup_proxy(ENV['https_proxy'] || ENV['HTTPS_PROXY'])
43
43
  end
44
44
 
45
45
  if @proxy
@@ -56,7 +56,7 @@ module Excon
56
56
  @connection[:headers]['Authorization'] ||= "Basic #{auth}"
57
57
  end
58
58
 
59
- @socket_key = '' << @connection[:host] << ':' << @connection[:port]
59
+ @socket_key = '' << @connection[:host] << ':' << @connection[:port].to_s
60
60
  reset
61
61
  end
62
62
 
@@ -258,8 +258,8 @@ module Excon
258
258
 
259
259
  response
260
260
  end
261
- rescue Excon::Errors::StubNotFound => stub_not_found
262
- raise(stub_not_found)
261
+ rescue Excon::Errors::StubNotFound, Excon::Errors::Timeout => error
262
+ raise(error)
263
263
  rescue => socket_error
264
264
  reset
265
265
  raise(Excon::Errors::SocketError.new(socket_error))
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
  unless const_defined?(:VERSION)
3
- VERSION = '0.14.0'
3
+ VERSION = '0.14.1'
4
4
  end
5
5
 
6
6
  unless const_defined?(:CHUNK_SIZE)
@@ -18,7 +18,8 @@ module Excon
18
18
  end
19
19
 
20
20
  def self.parse(socket, params={})
21
- response = new(:status => socket.readline[9, 11].to_i)
21
+ response = new(:status => socket.read(12)[9, 11].to_i)
22
+ socket.readline # read the rest of the status line and CRLF
22
23
 
23
24
  until ((data = socket.readline).chop!).empty?
24
25
  key, value = data.split(/:\s*/, 2)
@@ -33,6 +33,11 @@ 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
+
36
41
  socket.connect_nonblock(sockaddr)
37
42
 
38
43
  @socket = socket
@@ -26,7 +26,7 @@ Shindo.tests('Excon proxy support') do
26
26
  end
27
27
  end
28
28
 
29
- tests('with proxy config from the environment') do
29
+ tests('with lowercase proxy config from the environment') do
30
30
  ENV['http_proxy'] = 'http://myproxy:8080'
31
31
  ENV['https_proxy'] = 'http://mysecureproxy:8081'
32
32
 
@@ -78,6 +78,58 @@ Shindo.tests('Excon proxy support') do
78
78
  ENV.delete('https_proxy')
79
79
  end
80
80
 
81
+ tests('with uppercase proxy config from the environment') do
82
+ ENV['HTTP_PROXY'] = 'http://myproxy:8080'
83
+ ENV['HTTPS_PROXY'] = 'http://mysecureproxy:8081'
84
+
85
+ tests('an http connection') do
86
+ connection = Excon.new('http://foo.com')
87
+
88
+ tests('connection.proxy.host').returns('myproxy') do
89
+ connection.proxy[:host]
90
+ end
91
+
92
+ tests('connection.proxy.port').returns(8080) do
93
+ connection.proxy[:port]
94
+ end
95
+
96
+ tests('connection.proxy.scheme').returns('http') do
97
+ connection.proxy[:scheme]
98
+ end
99
+ end
100
+
101
+ tests('an https connection') do
102
+ connection = Excon.new('https://secret.com')
103
+
104
+ tests('connection.proxy.host').returns('mysecureproxy') do
105
+ connection.proxy[:host]
106
+ end
107
+
108
+ tests('connection.proxy.port').returns(8081) do
109
+ connection.proxy[:port]
110
+ end
111
+
112
+ tests('connection.proxy.scheme').returns('http') do
113
+ connection.proxy[:scheme]
114
+ end
115
+ end
116
+
117
+ tests('http proxy from the environment overrides config') do
118
+ connection = Excon.new('http://foo.com', :proxy => 'http://hard.coded.proxy:6666')
119
+
120
+ tests('connection.proxy.host').returns('myproxy') do
121
+ connection.proxy[:host]
122
+ end
123
+
124
+ tests('connection.proxy.port').returns(8080) do
125
+ connection.proxy[:port]
126
+ end
127
+ end
128
+
129
+ ENV.delete('HTTP_PROXY')
130
+ ENV.delete('HTTPS_PROXY')
131
+ end
132
+
81
133
  tests('with only http_proxy config from the environment') do
82
134
  ENV['http_proxy'] = 'http://myproxy:8080'
83
135
  ENV.delete('https_proxy')
@@ -0,0 +1,9 @@
1
+ require 'sinatra'
2
+
3
+ class App < Sinatra::Base
4
+ get('/timeout') do
5
+ sleep(1)
6
+ end
7
+ end
8
+
9
+ run App
@@ -0,0 +1,10 @@
1
+ with_rackup('timeout.ru') do
2
+ Shindo.tests('read should timeout') do
3
+ connection = Excon.new('http://127.0.0.1:9292')
4
+
5
+ tests('hits read_timeout').raises(Excon::Errors::Timeout) do
6
+ connection.request(:method => :get, :path => '/timeout', :read_timeout => 0)
7
+ end
8
+
9
+ end
10
+ 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.14.0
4
+ version: 0.14.1
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-05-31 00:00:00.000000000 Z
14
+ date: 2012-06-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70191342427280 !ruby/object:Gem::Requirement
18
+ requirement: &70270728323400 !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: *70191342427280
26
+ version_requirements: *70270728323400
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: delorean
29
- requirement: &70191342426160 !ruby/object:Gem::Requirement
29
+ requirement: &70270728322580 !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: *70191342426160
37
+ version_requirements: *70270728322580
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: open4
40
- requirement: &70191342425140 !ruby/object:Gem::Requirement
40
+ requirement: &70270728321900 !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: *70191342425140
48
+ version_requirements: *70270728321900
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
- requirement: &70191342424280 !ruby/object:Gem::Requirement
51
+ requirement: &70270728321100 !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: *70191342424280
59
+ version_requirements: *70270728321100
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rdoc
62
- requirement: &70191342423500 !ruby/object:Gem::Requirement
62
+ requirement: &70270728320640 !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: *70191342423500
70
+ version_requirements: *70270728320640
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: shindo
73
- requirement: &70191342422860 !ruby/object:Gem::Requirement
73
+ requirement: &70270728320160 !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: *70191342422860
81
+ version_requirements: *70270728320160
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sinatra
84
- requirement: &70191342422180 !ruby/object:Gem::Requirement
84
+ requirement: &70270728319720 !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: *70191342422180
92
+ version_requirements: *70270728319720
93
93
  description: EXtended http(s) CONnections
94
94
  email: geemus@gmail.com
95
95
  executables: []
@@ -146,11 +146,13 @@ files:
146
146
  - tests/rackups/response_header.ru
147
147
  - tests/rackups/ssl.ru
148
148
  - tests/rackups/thread_safety.ru
149
+ - tests/rackups/timeout.ru
149
150
  - tests/request_method_tests.rb
150
151
  - tests/servers/bad.rb
151
152
  - tests/stub_tests.rb
152
153
  - tests/test_helper.rb
153
154
  - tests/thread_safety_tests.rb
155
+ - tests/timeout_tests.rb
154
156
  homepage: https://github.com/geemus/excon
155
157
  licenses: []
156
158
  post_install_message:
@@ -166,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
168
  version: '0'
167
169
  segments:
168
170
  - 0
169
- hash: 830619460380179228
171
+ hash: -419476000002150185
170
172
  required_rubygems_version: !ruby/object:Gem::Requirement
171
173
  none: false
172
174
  requirements: