excon 0.62.0 → 0.92.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +0 -1
- data/LICENSE.md +1 -1
- data/README.md +7 -6
- data/data/cacert.pem +1220 -1828
- data/excon.gemspec +19 -3
- data/lib/excon/connection.rb +216 -139
- data/lib/excon/constants.rb +38 -13
- data/lib/excon/error.rb +15 -0
- data/lib/excon/headers.rb +4 -3
- data/lib/excon/instrumentors/logging_instrumentor.rb +5 -16
- 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 +11 -4
- 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 +59 -42
- data/lib/excon/ssl_socket.rb +37 -15
- data/lib/excon/test/plugin/server/exec.rb +5 -2
- data/lib/excon/test/plugin/server/puma.rb +4 -1
- data/lib/excon/test/plugin/server/unicorn.rb +5 -0
- data/lib/excon/test/plugin/server/webrick.rb +4 -1
- data/lib/excon/test/server.rb +1 -1
- data/lib/excon/unix_socket.rb +1 -0
- data/lib/excon/utils.rb +59 -5
- data/lib/excon/version.rb +1 -1
- data/lib/excon.rb +25 -17
- 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/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
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon request methods') do
|
|
2
|
-
|
|
3
|
-
with_rackup('request_headers.ru') do
|
|
4
|
-
|
|
5
|
-
tests 'empty headers sent' do
|
|
6
|
-
|
|
7
|
-
test('Excon.post') do
|
|
8
|
-
headers = {
|
|
9
|
-
:one => 1,
|
|
10
|
-
:two => nil,
|
|
11
|
-
:three => 3,
|
|
12
|
-
}
|
|
13
|
-
r = Excon.post('http://localhost:9292', :headers => headers).body
|
|
14
|
-
!r.match(/two:/).nil?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon request methods') do
|
|
2
|
-
|
|
3
|
-
with_rackup('request_methods.ru') do
|
|
4
|
-
|
|
5
|
-
tests 'one-offs' do
|
|
6
|
-
|
|
7
|
-
tests('Excon.get').returns('GET') do
|
|
8
|
-
Excon.get('http://localhost:9292').body
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
tests('Excon.post').returns('POST') do
|
|
12
|
-
Excon.post('http://localhost:9292').body
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
tests('Excon.delete').returns('DELETE') do
|
|
16
|
-
Excon.delete('http://localhost:9292').body
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
tests 'with a connection object' do
|
|
22
|
-
connection = nil
|
|
23
|
-
|
|
24
|
-
tests('connection.get').returns('GET') do
|
|
25
|
-
connection = Excon.new('http://localhost:9292')
|
|
26
|
-
connection.get.body
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
tests('connection.post').returns('POST') do
|
|
30
|
-
connection.post.body
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
tests('connection.delete').returns('DELETE') do
|
|
34
|
-
connection.delete.body
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
tests('not modifies path argument').returns('path') do
|
|
38
|
-
path = 'path'
|
|
39
|
-
connection.get(:path => path)
|
|
40
|
-
path
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
data/tests/request_tests.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Request Tests') do
|
|
2
|
-
with_server('good') do
|
|
3
|
-
|
|
4
|
-
tests('persistent connections') do
|
|
5
|
-
ip_ports = %w(127.0.0.1:9292)
|
|
6
|
-
ip_ports << "[::1]:9293" unless RUBY_PLATFORM == 'java'
|
|
7
|
-
ip_ports.each do |ip_port|
|
|
8
|
-
|
|
9
|
-
tests("with default :persistent => true, #{ip_port}") do
|
|
10
|
-
connection = nil
|
|
11
|
-
|
|
12
|
-
returns(['1', '2'], 'uses a persistent connection') do
|
|
13
|
-
connection = Excon.new("http://#{ip_port}", :persistent => true)
|
|
14
|
-
2.times.map do
|
|
15
|
-
connection.request(:method => :get, :path => '/echo/request_count').body
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
returns(['3', '1', '2'], ':persistent => false resets connection') do
|
|
20
|
-
ret = []
|
|
21
|
-
ret << connection.request(:method => :get,
|
|
22
|
-
:path => '/echo/request_count',
|
|
23
|
-
:persistent => false).body
|
|
24
|
-
ret << connection.request(:method => :get,
|
|
25
|
-
:path => '/echo/request_count').body
|
|
26
|
-
ret << connection.request(:method => :get,
|
|
27
|
-
:path => '/echo/request_count').body
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
tests("with default :persistent => false, #{ip_port}") do
|
|
32
|
-
connection = nil
|
|
33
|
-
|
|
34
|
-
returns(['1', '1'], 'does not use a persistent connection') do
|
|
35
|
-
connection = Excon.new("http://#{ip_port}", :persistent => false)
|
|
36
|
-
2.times.map do
|
|
37
|
-
connection.request(:method => :get, :path => '/echo/request_count').body
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
returns(['1', '2', '3', '1'], ':persistent => true enables persistence') do
|
|
42
|
-
ret = []
|
|
43
|
-
ret << connection.request(:method => :get,
|
|
44
|
-
:path => '/echo/request_count',
|
|
45
|
-
:persistent => true).body
|
|
46
|
-
ret << connection.request(:method => :get,
|
|
47
|
-
:path => '/echo/request_count',
|
|
48
|
-
:persistent => true).body
|
|
49
|
-
ret << connection.request(:method => :get,
|
|
50
|
-
:path => '/echo/request_count').body
|
|
51
|
-
ret << connection.request(:method => :get,
|
|
52
|
-
:path => '/echo/request_count').body
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
data/tests/response_tests.rb
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon Response Parsing') do
|
|
2
|
-
env_init
|
|
3
|
-
|
|
4
|
-
with_server('good') do
|
|
5
|
-
|
|
6
|
-
tests('responses with chunked transfer-encoding') do
|
|
7
|
-
|
|
8
|
-
tests('simple response').returns('hello world') do
|
|
9
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple').body
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
tests('with :response_block') do
|
|
13
|
-
|
|
14
|
-
tests('simple response').
|
|
15
|
-
returns([['hello ', nil, nil], ['world', nil, nil]]) do
|
|
16
|
-
capture_response_block do |block|
|
|
17
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple',
|
|
18
|
-
:response_block => block,
|
|
19
|
-
:chunk_size => 5) # not used
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
tests('simple response has empty body').returns('') do
|
|
24
|
-
response_block = lambda { |_, _, _| }
|
|
25
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple', :response_block => response_block).body
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
tests('with expected response status').
|
|
29
|
-
returns([['hello ', nil, nil], ['world', nil, nil]]) do
|
|
30
|
-
capture_response_block do |block|
|
|
31
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple',
|
|
32
|
-
:response_block => block,
|
|
33
|
-
:expects => 200)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
tests('with unexpected response status').returns('hello world') do
|
|
38
|
-
begin
|
|
39
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple',
|
|
40
|
-
:response_block => Proc.new { raise 'test failed' },
|
|
41
|
-
:expects => 500)
|
|
42
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
43
|
-
err.response[:body]
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
tests('merges trailers into headers').
|
|
50
|
-
returns('one, two, three, four, five, six') do
|
|
51
|
-
Excon.get('http://127.0.0.1:9292/chunked/trailers').headers['Test-Header']
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
tests("removes 'chunked' from Transfer-Encoding").returns(nil) do
|
|
55
|
-
Excon.get('http://127.0.0.1:9292/chunked/simple').headers['Transfer-Encoding']
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
tests('responses with content-length') do
|
|
61
|
-
|
|
62
|
-
tests('simple response').returns('hello world') do
|
|
63
|
-
Excon.get('http://127.0.0.1:9292/content-length/simple').body
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
tests('with :response_block') do
|
|
67
|
-
|
|
68
|
-
tests('simple response').
|
|
69
|
-
returns([['hello', 6, 11], [' worl', 1, 11], ['d', 0, 11]]) do
|
|
70
|
-
capture_response_block do |block|
|
|
71
|
-
Excon.get('http://127.0.0.1:9292/content-length/simple',
|
|
72
|
-
:response_block => block,
|
|
73
|
-
:chunk_size => 5)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
tests('simple response has empty body').returns('') do
|
|
78
|
-
response_block = lambda { |_, _, _| }
|
|
79
|
-
Excon.get('http://127.0.0.1:9292/content-length/simple', :response_block => response_block).body
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
tests('with expected response status').
|
|
83
|
-
returns([['hello', 6, 11], [' worl', 1, 11], ['d', 0, 11]]) do
|
|
84
|
-
capture_response_block do |block|
|
|
85
|
-
Excon.get('http://127.0.0.1:9292/content-length/simple',
|
|
86
|
-
:response_block => block,
|
|
87
|
-
:chunk_size => 5,
|
|
88
|
-
:expects => 200)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
tests('with unexpected response status').returns('hello world') do
|
|
93
|
-
begin
|
|
94
|
-
Excon.get('http://127.0.0.1:9292/content-length/simple',
|
|
95
|
-
:response_block => Proc.new { raise 'test failed' },
|
|
96
|
-
:chunk_size => 5,
|
|
97
|
-
:expects => 500)
|
|
98
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
99
|
-
err.response[:body]
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
tests('responses with unknown length') do
|
|
108
|
-
|
|
109
|
-
tests('simple response').returns('hello world') do
|
|
110
|
-
Excon.get('http://127.0.0.1:9292/unknown/simple').body
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
tests('with :response_block') do
|
|
114
|
-
|
|
115
|
-
tests('simple response').
|
|
116
|
-
returns([['hello', nil, nil], [' worl', nil, nil], ['d', nil, nil]]) do
|
|
117
|
-
capture_response_block do |block|
|
|
118
|
-
Excon.get('http://127.0.0.1:9292/unknown/simple',
|
|
119
|
-
:response_block => block,
|
|
120
|
-
:chunk_size => 5)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
tests('simple response has empty body').returns('') do
|
|
125
|
-
response_block = lambda { |_, _, _| }
|
|
126
|
-
Excon.get('http://127.0.0.1:9292/unknown/simple', :response_block => response_block).body
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
tests('with expected response status').
|
|
130
|
-
returns([['hello', nil, nil], [' worl', nil, nil], ['d', nil, nil]]) do
|
|
131
|
-
capture_response_block do |block|
|
|
132
|
-
Excon.get('http://127.0.0.1:9292/unknown/simple',
|
|
133
|
-
:response_block => block,
|
|
134
|
-
:chunk_size => 5,
|
|
135
|
-
:expects => 200)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
tests('with unexpected response status').returns('hello world') do
|
|
140
|
-
begin
|
|
141
|
-
Excon.get('http://127.0.0.1:9292/unknown/simple',
|
|
142
|
-
:response_block => Proc.new { raise 'test failed' },
|
|
143
|
-
:chunk_size => 5,
|
|
144
|
-
:expects => 500)
|
|
145
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
146
|
-
err.response[:body]
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
tests('cookies') do
|
|
155
|
-
|
|
156
|
-
tests('parses cookies into array').returns(['one, two', 'three, four']) do
|
|
157
|
-
resp = Excon.get('http://127.0.0.1:9292/unknown/cookies')
|
|
158
|
-
resp[:cookies]
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
tests('header continuation') do
|
|
164
|
-
|
|
165
|
-
tests('proper continuation').returns('one, two, three, four, five, six') do
|
|
166
|
-
resp = Excon.get('http://127.0.0.1:9292/unknown/header_continuation')
|
|
167
|
-
resp.headers['Test-Header']
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
tests('malformed header').raises(Excon::Errors::SocketError) do
|
|
171
|
-
Excon.get('http://127.0.0.1:9292/bad/malformed_header')
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
tests('malformed header continuation').raises(Excon::Errors::SocketError) do
|
|
175
|
-
Excon.get('http://127.0.0.1:9292/bad/malformed_header_continuation')
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
tests('status line parsing') do
|
|
181
|
-
|
|
182
|
-
tests('proper status code').returns(404) do
|
|
183
|
-
resp = Excon.get('http://127.0.0.1:9292/not-found')
|
|
184
|
-
resp.status
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
tests('proper reason phrase').returns("Not Found") do
|
|
188
|
-
resp = Excon.get('http://127.0.0.1:9292/not-found')
|
|
189
|
-
resp.reason_phrase
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
env_restore
|
|
197
|
-
end
|
data/tests/servers/bad.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "eventmachine"
|
|
4
|
-
|
|
5
|
-
module BadServer
|
|
6
|
-
def receive_data(data)
|
|
7
|
-
case data
|
|
8
|
-
when %r{^GET /eof/no_content_length_and_no_chunking\s}
|
|
9
|
-
send_data "HTTP/1.1 200 OK\r\n"
|
|
10
|
-
send_data "\r\n"
|
|
11
|
-
send_data "hello"
|
|
12
|
-
close_connection(true)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
EM.run do
|
|
18
|
-
EM.start_server("127.0.0.1", 9292, BadServer)
|
|
19
|
-
$stderr.puts "ready"
|
|
20
|
-
end
|
data/tests/servers/eof.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "eventmachine"
|
|
4
|
-
|
|
5
|
-
module EOFServer
|
|
6
|
-
def receive_data(data)
|
|
7
|
-
case data
|
|
8
|
-
when %r{^GET /eof\s}
|
|
9
|
-
close_connection(true)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
EM.run do
|
|
15
|
-
EM.start_server("127.0.0.1", 9292, EOFServer)
|
|
16
|
-
$stderr.puts "ready"
|
|
17
|
-
end
|
data/tests/servers/error.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "eventmachine"
|
|
4
|
-
|
|
5
|
-
module ErrorServer
|
|
6
|
-
def receive_data(data)
|
|
7
|
-
case data
|
|
8
|
-
when %r{^GET /error/not_found\s}
|
|
9
|
-
send_data "HTTP/1.1 404 Not Found\r\n"
|
|
10
|
-
send_data "\r\n"
|
|
11
|
-
send_data "server says not found"
|
|
12
|
-
close_connection(true)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
EM.run do
|
|
18
|
-
EM.start_server("127.0.0.1", 9292, ErrorServer)
|
|
19
|
-
$stderr.puts "ready"
|
|
20
|
-
end
|