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/data/excon.cert.key
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
-
MIIEowIBAAKCAQEAxZ527UceJuBMTm/FwDzbq+2WAMwoRg3s09KSEf5mMPP+dZnt
|
|
3
|
-
jsNwNw0ixbc13nc+xQbC9roWcGTSP/YYDCb5A7huMehTMHY7iuR4+yuGsA60ar24
|
|
4
|
-
g0qZwBLTL0+2X9lO/VCwpSLiUqMOhqXIdXyYSiGlY2X25Y7Ro35DYo13inRIeaU0
|
|
5
|
-
YBmT0GKJG88kmp6dnYPnUxsl0fk7c30WEufAgrp5VpRH9reV/mF2TIZiLf3OkbHj
|
|
6
|
-
tUb/qr2KzW35ZcFZpot1TSiYOGUfbzWSr4dpXdqQbqQqHvTEUZdT1hrurBH48D5a
|
|
7
|
-
QYk7rPzyrARJGkZl9JIGSWkzT6ohtg4/tlv08wIDAQABAoIBABpFHnocYh2442vp
|
|
8
|
-
39fWPz1zr+UbPp9RapIeA9zwfJU1WjY36CR6RoiK7nxqBnc0UtvOMkyqICGAxZJL
|
|
9
|
-
HJdA9wlPkxZ/U8+1Z+Tmyk5ZUuZEjidCYSzS1e16kyhO6GeFc8Ko31KUeJGTq3Kq
|
|
10
|
-
xyMXFQeFwX6dJ10Mx0F8n2iSdbmpz6Sfz+L8RwUjlbi3m1iveeMqTk0V8ChTDluC
|
|
11
|
-
RWLoUUAqOaV3YpaV4pHmpRJ9uMLbyC72t6JnbLdi5d/EY5vGmMDgsKg/pqW8omFO
|
|
12
|
-
8kWo5riLncUyvEwSPoUyY12WWc3CnroacEJ7GoibuZYZwntwot+cWOkIZmnCbj+H
|
|
13
|
-
OiBcDoECgYEA8ZgQmdlxQ5Fwe9sadDA3SYi2V/6bQNQkw54xkfsWd/PijIunVJI8
|
|
14
|
-
cj/hVnbZL487DnJAXsLLygw048fSGwFZXmNbQUiXZaEIpa4t9DkgouGPvvuBp6TI
|
|
15
|
-
uIjUF4aRKA4a3+MT4SNm74qXx8co5YXnE09KIMswZQ1YHjwIzV0ggJsCgYEA0Wce
|
|
16
|
-
7poL7Xiyu1G1vr8vEbYtqelqHP28SzXkwrTqyOV8MPlw0/OhMDWmPLdE9mxSDwdD
|
|
17
|
-
QAlPvvCWXhHEM/St5tN72mzuyodHjNsVnlPAckj6ADTTAmUO0fixHjivZ/6v+PEo
|
|
18
|
-
SbjzmsbEExjyLKdScW8ALq3nfCdC9+Z3aTFShokCgYBbmz9gNtT9u94c+J11RPsR
|
|
19
|
-
xObvQrl3wXkXO5qsMbr5TN6wUBvos3J8F8DH2lTL9dF8ztGdnNtNB4feftwqJT7P
|
|
20
|
-
zXjCrlXJ0V/IAt2l5yt613B8CD3HZXI+lpNlQD82IvMJxb659YSIe9LFi7z0Guvd
|
|
21
|
-
pIkFGkaFaqPpAvaLeC5k1QKBgGTqrZ2P3++yG3DrEAu9V5HRmnAobVtLbVNRxc2Q
|
|
22
|
-
IxZugkuX6yg6YZQ6RsM8D6Ay09kqRt61nhkHGXB8X3IqmSSFB0tc9DfmujTH4MNM
|
|
23
|
-
2ZI6WUGAM7ETwvCuSa2m4+HafDQdBK2C1OPiptwNSaj7el/wfsYASW8r/Lo795Ba
|
|
24
|
-
lMsBAoGBAO8fKeu1cSrgNBG5Bafa5P2uPK1X9GASA1zgG6ay3FGH9m/vt36/DcRq
|
|
25
|
-
LQQP1WJUH8AR9/jlUgpS134Ww0AFVVh/ZHZTFnVkS8mn6wzFehxt49uVVcJncRzB
|
|
26
|
-
Vnes1S/Zky0RgvfR4rWy9NCYkIkqYAQPacfElxpGItV7V2INKFol
|
|
27
|
-
-----END RSA PRIVATE KEY-----
|
data/tests/data/xs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
data/tests/error_tests.rb
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Shindo.tests('HTTPStatusError request/response debugging') do
|
|
4
|
-
|
|
5
|
-
# Regression against e300458f2d9330cb265baeb8973120d08c665d9
|
|
6
|
-
tests('Excon::Error knows about pertinent errors') do
|
|
7
|
-
expected = [
|
|
8
|
-
100,
|
|
9
|
-
101,
|
|
10
|
-
(200..206).to_a,
|
|
11
|
-
(300..307).to_a,
|
|
12
|
-
(400..417).to_a,
|
|
13
|
-
422,
|
|
14
|
-
429,
|
|
15
|
-
(500..504).to_a
|
|
16
|
-
]
|
|
17
|
-
expected.flatten == Excon::Error.status_errors.keys
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
tests('new returns an Error').returns(true) do
|
|
21
|
-
Excon::Error.new('bar').class == Excon::Error
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
tests('new raises errors for bad URIs').returns(true) do
|
|
25
|
-
begin
|
|
26
|
-
Excon.new('foo')
|
|
27
|
-
false
|
|
28
|
-
rescue => err
|
|
29
|
-
err.to_s.include? 'foo'
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
tests('new raises errors for bad paths').returns(true) do
|
|
34
|
-
begin
|
|
35
|
-
Excon.new('http://localhost', path: "foo\r\nbar: baz")
|
|
36
|
-
false
|
|
37
|
-
rescue => err
|
|
38
|
-
err.to_s.include? "foo\r\nbar: baz"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
tests('can raise standard error and catch standard error').returns(true) do
|
|
43
|
-
begin
|
|
44
|
-
raise Excon::Error::Client.new('foo')
|
|
45
|
-
rescue Excon::Error => e
|
|
46
|
-
true
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
tests('can raise legacy errors and catch legacy errors').returns(true) do
|
|
51
|
-
begin
|
|
52
|
-
raise Excon::Errors::Error.new('bar')
|
|
53
|
-
rescue Excon::Errors::Error => e
|
|
54
|
-
true
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
tests('can raise standard error and catch legacy errors').returns(true) do
|
|
59
|
-
begin
|
|
60
|
-
raise Excon::Error::NotFound.new('bar')
|
|
61
|
-
rescue Excon::Errors::Error => e
|
|
62
|
-
true
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
tests('can raise with status_error() and catch with standard error').returns(true) do
|
|
67
|
-
begin
|
|
68
|
-
raise Excon::Error.status_error({expects: 200}, {status: 400})
|
|
69
|
-
rescue Excon::Error
|
|
70
|
-
true
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tests('can raise with status_error() and catch with legacy error').returns(true) do
|
|
76
|
-
begin
|
|
77
|
-
raise Excon::Error.status_error({expects: 200}, {status: 400})
|
|
78
|
-
rescue Excon::Errors::BadRequest
|
|
79
|
-
true
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
tests('can raise with legacy status_error() and catch with legacy').returns(true) do
|
|
84
|
-
begin
|
|
85
|
-
raise Excon::Errors.status_error({expects: 200}, {status: 400})
|
|
86
|
-
rescue Excon::Errors::BadRequest
|
|
87
|
-
true
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
tests('can raise with legacy status_error() and catch with standard').returns(true) do
|
|
93
|
-
begin
|
|
94
|
-
raise Excon::Errors.status_error({expects: 200}, {status: 400})
|
|
95
|
-
rescue Excon::Error
|
|
96
|
-
true
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
with_server('error') do
|
|
101
|
-
|
|
102
|
-
tests('message does not include response or response info').returns(true) do
|
|
103
|
-
begin
|
|
104
|
-
Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200)
|
|
105
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
106
|
-
err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
|
|
107
|
-
!err.message.include?('excon.error.request') &&
|
|
108
|
-
!err.message.include?('excon.error.response')
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
tests('message includes only request info').returns(true) do
|
|
113
|
-
begin
|
|
114
|
-
Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
|
|
115
|
-
:debug_request => true)
|
|
116
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
117
|
-
err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
|
|
118
|
-
err.message.include?('excon.error.request') &&
|
|
119
|
-
!err.message.include?('excon.error.response')
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
tests('message includes only response info').returns(true) do
|
|
124
|
-
begin
|
|
125
|
-
Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
|
|
126
|
-
:debug_response => true)
|
|
127
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
128
|
-
err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
|
|
129
|
-
!err.message.include?('excon.error.request') &&
|
|
130
|
-
err.message.include?('excon.error.response')
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
tests('message include request and response info').returns(true) do
|
|
135
|
-
begin
|
|
136
|
-
Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200,
|
|
137
|
-
:debug_request => true, :debug_response => true)
|
|
138
|
-
rescue Excon::Errors::HTTPStatusError => err
|
|
139
|
-
err.message.include?('Expected(200) <=> Actual(404 Not Found)') &&
|
|
140
|
-
err.message.include?('excon.error.request') &&
|
|
141
|
-
err.message.include?('excon.error.response')
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
data/tests/header_tests.rb
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon response header support') do
|
|
2
|
-
env_init
|
|
3
|
-
|
|
4
|
-
tests('Excon::Headers storage') do
|
|
5
|
-
headers = Excon::Headers.new
|
|
6
|
-
headers['Exact-Case'] = 'expected'
|
|
7
|
-
headers['Another-Fixture'] = 'another'
|
|
8
|
-
|
|
9
|
-
tests('stores and retrieves as received').returns('expected') do
|
|
10
|
-
headers['Exact-Case']
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
tests('enumerates keys as received') do
|
|
14
|
-
ks = headers.keys
|
|
15
|
-
tests('contains Exact-Case').returns(true) { ks.include? 'Exact-Case' }
|
|
16
|
-
tests('contains Another-Fixture').returns(true) { ks.include? 'Another-Fixture' }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
tests('supports case-insensitive access').returns('expected') do
|
|
20
|
-
headers['EXACT-CASE']
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
tests('but still returns nil for missing keys').returns(nil) do
|
|
24
|
-
headers['Missing-Header']
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
tests('Hash methods that should support case-insensitive access') do
|
|
28
|
-
if {}.respond_to? :assoc
|
|
29
|
-
tests('#assoc').returns(%w{exact-case expected}) do
|
|
30
|
-
headers.assoc('exact-Case')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
tests('#delete') do
|
|
35
|
-
tests('with just a key').returns('yes') do
|
|
36
|
-
headers['Extra'] = 'yes'
|
|
37
|
-
headers.delete('extra')
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
tests('with a proc').returns('called with notpresent') do
|
|
41
|
-
headers.delete('notpresent') { |k| "called with #{k}" }
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
tests('#fetch') do
|
|
46
|
-
tests('when present').returns('expected') { headers.fetch('exact-CASE') }
|
|
47
|
-
tests('with a default value').returns('default') { headers.fetch('missing', 'default') }
|
|
48
|
-
tests('with a default proc').returns('got missing') do
|
|
49
|
-
headers.fetch('missing') { |k| "got #{k}" }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
tests('#has_key?') do
|
|
54
|
-
tests('when present').returns(true) { headers.has_key?('EXACT-case') }
|
|
55
|
-
tests('when absent').returns(false) { headers.has_key?('missing') }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
tests('#values_at') do
|
|
59
|
-
tests('all present').returns(%w{expected another}) do
|
|
60
|
-
headers.values_at('exACT-cASE', 'anotheR-fixturE')
|
|
61
|
-
end
|
|
62
|
-
tests('some missing').returns(['expected', nil]) do
|
|
63
|
-
headers.values_at('exact-case', 'missing-header')
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
with_rackup('response_header.ru') do
|
|
70
|
-
|
|
71
|
-
tests('Response#get_header') do
|
|
72
|
-
connection = nil
|
|
73
|
-
response = nil
|
|
74
|
-
|
|
75
|
-
tests('with variable header capitalization') do
|
|
76
|
-
|
|
77
|
-
tests('response.get_header("mixedcase-header")').returns('MixedCase') do
|
|
78
|
-
connection = Excon.new('http://foo.com:8080', :proxy => 'http://127.0.0.1:9292')
|
|
79
|
-
response = connection.request(:method => :get, :path => '/foo')
|
|
80
|
-
|
|
81
|
-
response.get_header("mixedcase-header")
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
tests('response.get_header("uppercase-header")').returns('UPPERCASE') do
|
|
85
|
-
response.get_header("uppercase-header")
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
tests('response.get_header("lowercase-header")').returns('lowercase') do
|
|
89
|
-
response.get_header("lowercase-header")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
tests('when provided key capitalization varies') do
|
|
95
|
-
|
|
96
|
-
tests('response.get_header("MIXEDCASE-HEADER")').returns('MixedCase') do
|
|
97
|
-
response.get_header("MIXEDCASE-HEADER")
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
tests('response.get_header("MiXeDcAsE-hEaDeR")').returns('MixedCase') do
|
|
101
|
-
response.get_header("MiXeDcAsE-hEaDeR")
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
tests('when header is unavailable') do
|
|
107
|
-
|
|
108
|
-
tests('response.get_header("missing")').returns(nil) do
|
|
109
|
-
response.get_header("missing")
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
env_restore
|
|
119
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Shindo.tests("Excon support for middlewares that return canned responses") do
|
|
2
|
-
the_body = "canned"
|
|
3
|
-
|
|
4
|
-
canned_response_middleware = Class.new(Excon::Middleware::Base) do
|
|
5
|
-
define_method :request_call do |params|
|
|
6
|
-
params[:response] = {
|
|
7
|
-
:body => the_body,
|
|
8
|
-
:headers => {},
|
|
9
|
-
:status => 200
|
|
10
|
-
}
|
|
11
|
-
super(params)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
tests('does not mutate the canned response body').returns(the_body) do
|
|
16
|
-
Excon.get(
|
|
17
|
-
'http://some-host.com/some-path',
|
|
18
|
-
:middlewares => [canned_response_middleware] + Excon.defaults[:middlewares]
|
|
19
|
-
).body
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
tests('yields non-mutated body to response_block').returns(the_body) do
|
|
23
|
-
body = ''
|
|
24
|
-
response_block = lambda { |chunk, _, _| body << chunk }
|
|
25
|
-
Excon.get(
|
|
26
|
-
'http://some-host.com/some-path',
|
|
27
|
-
:middlewares => [canned_response_middleware] + Excon.defaults[:middlewares],
|
|
28
|
-
:response_block => response_block
|
|
29
|
-
)
|
|
30
|
-
body
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Shindo.tests("Excon redirecting with cookie preserved") do
|
|
2
|
-
env_init
|
|
3
|
-
|
|
4
|
-
with_rackup('redirecting_with_cookie.ru') do
|
|
5
|
-
tests('second request will send cookies set by the first').returns('ok') do
|
|
6
|
-
Excon.get(
|
|
7
|
-
'http://127.0.0.1:9292',
|
|
8
|
-
:path => '/sets_cookie',
|
|
9
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower]
|
|
10
|
-
).body
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
tests('second request will send multiple cookies set by the first').returns('ok') do
|
|
14
|
-
Excon.get(
|
|
15
|
-
'http://127.0.0.1:9292',
|
|
16
|
-
:path => '/sets_multi_cookie',
|
|
17
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower]
|
|
18
|
-
).body
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
with_rackup('redirecting.ru') do
|
|
23
|
-
tests("runs normally when there are no cookies set").returns('ok') do
|
|
24
|
-
Excon.post(
|
|
25
|
-
'http://127.0.0.1:9292',
|
|
26
|
-
:path => '/first',
|
|
27
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower],
|
|
28
|
-
:body => "a=Some_content"
|
|
29
|
-
).body
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
env_restore
|
|
34
|
-
end
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon Decompress Middleware') do
|
|
2
|
-
env_init
|
|
3
|
-
|
|
4
|
-
with_server('good') do
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
@connection ||= Excon.new(
|
|
8
|
-
'http://127.0.0.1:9292/echo/content-encoded',
|
|
9
|
-
:method => :post,
|
|
10
|
-
:body => 'hello world',
|
|
11
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::Decompress]
|
|
12
|
-
)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
tests('gzip') do
|
|
16
|
-
resp = nil
|
|
17
|
-
|
|
18
|
-
tests('response body decompressed').returns('hello world') do
|
|
19
|
-
resp = @connection.request(
|
|
20
|
-
:headers => { 'Accept-Encoding' => 'gzip, deflate;q=0' }
|
|
21
|
-
)
|
|
22
|
-
resp[:body]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
tests('server sent content-encoding').returns('gzip') do
|
|
26
|
-
resp[:headers]['Content-Encoding-Sent']
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
tests('removes processed encoding from header').returns('') do
|
|
30
|
-
resp[:headers]['Content-Encoding']
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
tests('empty response body').returns('') do
|
|
34
|
-
resp = @connection.request(:body => '')
|
|
35
|
-
resp[:body]
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
tests('deflate') do
|
|
40
|
-
resp = nil
|
|
41
|
-
|
|
42
|
-
tests('response body decompressed').returns('hello world') do
|
|
43
|
-
resp = @connection.request(
|
|
44
|
-
:headers => { 'Accept-Encoding' => 'gzip;q=0, deflate' }
|
|
45
|
-
)
|
|
46
|
-
resp[:body]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
tests('server sent content-encoding').returns('deflate') do
|
|
50
|
-
resp[:headers]['Content-Encoding-Sent']
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
tests('removes processed encoding from header').returns('') do
|
|
54
|
-
resp[:headers]['Content-Encoding']
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
tests('with pre-encoding') do
|
|
59
|
-
resp = nil
|
|
60
|
-
|
|
61
|
-
tests('server sent content-encoding').returns('other, gzip') do
|
|
62
|
-
resp = @connection.request(
|
|
63
|
-
:headers => { 'Accept-Encoding' => 'gzip, deflate;q=0',
|
|
64
|
-
'Content-Encoding-Pre' => 'other' }
|
|
65
|
-
)
|
|
66
|
-
resp[:headers]['Content-Encoding-Sent']
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
tests('processed encoding removed from header').returns('other') do
|
|
70
|
-
resp[:headers]['Content-Encoding']
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
tests('response body decompressed').returns('hello world') do
|
|
74
|
-
resp[:body]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
tests('with post-encoding') do
|
|
80
|
-
resp = nil
|
|
81
|
-
|
|
82
|
-
tests('server sent content-encoding').returns('gzip, other') do
|
|
83
|
-
resp = @connection.request(
|
|
84
|
-
:headers => { 'Accept-Encoding' => 'gzip, deflate;q=0',
|
|
85
|
-
'Content-Encoding-Post' => 'other' }
|
|
86
|
-
)
|
|
87
|
-
resp[:headers]['Content-Encoding-Sent']
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
tests('unprocessed since last applied is unknown').returns('gzip, other') do
|
|
91
|
-
resp[:headers]['Content-Encoding']
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
tests('response body still compressed').returns('hello world') do
|
|
95
|
-
Zlib::GzipReader.new(StringIO.new(resp[:body])).read
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
tests('with a :response_block') do
|
|
101
|
-
captures = nil
|
|
102
|
-
resp = nil
|
|
103
|
-
|
|
104
|
-
tests('server sent content-encoding').returns('gzip') do
|
|
105
|
-
captures = capture_response_block do |block|
|
|
106
|
-
resp = @connection.request(
|
|
107
|
-
:headers => { 'Accept-Encoding' => 'gzip'},
|
|
108
|
-
:response_block => block
|
|
109
|
-
)
|
|
110
|
-
end
|
|
111
|
-
resp[:headers]['Content-Encoding-Sent']
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
tests('unprocessed since :response_block was used').returns('gzip') do
|
|
115
|
-
resp[:headers]['Content-Encoding']
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
tests(':response_block passed unprocessed data').returns('hello world') do
|
|
119
|
-
body = captures.map {|capture| capture[0] }.join
|
|
120
|
-
Zlib::GzipReader.new(StringIO.new(body)).read
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
tests('adds Accept-Encoding if needed') do
|
|
126
|
-
|
|
127
|
-
tests('without a :response_block').returns('deflate, gzip') do
|
|
128
|
-
resp = Excon.post(
|
|
129
|
-
'http://127.0.0.1:9292/echo/request',
|
|
130
|
-
:body => 'hello world',
|
|
131
|
-
:middlewares => Excon.defaults[:middlewares] +
|
|
132
|
-
[Excon::Middleware::Decompress]
|
|
133
|
-
)
|
|
134
|
-
request = Marshal.load(resp.body)
|
|
135
|
-
request[:headers]['Accept-Encoding']
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
tests('with a :response_block').returns(nil) do
|
|
139
|
-
captures = capture_response_block do |block|
|
|
140
|
-
Excon.post(
|
|
141
|
-
'http://127.0.0.1:9292/echo/request',
|
|
142
|
-
:body => 'hello world',
|
|
143
|
-
:response_block => block,
|
|
144
|
-
:middlewares => Excon.defaults[:middlewares] +
|
|
145
|
-
[Excon::Middleware::Decompress]
|
|
146
|
-
)
|
|
147
|
-
end
|
|
148
|
-
request = Marshal.load(captures.map {|capture| capture[0] }.join)
|
|
149
|
-
request[:headers]['Accept-Encoding']
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
env_restore
|
|
157
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Excon Decompress Middleware') do
|
|
2
|
-
env_init
|
|
3
|
-
with_rackup('basic.ru') do
|
|
4
|
-
tests('encoded uri passed to connection') do
|
|
5
|
-
tests('GET /echo%20dirty').returns(200) do
|
|
6
|
-
connection = Excon::Connection.new({
|
|
7
|
-
:host => '127.0.0.1',
|
|
8
|
-
:hostname => '127.0.0.1',
|
|
9
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::EscapePath],
|
|
10
|
-
:nonblock => false,
|
|
11
|
-
:port => 9292,
|
|
12
|
-
:scheme => 'http',
|
|
13
|
-
:ssl_verify_peer => false
|
|
14
|
-
})
|
|
15
|
-
response = connection.request(:method => :get, :path => '/echo%20dirty')
|
|
16
|
-
response[:status]
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
tests('unencoded uri passed to connection') do
|
|
21
|
-
tests('GET /echo dirty').returns(200) do
|
|
22
|
-
connection = Excon::Connection.new({
|
|
23
|
-
:host => '127.0.0.1',
|
|
24
|
-
:hostname => '127.0.0.1',
|
|
25
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::EscapePath],
|
|
26
|
-
:nonblock => false,
|
|
27
|
-
:port => 9292,
|
|
28
|
-
:scheme => 'http',
|
|
29
|
-
:ssl_verify_peer => false
|
|
30
|
-
})
|
|
31
|
-
response = connection.request(:method => :get, :path => '/echo dirty')
|
|
32
|
-
response[:status]
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|