excon 0.29.0 → 0.30.0

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/Gemfile CHANGED
@@ -3,7 +3,8 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'jruby-openssl', :platform => :jruby
6
- gem 'unicorn', :platform => :mri
6
+ gem 'unicorn', :platforms => [:mri, :rbx]
7
+ gem 'rubysl', '~> 2.0', :platform => :rbx
7
8
 
8
9
  # group :benchmark do
9
10
  # gem 'em-http-request'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- excon (0.29.0)
4
+ excon (0.30.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -15,6 +15,7 @@ GEM
15
15
  chronic
16
16
  eventmachine (1.0.0)
17
17
  eventmachine (1.0.0-java)
18
+ ffi2-generators (0.1.1)
18
19
  formatador (0.2.3)
19
20
  i18n (0.6.0)
20
21
  jruby-openssl (0.8.8)
@@ -22,6 +23,7 @@ GEM
22
23
  json (1.7.3)
23
24
  json (1.7.3-java)
24
25
  kgio (2.8.0)
26
+ minitest (4.7.5)
25
27
  multi_json (1.3.6)
26
28
  open4 (1.3.0)
27
29
  rack (1.4.1)
@@ -31,6 +33,211 @@ GEM
31
33
  rake (0.9.2.2)
32
34
  rdoc (3.12)
33
35
  json (~> 1.4)
36
+ rubysl (2.0.14)
37
+ rubysl-abbrev (~> 2.0)
38
+ rubysl-base64 (~> 2.0)
39
+ rubysl-benchmark (~> 2.0)
40
+ rubysl-bigdecimal (~> 2.0)
41
+ rubysl-cgi (~> 2.0)
42
+ rubysl-cgi-session (~> 2.0)
43
+ rubysl-cmath (~> 2.0)
44
+ rubysl-complex (~> 2.0)
45
+ rubysl-continuation (~> 2.0)
46
+ rubysl-coverage (~> 2.0)
47
+ rubysl-csv (~> 2.0)
48
+ rubysl-curses (~> 2.0)
49
+ rubysl-date (~> 2.0)
50
+ rubysl-delegate (~> 2.0)
51
+ rubysl-digest (~> 2.0)
52
+ rubysl-drb (~> 2.0)
53
+ rubysl-e2mmap (~> 2.0)
54
+ rubysl-english (~> 2.0)
55
+ rubysl-enumerator (~> 2.0)
56
+ rubysl-erb (~> 2.0)
57
+ rubysl-etc (~> 2.0)
58
+ rubysl-expect (~> 2.0)
59
+ rubysl-fcntl (~> 2.0)
60
+ rubysl-fiber (~> 2.0)
61
+ rubysl-fileutils (~> 2.0)
62
+ rubysl-find (~> 2.0)
63
+ rubysl-forwardable (~> 2.0)
64
+ rubysl-getoptlong (~> 2.0)
65
+ rubysl-gserver (~> 2.0)
66
+ rubysl-io-console (~> 2.0)
67
+ rubysl-io-nonblock (~> 2.0)
68
+ rubysl-io-wait (~> 2.0)
69
+ rubysl-ipaddr (~> 2.0)
70
+ rubysl-irb (~> 2.0)
71
+ rubysl-logger (~> 2.0)
72
+ rubysl-mathn (~> 2.0)
73
+ rubysl-matrix (~> 2.0)
74
+ rubysl-mkmf (~> 2.0)
75
+ rubysl-monitor (~> 2.0)
76
+ rubysl-mutex_m (~> 2.0)
77
+ rubysl-net-ftp (~> 2.0)
78
+ rubysl-net-http (~> 2.0)
79
+ rubysl-net-imap (~> 2.0)
80
+ rubysl-net-pop (~> 2.0)
81
+ rubysl-net-protocol (~> 2.0)
82
+ rubysl-net-smtp (~> 2.0)
83
+ rubysl-net-telnet (~> 2.0)
84
+ rubysl-nkf (~> 2.0)
85
+ rubysl-observer (~> 2.0)
86
+ rubysl-open-uri (~> 2.0)
87
+ rubysl-open3 (~> 2.0)
88
+ rubysl-openssl (~> 2.0)
89
+ rubysl-optparse (~> 2.0)
90
+ rubysl-ostruct (~> 2.0)
91
+ rubysl-pathname (~> 2.0)
92
+ rubysl-prettyprint (~> 2.0)
93
+ rubysl-prime (~> 2.0)
94
+ rubysl-profile (~> 2.0)
95
+ rubysl-profiler (~> 2.0)
96
+ rubysl-pstore (~> 2.0)
97
+ rubysl-pty (~> 2.0)
98
+ rubysl-rational (~> 2.0)
99
+ rubysl-readline (~> 2.0)
100
+ rubysl-resolv (~> 2.0)
101
+ rubysl-rexml (~> 2.0)
102
+ rubysl-rinda (~> 2.0)
103
+ rubysl-rss (~> 2.0)
104
+ rubysl-scanf (~> 2.0)
105
+ rubysl-securerandom (~> 2.0)
106
+ rubysl-set (~> 2.0)
107
+ rubysl-shellwords (~> 2.0)
108
+ rubysl-singleton (~> 2.0)
109
+ rubysl-socket (~> 2.0)
110
+ rubysl-stringio (~> 2.0)
111
+ rubysl-strscan (~> 2.0)
112
+ rubysl-sync (~> 2.0)
113
+ rubysl-syslog (~> 2.0)
114
+ rubysl-tempfile (~> 2.0)
115
+ rubysl-test-unit (~> 2.0)
116
+ rubysl-thread (~> 2.0)
117
+ rubysl-thwait (~> 2.0)
118
+ rubysl-time (~> 2.0)
119
+ rubysl-timeout (~> 2.0)
120
+ rubysl-tmpdir (~> 2.0)
121
+ rubysl-tsort (~> 2.0)
122
+ rubysl-un (~> 2.0)
123
+ rubysl-uri (~> 2.0)
124
+ rubysl-weakref (~> 2.0)
125
+ rubysl-webrick (~> 2.0)
126
+ rubysl-xmlrpc (~> 2.0)
127
+ rubysl-yaml (~> 2.0)
128
+ rubysl-zlib (~> 2.0)
129
+ rubysl-abbrev (2.0.4)
130
+ rubysl-base64 (2.0.0)
131
+ rubysl-benchmark (2.0.1)
132
+ rubysl-bigdecimal (2.0.2)
133
+ rubysl-cgi (2.0.1)
134
+ rubysl-cgi-session (2.0.1)
135
+ rubysl-cmath (2.0.0)
136
+ rubysl-complex (2.0.0)
137
+ rubysl-continuation (2.0.0)
138
+ rubysl-coverage (2.0.3)
139
+ rubysl-csv (2.0.2)
140
+ rubysl-english (~> 2.0)
141
+ rubysl-curses (2.0.0)
142
+ rubysl-date (2.0.6)
143
+ rubysl-delegate (2.0.1)
144
+ rubysl-digest (2.0.3)
145
+ rubysl-drb (2.0.1)
146
+ rubysl-e2mmap (2.0.0)
147
+ rubysl-english (2.0.0)
148
+ rubysl-enumerator (2.0.0)
149
+ rubysl-erb (2.0.1)
150
+ rubysl-etc (2.0.3)
151
+ ffi2-generators (~> 0.1)
152
+ rubysl-expect (2.0.0)
153
+ rubysl-fcntl (2.0.4)
154
+ ffi2-generators (~> 0.1)
155
+ rubysl-fiber (2.0.0)
156
+ rubysl-fileutils (2.0.3)
157
+ rubysl-find (2.0.1)
158
+ rubysl-forwardable (2.0.1)
159
+ rubysl-getoptlong (2.0.0)
160
+ rubysl-gserver (2.0.0)
161
+ rubysl-socket (~> 2.0)
162
+ rubysl-thread (~> 2.0)
163
+ rubysl-io-console (2.0.0)
164
+ rubysl-io-nonblock (2.0.0)
165
+ rubysl-io-wait (2.0.0)
166
+ rubysl-ipaddr (2.0.0)
167
+ rubysl-irb (2.0.4)
168
+ rubysl-e2mmap (~> 2.0)
169
+ rubysl-mathn (~> 2.0)
170
+ rubysl-readline (~> 2.0)
171
+ rubysl-thread (~> 2.0)
172
+ rubysl-logger (2.0.0)
173
+ rubysl-mathn (2.0.0)
174
+ rubysl-matrix (2.1.0)
175
+ rubysl-e2mmap (~> 2.0)
176
+ rubysl-mkmf (2.0.1)
177
+ rubysl-fileutils (~> 2.0)
178
+ rubysl-shellwords (~> 2.0)
179
+ rubysl-monitor (2.0.0)
180
+ rubysl-mutex_m (2.0.0)
181
+ rubysl-net-ftp (2.0.1)
182
+ rubysl-net-http (2.0.4)
183
+ rubysl-cgi (~> 2.0)
184
+ rubysl-erb (~> 2.0)
185
+ rubysl-singleton (~> 2.0)
186
+ rubysl-net-imap (2.0.1)
187
+ rubysl-net-pop (2.0.1)
188
+ rubysl-net-protocol (2.0.1)
189
+ rubysl-net-smtp (2.0.1)
190
+ rubysl-net-telnet (2.0.0)
191
+ rubysl-nkf (2.0.1)
192
+ rubysl-observer (2.0.0)
193
+ rubysl-open-uri (2.0.0)
194
+ rubysl-open3 (2.0.0)
195
+ rubysl-openssl (2.0.4)
196
+ rubysl-optparse (2.0.1)
197
+ rubysl-shellwords (~> 2.0)
198
+ rubysl-ostruct (2.0.4)
199
+ rubysl-pathname (2.0.0)
200
+ rubysl-prettyprint (2.0.2)
201
+ rubysl-prime (2.0.0)
202
+ rubysl-profile (2.0.0)
203
+ rubysl-profiler (2.0.1)
204
+ rubysl-pstore (2.0.0)
205
+ rubysl-pty (2.0.2)
206
+ rubysl-rational (2.0.1)
207
+ rubysl-readline (2.0.2)
208
+ rubysl-resolv (2.0.0)
209
+ rubysl-rexml (2.0.2)
210
+ rubysl-rinda (2.0.0)
211
+ rubysl-rss (2.0.0)
212
+ rubysl-scanf (2.0.0)
213
+ rubysl-securerandom (2.0.0)
214
+ rubysl-set (2.0.1)
215
+ rubysl-shellwords (2.0.0)
216
+ rubysl-singleton (2.0.0)
217
+ rubysl-socket (2.0.1)
218
+ rubysl-stringio (2.0.0)
219
+ rubysl-strscan (2.0.0)
220
+ rubysl-sync (2.0.0)
221
+ rubysl-syslog (2.0.1)
222
+ ffi2-generators (~> 0.1)
223
+ rubysl-tempfile (2.0.1)
224
+ rubysl-test-unit (2.0.1)
225
+ minitest (~> 4.7)
226
+ rubysl-thread (2.0.2)
227
+ rubysl-thwait (2.0.0)
228
+ rubysl-time (2.0.3)
229
+ rubysl-timeout (2.0.0)
230
+ rubysl-tmpdir (2.0.0)
231
+ rubysl-tsort (2.0.1)
232
+ rubysl-un (2.0.0)
233
+ rubysl-fileutils (~> 2.0)
234
+ rubysl-optparse (~> 2.0)
235
+ rubysl-uri (2.0.0)
236
+ rubysl-weakref (2.0.0)
237
+ rubysl-webrick (2.0.0)
238
+ rubysl-xmlrpc (2.0.0)
239
+ rubysl-yaml (2.0.3)
240
+ rubysl-zlib (2.0.1)
34
241
  shindo (0.3.4)
35
242
  formatador (>= 0.1.1)
36
243
  sinatra (1.3.2)
@@ -56,6 +263,7 @@ DEPENDENCIES
56
263
  open4
57
264
  rake
58
265
  rdoc
266
+ rubysl (~> 2.0)
59
267
  shindo
60
268
  sinatra
61
269
  unicorn
data/changelog.txt CHANGED
@@ -1,3 +1,28 @@
1
+ 0.30.0 11/25/2013
2
+ =================
3
+
4
+ ensure schema/host/port are passed to redirect follower with relative location
5
+ add .ruby-version and .ruby-gemset to .gitignore
6
+ pass nil to :response_block for unknown values
7
+ use :response_block if expects middleware is not used
8
+ refactor Response.parse, add tests
9
+ support header continuations
10
+ support chunked trailers
11
+ improve decompress middleware/tests
12
+ add accept-encoding in decompress middleware requests, if missing
13
+ fixes for connection close detection
14
+ support transfer encoding
15
+ fix deprecated URI.decode usage
16
+ do not try to use tcp_nodelay for unix sockets
17
+ nonblocking connect, connect timeouts for unix sockets
18
+ ignore IO#close exceptions
19
+ move conditional nonblock to only SSLSocket
20
+ skip reverse lookups
21
+ avoid mutating canned response from middleware
22
+ test against latest rubinius, no longer allow failures
23
+ add unicorn as rubinius dev dependency
24
+ use webbrick form decode
25
+
1
26
  0.29.0 11/07/2013
2
27
  =================
3
28
 
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.29.0'
17
- s.date = '2013-11-07'
16
+ s.version = '0.30.0'
17
+ s.date = '2013-11-25'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -119,6 +119,7 @@ Gem::Specification.new do |s|
119
119
  tests/data/xs
120
120
  tests/errors_tests.rb
121
121
  tests/header_tests.rb
122
+ tests/middlewares/canned_response_tests.rb
122
123
  tests/middlewares/decompress_tests.rb
123
124
  tests/middlewares/idempotent_tests.rb
124
125
  tests/middlewares/instrumentation_tests.rb
@@ -142,9 +143,11 @@ Gem::Specification.new do |s|
142
143
  tests/request_headers_tests.rb
143
144
  tests/request_method_tests.rb
144
145
  tests/requests_tests.rb
146
+ tests/response_tests.rb
145
147
  tests/servers/bad.rb
146
148
  tests/servers/eof.rb
147
149
  tests/servers/error.rb
150
+ tests/servers/good.rb
148
151
  tests/test_helper.rb
149
152
  tests/thread_safety_tests.rb
150
153
  tests/timeout_tests.rb
data/lib/excon.rb CHANGED
@@ -10,6 +10,9 @@ require 'timeout'
10
10
  require 'uri'
11
11
  require 'zlib'
12
12
  require 'stringio'
13
+ require 'webrick/httputils'
14
+
15
+ BasicSocket.do_not_reverse_lookup = true
13
16
 
14
17
  # Define defaults first so they will be available to other files
15
18
  module Excon
@@ -36,7 +39,7 @@ module Excon
36
39
  Excon::Middleware::Mock
37
40
  ],
38
41
  :mock => false,
39
- :nonblock => DEFAULT_NONBLOCK,
42
+ :nonblock => true,
40
43
  :omit_default_port => false,
41
44
  :read_timeout => 60,
42
45
  :retry_limit => DEFAULT_RETRY_LIMIT,
@@ -139,8 +142,8 @@ module Excon
139
142
  :port => uri.port,
140
143
  :query => uri.query,
141
144
  :scheme => uri.scheme,
142
- :user => (URI.decode(uri.user) if uri.user),
143
- :password => (URI.decode(uri.password) if uri.password),
145
+ :user => (Utils.unescape_uri(uri.user) if uri.user),
146
+ :password => (Utils.unescape_uri(uri.password) if uri.password)
144
147
  }.merge!(params)
145
148
  Excon::Connection.new(params)
146
149
  end
@@ -75,7 +75,7 @@ module Excon
75
75
  @data[:headers]['Proxy-Connection'] ||= 'Keep-Alive'
76
76
  # https credentials happen in handshake
77
77
  if @data[:scheme] == 'http' && (@data[:proxy][:user] || @data[:proxy][:password])
78
- user, pass = URI.decode_www_form_component(@data[:proxy][:user].to_s), URI.decode_www_form_component(@data[:proxy][:password].to_s)
78
+ user, pass = Utils.unescape_form(@data[:proxy][:user].to_s), Utils.unescape_form(@data[:proxy][:password].to_s)
79
79
  auth = ['' << user.to_s << ':' << pass.to_s].pack('m').delete(Excon::CR_NL)
80
80
  @data[:headers]['Proxy-Authorization'] = 'Basic ' << auth
81
81
  end
@@ -87,7 +87,7 @@ module Excon
87
87
 
88
88
  # Use Basic Auth if url contains a login
89
89
  if @data[:user] || @data[:password]
90
- user, pass = URI.decode_www_form_component(@data[:user].to_s), URI.decode_www_form_component(@data[:password].to_s)
90
+ user, pass = Utils.unescape_form(@data[:user].to_s), Utils.unescape_form(@data[:password].to_s)
91
91
  @data[:headers]['Authorization'] ||= 'Basic ' << ['' << user.to_s << ':' << pass.to_s].pack('m').delete(Excon::CR_NL)
92
92
  end
93
93
 
@@ -147,6 +147,13 @@ module Excon
147
147
  end
148
148
  end
149
149
 
150
+ if datum[:response_block]
151
+ datum[:headers]['TE'] = 'trailers'
152
+ else
153
+ datum[:headers]['TE'] = 'trailers, deflate, gzip'
154
+ end
155
+ datum[:headers]['Connection'] = 'TE'
156
+
150
157
  # add headers to request
151
158
  datum[:headers].each do |key, values|
152
159
  [values].flatten.each do |value|
@@ -197,9 +204,10 @@ module Excon
197
204
 
198
205
  def response_call(datum)
199
206
  if datum.has_key?(:response_block) && !datum[:response][:body].empty?
200
- content_length = remaining = datum[:response][:body].bytesize
207
+ response_body = datum[:response][:body].dup
208
+ content_length = remaining = response_body.bytesize
201
209
  while remaining > 0
202
- datum[:response_block].call(datum[:response][:body].slice!(0, [datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
210
+ datum[:response_block].call(response_body.slice!(0, [datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
203
211
  remaining -= datum[:chunk_size]
204
212
  end
205
213
  end
@@ -259,8 +267,10 @@ module Excon
259
267
  unless datum[:pipeline]
260
268
  datum = response(datum)
261
269
 
262
- if datum[:response][:headers]['Connection'] == 'close'
263
- reset
270
+ if key = datum[:response][:headers].keys.detect {|k| k.casecmp('Connection') == 0 }
271
+ if split_header_value(datum[:response][:headers][key]).any? {|t| t.casecmp('close') }
272
+ reset
273
+ end
264
274
  end
265
275
 
266
276
  Excon::Response.new(datum[:response])
@@ -286,15 +296,19 @@ module Excon
286
296
  Excon::Response.new(response(datum)[:response])
287
297
  end
288
298
 
289
- if responses.last[:headers]['Connection'] == 'close'
290
- reset
299
+ if key = responses.last[:headers].keys.detect {|k| k.casecmp('Connection') == 0 }
300
+ if split_header_value(responses.last[:headers][key]).any? {|t| t.casecmp('close') }
301
+ reset
302
+ end
291
303
  end
292
304
 
293
305
  responses
294
306
  end
295
307
 
296
308
  def reset
297
- (old_socket = sockets.delete(@socket_key)) && old_socket.close
309
+ if old_socket = sockets.delete(@socket_key)
310
+ old_socket.close rescue nil
311
+ end
298
312
  end
299
313
 
300
314
  # Generate HTTP request verb methods
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
 
3
- VERSION = '0.29.0'
3
+ VERSION = '0.30.0'
4
4
 
5
5
  CR_NL = "\r\n"
6
6
 
@@ -13,10 +13,6 @@ module Excon
13
13
  CHUNK_SIZE = DEFAULT_CHUNK_SIZE
14
14
  end
15
15
 
16
- DEFAULT_NONBLOCK = OpenSSL::SSL::SSLSocket.public_method_defined?(:connect_nonblock) &&
17
- OpenSSL::SSL::SSLSocket.public_method_defined?(:read_nonblock) &&
18
- OpenSSL::SSL::SSLSocket.public_method_defined?(:write_nonblock)
19
-
20
16
  DEFAULT_RETRY_LIMIT = 4
21
17
 
22
18
  FORCE_ENC = CR_NL.respond_to?(:force_encoding)
data/lib/excon/errors.rb CHANGED
@@ -20,6 +20,8 @@ module Excon
20
20
 
21
21
  class Timeout < Error; end
22
22
 
23
+ class ResponseParseError < Error; end
24
+
23
25
  class ProxyParseError < Error; end
24
26
 
25
27
  class ProxyConnectionError < Error; end