excon 0.62.0 → 0.79.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.md +1 -1
- data/README.md +5 -4
- data/data/cacert.pem +769 -1496
- data/excon.gemspec +17 -2
- data/lib/excon.rb +25 -17
- data/lib/excon/connection.rb +193 -119
- data/lib/excon/constants.rb +36 -13
- data/lib/excon/error.rb +15 -0
- data/lib/excon/headers.rb +4 -3
- data/lib/excon/instrumentors/logging_instrumentor.rb +4 -15
- data/lib/excon/instrumentors/standard_instrumentor.rb +2 -9
- data/lib/excon/middlewares/base.rb +6 -0
- data/lib/excon/middlewares/capture_cookies.rb +1 -1
- data/lib/excon/middlewares/decompress.rb +2 -2
- data/lib/excon/middlewares/expects.rb +7 -1
- data/lib/excon/middlewares/idempotent.rb +20 -3
- data/lib/excon/middlewares/instrumentor.rb +8 -0
- data/lib/excon/middlewares/mock.rb +12 -3
- data/lib/excon/middlewares/redirect_follower.rb +25 -3
- data/lib/excon/middlewares/response_parser.rb +3 -0
- data/lib/excon/pretty_printer.rb +1 -8
- data/lib/excon/response.rb +12 -9
- data/lib/excon/socket.rb +38 -21
- data/lib/excon/ssl_socket.rb +24 -13
- data/lib/excon/test/plugin/server/exec.rb +2 -2
- data/lib/excon/test/server.rb +1 -1
- data/lib/excon/unix_socket.rb +1 -0
- data/lib/excon/utils.rb +41 -5
- data/lib/excon/version.rb +1 -1
- metadata +27 -98
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -29
- data/Gemfile +0 -19
- data/Rakefile +0 -41
- data/benchmarks/class_vs_lambda.rb +0 -50
- data/benchmarks/concat_vs_insert.rb +0 -21
- data/benchmarks/concat_vs_interpolate.rb +0 -22
- data/benchmarks/cr_lf.rb +0 -21
- data/benchmarks/downcase-eq-eq_vs_casecmp.rb +0 -169
- data/benchmarks/excon.rb +0 -69
- data/benchmarks/excon_vs.rb +0 -165
- data/benchmarks/for_vs_array_each.rb +0 -27
- data/benchmarks/for_vs_hash_each.rb +0 -27
- data/benchmarks/has_key-vs-lookup.rb +0 -177
- data/benchmarks/headers_case_sensitivity.rb +0 -83
- data/benchmarks/headers_split_vs_match.rb +0 -34
- data/benchmarks/implicit_block-vs-explicit_block.rb +0 -98
- data/benchmarks/merging.rb +0 -21
- data/benchmarks/single_vs_double_quotes.rb +0 -21
- data/benchmarks/string_ranged_index.rb +0 -87
- data/benchmarks/strip_newline.rb +0 -115
- data/benchmarks/vs_stdlib.rb +0 -82
- data/changelog.txt +0 -1083
- data/spec/excon/error_spec.rb +0 -139
- data/spec/excon/test/server_spec.rb +0 -28
- data/spec/excon_spec.rb +0 -7
- data/spec/helpers/file_path_helpers.rb +0 -22
- data/spec/requests/basic_spec.rb +0 -40
- data/spec/requests/eof_requests_spec.rb +0 -36
- data/spec/requests/unix_socket_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -24
- data/spec/support/shared_contexts/test_server_context.rb +0 -83
- data/spec/support/shared_examples/shared_example_for_clients.rb +0 -218
- data/spec/support/shared_examples/shared_example_for_streaming_clients.rb +0 -20
- data/spec/support/shared_examples/shared_example_for_test_servers.rb +0 -16
- data/tests/authorization_header_tests.rb +0 -29
- data/tests/bad_tests.rb +0 -47
- data/tests/basic_tests.rb +0 -351
- data/tests/batch_requests.rb +0 -133
- data/tests/complete_responses.rb +0 -31
- data/tests/data/127.0.0.1.cert.crt +0 -20
- data/tests/data/127.0.0.1.cert.key +0 -27
- data/tests/data/excon.cert.crt +0 -20
- data/tests/data/excon.cert.key +0 -27
- data/tests/data/xs +0 -1
- data/tests/error_tests.rb +0 -145
- data/tests/header_tests.rb +0 -119
- data/tests/middlewares/canned_response_tests.rb +0 -34
- data/tests/middlewares/capture_cookies_tests.rb +0 -34
- data/tests/middlewares/decompress_tests.rb +0 -157
- data/tests/middlewares/escape_path_tests.rb +0 -36
- data/tests/middlewares/idempotent_tests.rb +0 -206
- data/tests/middlewares/instrumentation_tests.rb +0 -315
- data/tests/middlewares/mock_tests.rb +0 -304
- data/tests/middlewares/redirect_follower_tests.rb +0 -112
- data/tests/pipeline_tests.rb +0 -40
- data/tests/proxy_tests.rb +0 -306
- data/tests/query_string_tests.rb +0 -87
- data/tests/rackups/basic.rb +0 -41
- data/tests/rackups/basic.ru +0 -3
- data/tests/rackups/basic_auth.ru +0 -14
- data/tests/rackups/deflater.ru +0 -4
- data/tests/rackups/proxy.ru +0 -18
- data/tests/rackups/query_string.ru +0 -13
- data/tests/rackups/redirecting.ru +0 -23
- data/tests/rackups/redirecting_with_cookie.ru +0 -40
- data/tests/rackups/request_headers.ru +0 -15
- data/tests/rackups/request_methods.ru +0 -21
- data/tests/rackups/response_header.ru +0 -18
- data/tests/rackups/ssl.ru +0 -16
- data/tests/rackups/ssl_mismatched_cn.ru +0 -15
- data/tests/rackups/ssl_verify_peer.ru +0 -16
- data/tests/rackups/streaming.ru +0 -30
- data/tests/rackups/thread_safety.ru +0 -17
- data/tests/rackups/timeout.ru +0 -14
- data/tests/rackups/webrick_patch.rb +0 -34
- data/tests/request_headers_tests.rb +0 -21
- data/tests/request_method_tests.rb +0 -47
- data/tests/request_tests.rb +0 -59
- data/tests/response_tests.rb +0 -197
- data/tests/servers/bad.rb +0 -20
- data/tests/servers/eof.rb +0 -17
- data/tests/servers/error.rb +0 -20
- data/tests/servers/good.rb +0 -350
- data/tests/test_helper.rb +0 -306
- data/tests/thread_safety_tests.rb +0 -39
- data/tests/timeout_tests.rb +0 -12
- data/tests/utils_tests.rb +0 -81
data/tests/query_string_tests.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
Shindo.tests('Excon query string variants') do
|
2
|
-
with_rackup('query_string.ru') do
|
3
|
-
connection = Excon.new('http://127.0.0.1:9292')
|
4
|
-
|
5
|
-
tests(":query => {:foo => 'bar'}") do
|
6
|
-
response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar'})
|
7
|
-
query_string = response.body[7..-1] # query string sent
|
8
|
-
|
9
|
-
tests("query string sent").returns('foo=bar') do
|
10
|
-
query_string
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
tests(":query => {:foo => nil}") do
|
15
|
-
response = connection.request(:method => :get, :path => '/query', :query => {:foo => nil})
|
16
|
-
query_string = response.body[7..-1] # query string sent
|
17
|
-
|
18
|
-
tests("query string sent").returns('foo') do
|
19
|
-
query_string
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
tests(":query => {:foo => 'bar', :me => nil}") do
|
24
|
-
response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar', :me => nil})
|
25
|
-
query_string = response.body[7..-1] # query string sent
|
26
|
-
|
27
|
-
test("query string sent includes 'foo=bar'") do
|
28
|
-
query_string.split('&').include?('foo=bar')
|
29
|
-
end
|
30
|
-
|
31
|
-
test("query string sent includes 'me'") do
|
32
|
-
query_string.split('&').include?('me')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
tests(":query => {:foo => 'bar', :me => 'too'}") do
|
37
|
-
response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar', :me => 'too'})
|
38
|
-
query_string = response.body[7..-1] # query string sent
|
39
|
-
|
40
|
-
test("query string sent includes 'foo=bar'") do
|
41
|
-
query_string.split('&').include?('foo=bar')
|
42
|
-
end
|
43
|
-
|
44
|
-
test("query string sent includes 'me=too'") do
|
45
|
-
query_string.split('&').include?('me=too')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# You can use an atom or a string for the hash keys, what is shown here is emulating
|
50
|
-
# the Rails and PHP style of serializing a query array with a square brackets suffix.
|
51
|
-
tests(":query => {'foo[]' => ['bar', 'baz'], :me => 'too'}") do
|
52
|
-
response = connection.request(:method => :get, :path => '/query', :query => {'foo[]' => ['bar', 'baz'], :me => 'too'})
|
53
|
-
query_string = response.body[7..-1] # query string sent
|
54
|
-
|
55
|
-
test("query string sent includes 'foo%5B%5D=bar'") do
|
56
|
-
query_string.split('&').include?('foo%5B%5D=bar')
|
57
|
-
end
|
58
|
-
|
59
|
-
test("query string sent includes 'foo%5B%5D=baz'") do
|
60
|
-
query_string.split('&').include?('foo%5B%5D=baz')
|
61
|
-
end
|
62
|
-
|
63
|
-
test("query string sent includes 'me=too'") do
|
64
|
-
query_string.split('&').include?('me=too')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
tests(":query => {'foo%=#' => 'bar%=#'}") do
|
69
|
-
response = connection.request(:method => :get, :path => '/query', :query => {'foo%=#' => 'bar%=#'})
|
70
|
-
query_string = response.body[7..-1] # query string sent
|
71
|
-
|
72
|
-
tests("query string sent").returns('foo%25%3D%23=bar%25%3D%23') do
|
73
|
-
query_string
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
tests(":query => {'foo%=#' => nil}") do
|
78
|
-
response = connection.request(:method => :get, :path => '/query', :query => {'foo%=#' => nil})
|
79
|
-
query_string = response.body[7..-1] # query string sent
|
80
|
-
|
81
|
-
tests("query string sent").returns('foo%25%3D%23') do
|
82
|
-
query_string
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
data/tests/rackups/basic.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'json'
|
3
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
4
|
-
|
5
|
-
class Basic < Sinatra::Base
|
6
|
-
set :environment, :production
|
7
|
-
enable :dump_errors
|
8
|
-
|
9
|
-
get('/content-length/:value') do |value|
|
10
|
-
headers("Custom" => "Foo: bar")
|
11
|
-
'x' * value.to_i
|
12
|
-
end
|
13
|
-
|
14
|
-
get('/headers') do
|
15
|
-
content_type :json
|
16
|
-
request.env.select{|key, _| key.start_with? 'HTTP_'}.to_json
|
17
|
-
end
|
18
|
-
|
19
|
-
post('/body-sink') do
|
20
|
-
request.body.read.size.to_s
|
21
|
-
end
|
22
|
-
|
23
|
-
post('/echo') do
|
24
|
-
echo
|
25
|
-
end
|
26
|
-
|
27
|
-
put('/echo') do
|
28
|
-
echo
|
29
|
-
end
|
30
|
-
|
31
|
-
get('/echo dirty') do
|
32
|
-
echo
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def echo
|
38
|
-
request.body.read
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/tests/rackups/basic.ru
DELETED
data/tests/rackups/basic_auth.ru
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'basic')
|
2
|
-
|
3
|
-
class BasicAuth < Basic
|
4
|
-
before do
|
5
|
-
auth ||= Rack::Auth::Basic::Request.new(request.env)
|
6
|
-
user, pass = auth.provided? && auth.basic? && auth.credentials
|
7
|
-
unless [user, pass] == ["test_user", "test_password"]
|
8
|
-
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
|
9
|
-
throw(:halt, [401, "Not authorized\n"])
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
run BasicAuth
|
data/tests/rackups/deflater.ru
DELETED
data/tests/rackups/proxy.ru
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
set :environment, :production
|
6
|
-
enable :dump_errors
|
7
|
-
|
8
|
-
get('*') do
|
9
|
-
headers(
|
10
|
-
"Sent-Request-Uri" => request.env['REQUEST_URI'].to_s,
|
11
|
-
"Sent-Host" => request.env['HTTP_HOST'].to_s,
|
12
|
-
"Sent-Proxy-Connection" => request.env['HTTP_PROXY_CONNECTION'].to_s
|
13
|
-
)
|
14
|
-
'proxied content'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
run App
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'json'
|
3
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
4
|
-
|
5
|
-
class App < Sinatra::Base
|
6
|
-
set :environment, :production
|
7
|
-
enable :dump_errors
|
8
|
-
|
9
|
-
post('/first') do
|
10
|
-
redirect "/second"
|
11
|
-
end
|
12
|
-
|
13
|
-
get('/second') do
|
14
|
-
post_body = request.body.read
|
15
|
-
if post_body == "" && request["CONTENT_LENGTH"].nil?
|
16
|
-
"ok"
|
17
|
-
else
|
18
|
-
JSON.pretty_generate(request.env)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
run App
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'sinatra/cookies'
|
3
|
-
require 'json'
|
4
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
5
|
-
|
6
|
-
class App < Sinatra::Base
|
7
|
-
helpers Sinatra::Cookies
|
8
|
-
set :environment, :production
|
9
|
-
enable :dump_errors
|
10
|
-
|
11
|
-
get('/sets_cookie') do
|
12
|
-
cookies[:chocolatechip] = "chunky"
|
13
|
-
redirect "/requires_cookie"
|
14
|
-
end
|
15
|
-
|
16
|
-
get('/requires_cookie') do
|
17
|
-
cookie = cookies[:chocolatechip]
|
18
|
-
unless cookie.nil? || cookie != "chunky"
|
19
|
-
"ok"
|
20
|
-
else
|
21
|
-
JSON.pretty_generate(headers)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
get('/sets_multi_cookie') do
|
26
|
-
cookies[:chocolatechip] = "chunky"
|
27
|
-
cookies[:thinmints] = "minty"
|
28
|
-
redirect "/requires_cookie"
|
29
|
-
end
|
30
|
-
|
31
|
-
get('/requires_cookie') do
|
32
|
-
if cookies[:chocolatechip] == "chunky" && cookies[:thinmints] == "minty"
|
33
|
-
"ok"
|
34
|
-
else
|
35
|
-
JSON.pretty_generate(headers)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
run App
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
set :environment, :production
|
6
|
-
enable :dump_errors
|
7
|
-
|
8
|
-
post '/' do
|
9
|
-
h = ""
|
10
|
-
env.each { |k,v| h << "#{$1.downcase}: #{v}\n" if k =~ /http_(.*)/i }
|
11
|
-
h
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
run App
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
set :environment, :production
|
6
|
-
enable :dump_errors
|
7
|
-
|
8
|
-
get '/' do
|
9
|
-
'GET'
|
10
|
-
end
|
11
|
-
|
12
|
-
post '/' do
|
13
|
-
'POST'
|
14
|
-
end
|
15
|
-
|
16
|
-
delete '/' do
|
17
|
-
'DELETE'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
run App
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
set :environment, :production
|
6
|
-
enable :dump_errors
|
7
|
-
|
8
|
-
get('/foo') do
|
9
|
-
headers(
|
10
|
-
"MixedCase-Header" => 'MixedCase',
|
11
|
-
"UPPERCASE-HEADER" => 'UPPERCASE',
|
12
|
-
"lowercase-header" => 'lowercase'
|
13
|
-
)
|
14
|
-
'primary content'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
run App
|
data/tests/rackups/ssl.ru
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
require 'webrick'
|
3
|
-
require 'webrick/https'
|
4
|
-
|
5
|
-
require File.join(File.dirname(__FILE__), 'basic')
|
6
|
-
|
7
|
-
key_file = File.join(File.dirname(__FILE__), '..', 'data', '127.0.0.1.cert.key')
|
8
|
-
cert_file = File.join(File.dirname(__FILE__), '..', 'data', '127.0.0.1.cert.crt')
|
9
|
-
Rack::Handler::WEBrick.run(Basic, {
|
10
|
-
:Port => 9443,
|
11
|
-
:SSLEnable => true,
|
12
|
-
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read),
|
13
|
-
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read),
|
14
|
-
:SSLCACertificateFile => cert_file,
|
15
|
-
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
|
16
|
-
})
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
require 'webrick'
|
3
|
-
require 'webrick/https'
|
4
|
-
|
5
|
-
require File.join(File.dirname(__FILE__), 'basic')
|
6
|
-
key_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.key')
|
7
|
-
cert_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.crt')
|
8
|
-
Rack::Handler::WEBrick.run(Basic, {
|
9
|
-
:Port => 9443,
|
10
|
-
:SSLEnable => true,
|
11
|
-
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read),
|
12
|
-
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read),
|
13
|
-
:SSLCACertificateFile => cert_file,
|
14
|
-
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
|
15
|
-
})
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
require 'webrick'
|
3
|
-
require 'webrick/https'
|
4
|
-
|
5
|
-
require File.join(File.dirname(__FILE__), 'basic')
|
6
|
-
key_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.key')
|
7
|
-
cert_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.crt')
|
8
|
-
Rack::Handler::WEBrick.run(Basic, {
|
9
|
-
:Port => 8443,
|
10
|
-
:SSLCertName => [["CN", WEBrick::Utils::getservername]],
|
11
|
-
:SSLEnable => true,
|
12
|
-
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read),
|
13
|
-
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read),
|
14
|
-
:SSLCACertificateFile => cert_file,
|
15
|
-
:SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT,
|
16
|
-
})
|
data/tests/rackups/streaming.ru
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
use Rack::ContentType, "text/plain"
|
2
|
-
|
3
|
-
app = lambda do |env|
|
4
|
-
# streamed pieces to be sent
|
5
|
-
pieces = %w{Hello streamy world}
|
6
|
-
|
7
|
-
response_headers = {}
|
8
|
-
|
9
|
-
# set a fixed content length in the header if requested
|
10
|
-
if env['REQUEST_PATH'] == '/streamed/fixed_length'
|
11
|
-
response_headers['Content-Length'] = pieces.join.length.to_s
|
12
|
-
end
|
13
|
-
|
14
|
-
response_headers["rack.hijack"] = lambda do |io|
|
15
|
-
# Write directly to IO of the response
|
16
|
-
begin
|
17
|
-
# return the response in pieces
|
18
|
-
pieces.each do |x|
|
19
|
-
sleep(0.1)
|
20
|
-
io.write(x)
|
21
|
-
io.flush
|
22
|
-
end
|
23
|
-
ensure
|
24
|
-
io.close
|
25
|
-
end
|
26
|
-
end
|
27
|
-
[200, response_headers, nil]
|
28
|
-
end
|
29
|
-
|
30
|
-
run app
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require File.join(File.dirname(__FILE__), 'webrick_patch')
|
3
|
-
|
4
|
-
class App < Sinatra::Base
|
5
|
-
set :environment, :production
|
6
|
-
enable :dump_errors
|
7
|
-
|
8
|
-
get('/id/:id/wait/:wait') do |id, wait|
|
9
|
-
sleep(wait.to_i)
|
10
|
-
id.to_s
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# get everything autoloaded, mainly for rbx
|
15
|
-
App.new
|
16
|
-
|
17
|
-
run App
|
data/tests/rackups/timeout.ru
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# The ruby 2.0 stdlib includes the following changes
|
2
|
-
# to avoid "can't add a new key into hash during iteration" errors.
|
3
|
-
# https://github.com/ruby/ruby/commit/3c491a92f6fbfecc065f7687c51c7d6d52a38883
|
4
|
-
# https://github.com/ruby/ruby/commit/7b18633804c606e8bcccfbb44e7d7b795e777ea6
|
5
|
-
# However, these changes were not backported to the 1.9.x stdlib.
|
6
|
-
# These errors are causing intermittent errors in the tests (frequently in jruby),
|
7
|
-
# so we're applying those changes here. This is loaded by all rackups using WEBrick.
|
8
|
-
if RUBY_VERSION =~ /^1\.9/
|
9
|
-
require 'webrick/utils'
|
10
|
-
module WEBrick
|
11
|
-
module Utils
|
12
|
-
class TimeoutHandler
|
13
|
-
def initialize
|
14
|
-
@timeout_info = Hash.new
|
15
|
-
Thread.start{
|
16
|
-
while true
|
17
|
-
now = Time.now
|
18
|
-
@timeout_info.keys.each{|thread|
|
19
|
-
ary = @timeout_info[thread]
|
20
|
-
next unless ary
|
21
|
-
ary.dup.each{|info|
|
22
|
-
time, exception = *info
|
23
|
-
interrupt(thread, info.object_id, exception) if time < now
|
24
|
-
}
|
25
|
-
}
|
26
|
-
sleep 0.5
|
27
|
-
end
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|