excon 0.62.0 → 0.92.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,304 +0,0 @@
|
|
1
|
-
Shindo.tests('Excon stubs') do
|
2
|
-
env_init
|
3
|
-
|
4
|
-
tests("missing stub").raises(Excon::Errors::StubNotFound) do
|
5
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
6
|
-
connection.request(:method => :get, :path => '/content-length/100')
|
7
|
-
end
|
8
|
-
|
9
|
-
tests("stub({})").raises(ArgumentError) do
|
10
|
-
Excon.stub({})
|
11
|
-
end
|
12
|
-
|
13
|
-
tests("stub({}, {}) {}").raises(ArgumentError) do
|
14
|
-
Excon.stub({}, {}) {}
|
15
|
-
end
|
16
|
-
|
17
|
-
tests("stub({:method => :get}, {:body => 'body', :status => 200})") do
|
18
|
-
connection = nil
|
19
|
-
response = nil
|
20
|
-
|
21
|
-
tests('response.body').returns('body') do
|
22
|
-
Excon.stub({:method => :get}, {:body => 'body', :status => 200})
|
23
|
-
|
24
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
25
|
-
response = connection.request(:method => :get, :path => '/content-length/100')
|
26
|
-
|
27
|
-
response.body
|
28
|
-
end
|
29
|
-
|
30
|
-
tests('response.headers').returns({}) do
|
31
|
-
response.headers
|
32
|
-
end
|
33
|
-
|
34
|
-
tests('response.status').returns(200) do
|
35
|
-
response.status
|
36
|
-
end
|
37
|
-
|
38
|
-
tests('response_block yields body').returns('body') do
|
39
|
-
body = ''
|
40
|
-
response_block = lambda do |chunk, remaining_bytes, total_bytes|
|
41
|
-
body << chunk
|
42
|
-
end
|
43
|
-
connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block)
|
44
|
-
body
|
45
|
-
end
|
46
|
-
|
47
|
-
tests('response.body empty with response_block').returns('') do
|
48
|
-
response_block = lambda { |_, _, _| }
|
49
|
-
connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block).body
|
50
|
-
end
|
51
|
-
|
52
|
-
Excon.stubs.clear
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
tests("stub({:path => %r{/tests/(\S+)}}, {:body => $1, :status => 200})") do
|
57
|
-
connection = nil
|
58
|
-
response = nil
|
59
|
-
|
60
|
-
tests('response.body').returns('test') do
|
61
|
-
Excon.stub({:path => %r{/tests/(\S+)}}) do |params|
|
62
|
-
{
|
63
|
-
:body => params[:captures][:path].first,
|
64
|
-
:status => 200
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
69
|
-
response = connection.request(:method => :get, :path => '/tests/test')
|
70
|
-
|
71
|
-
response.body
|
72
|
-
end
|
73
|
-
|
74
|
-
tests('response.headers').returns({}) do
|
75
|
-
response.headers
|
76
|
-
end
|
77
|
-
|
78
|
-
tests('response.status').returns(200) do
|
79
|
-
response.status
|
80
|
-
end
|
81
|
-
|
82
|
-
Excon.stubs.clear
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
tests("stub({:body => 'body', :method => :get}) {|params| {:body => params[:body], :headers => params[:headers], :status => 200}}") do
|
87
|
-
connection = nil
|
88
|
-
response = nil
|
89
|
-
|
90
|
-
tests('response.body').returns('body') do
|
91
|
-
Excon.stub({:body => 'body', :method => :get}) {|params| {:body => params[:body], :headers => params[:headers], :status => 200}}
|
92
|
-
|
93
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
94
|
-
response = connection.request(:body => 'body', :method => :get, :path => '/content-length/100')
|
95
|
-
|
96
|
-
response.body
|
97
|
-
end
|
98
|
-
|
99
|
-
tests('response.headers').returns({'Host' => '127.0.0.1:9292', 'User-Agent' => "excon/#{Excon::VERSION}"}) do
|
100
|
-
response.headers
|
101
|
-
end
|
102
|
-
|
103
|
-
tests('response.status').returns(200) do
|
104
|
-
response.status
|
105
|
-
end
|
106
|
-
|
107
|
-
tests('response_block yields body').returns('body') do
|
108
|
-
body = ''
|
109
|
-
response_block = lambda do |chunk, remaining_bytes, total_bytes|
|
110
|
-
body << chunk
|
111
|
-
end
|
112
|
-
connection.request(:body => 'body', :method => :get, :path => '/content-length/100', :response_block => response_block)
|
113
|
-
body
|
114
|
-
end
|
115
|
-
|
116
|
-
tests('response.body empty with response_block').returns('') do
|
117
|
-
response_block = lambda { |_, _, _| }
|
118
|
-
connection.request(:body => 'body', :method => :get, :path => '/content-length/100', :response_block => response_block).body
|
119
|
-
end
|
120
|
-
|
121
|
-
Excon.stubs.clear
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
tests("stub({:body => File.open(...), :method => :get}, { :status => 200 })") do
|
126
|
-
|
127
|
-
tests('response.status').returns(200) do
|
128
|
-
file_path = File.join(File.dirname(__FILE__), '..', 'data', 'xs')
|
129
|
-
|
130
|
-
Excon.stub(
|
131
|
-
{ :body => File.read(file_path), :method => :get },
|
132
|
-
{ :status => 200 }
|
133
|
-
)
|
134
|
-
|
135
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
136
|
-
response = connection.request(:body => File.open(file_path), :method => :get, :path => '/')
|
137
|
-
|
138
|
-
response.status
|
139
|
-
end
|
140
|
-
|
141
|
-
Excon.stubs.clear
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
tests("invalid stub response").raises(Excon::Errors::InvalidStub) do
|
146
|
-
Excon.stub({:body => 42, :method => :get}, {:status => 200})
|
147
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
148
|
-
connection.request(:body => 42, :method => :get, :path => '/').status
|
149
|
-
end
|
150
|
-
|
151
|
-
tests("mismatched stub").raises(Excon::Errors::StubNotFound) do
|
152
|
-
Excon.stub({:method => :post}, {:body => 'body'})
|
153
|
-
Excon.get('http://127.0.0.1:9292/', :mock => true)
|
154
|
-
end
|
155
|
-
|
156
|
-
with_server('good') do
|
157
|
-
tests('allow mismatched stub').returns(200) do
|
158
|
-
Excon.stub({:path => '/echo/request_count'}, {:body => 'body'})
|
159
|
-
Excon.get(
|
160
|
-
'http://127.0.0.1:9292/echo/request',
|
161
|
-
:mock => true,
|
162
|
-
:allow_unstubbed_requests => true
|
163
|
-
).status
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
Excon.stubs.clear
|
168
|
-
|
169
|
-
tests("stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})") do
|
170
|
-
|
171
|
-
test("response_block yields body") do
|
172
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
173
|
-
Excon.stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})
|
174
|
-
|
175
|
-
chunks = []
|
176
|
-
response_block = lambda do |chunk, remaining_bytes, total_bytes|
|
177
|
-
chunks << chunk
|
178
|
-
end
|
179
|
-
connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block)
|
180
|
-
chunks == ['x' * Excon::DEFAULT_CHUNK_SIZE, 'x']
|
181
|
-
end
|
182
|
-
|
183
|
-
tests("response.body empty with response_block").returns('') do
|
184
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
185
|
-
Excon.stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})
|
186
|
-
response_block = lambda { |_, _, _| }
|
187
|
-
connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block).body
|
188
|
-
end
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
Excon.stubs.clear
|
193
|
-
|
194
|
-
tests("stub({:url => 'https://user:pass@foo.bar.com:9999/baz?quux=true'}, {:status => 200})") do
|
195
|
-
test("get(:expects => 200)") do
|
196
|
-
Excon.stub({:url => 'https://user:pass@foo.bar.com:9999/baz?quux=true'}, {:status => 200})
|
197
|
-
Excon.new("https://user:pass@foo.bar.com:9999/baz?quux=true", :mock => true).get(:expects => 200)
|
198
|
-
true
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
Excon.stubs.clear
|
203
|
-
|
204
|
-
tests("stub({}, {:status => 404, :body => 'Not Found'}") do
|
205
|
-
connection = nil
|
206
|
-
|
207
|
-
tests("request(:expects => 200, :method => :get, :path => '/')").raises(Excon::Errors::NotFound) do
|
208
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
209
|
-
Excon.stub({}, {:status => 404, :body => 'Not Found'})
|
210
|
-
|
211
|
-
connection.request(:expects => 200, :method => :get, :path => '/')
|
212
|
-
end
|
213
|
-
|
214
|
-
tests("Expects exception should contain response object").returns(Excon::Response) do
|
215
|
-
begin
|
216
|
-
connection.request(:expects => 200, :method => :get, :path => '/')
|
217
|
-
rescue Excon::Errors::NotFound => e
|
218
|
-
e.response.class
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
test("request(:expects => 200, :method => :get, :path => '/') with block does not invoke the block since it raises an error") do
|
223
|
-
block_called = false
|
224
|
-
begin
|
225
|
-
response_block = lambda do |_,_,_|
|
226
|
-
block_called = true
|
227
|
-
end
|
228
|
-
connection.request(:expects => 200, :method => :get, :path => '/', :response_block => response_block)
|
229
|
-
rescue Excon::Errors::NotFound
|
230
|
-
end
|
231
|
-
!block_called
|
232
|
-
end
|
233
|
-
|
234
|
-
Excon.stubs.clear
|
235
|
-
|
236
|
-
end
|
237
|
-
|
238
|
-
tests("stub_for({})") do
|
239
|
-
tests("stub_for({})").returns([{}, {}]) do
|
240
|
-
Excon.new('http://127.0.0.1:9292', :mock => true)
|
241
|
-
Excon.stub({}, {})
|
242
|
-
|
243
|
-
Excon.stub_for({})
|
244
|
-
end
|
245
|
-
|
246
|
-
Excon.stubs.clear
|
247
|
-
end
|
248
|
-
|
249
|
-
tests("unstub({})") do
|
250
|
-
connection = nil
|
251
|
-
|
252
|
-
tests("unstub({})").returns([{}, {}]) do
|
253
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
254
|
-
Excon.stub({}, {})
|
255
|
-
|
256
|
-
Excon.unstub({})
|
257
|
-
end
|
258
|
-
|
259
|
-
tests("request(:method => :get)").raises(Excon::Errors::StubNotFound) do
|
260
|
-
connection.request(:method => :get)
|
261
|
-
end
|
262
|
-
|
263
|
-
Excon.stubs.clear
|
264
|
-
end
|
265
|
-
|
266
|
-
tests("global stubs") do
|
267
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
268
|
-
Excon.stub({}, {:body => '1'})
|
269
|
-
t = Thread.new do
|
270
|
-
Excon.stub({}, {:body => '2'})
|
271
|
-
connection.request(:method => :get).body
|
272
|
-
end
|
273
|
-
tests("get on a different thread").returns('2') do
|
274
|
-
t.join.value
|
275
|
-
end
|
276
|
-
tests("get on main thread").returns('2') do
|
277
|
-
connection.request(:method => :get).body
|
278
|
-
end
|
279
|
-
Excon.stubs.clear
|
280
|
-
end
|
281
|
-
|
282
|
-
tests("thread-local stubs") do
|
283
|
-
original_stubs_value = Excon.defaults[:stubs]
|
284
|
-
Excon.defaults[:stubs] = :local
|
285
|
-
|
286
|
-
connection = Excon.new('http://127.0.0.1:9292', :mock => true)
|
287
|
-
Excon.stub({}, {:body => '1'})
|
288
|
-
t = Thread.new do
|
289
|
-
Excon.stub({}, {:body => '2'})
|
290
|
-
connection.request(:method => :get).body
|
291
|
-
end
|
292
|
-
tests("get on a different thread").returns('2') do
|
293
|
-
t.join.value
|
294
|
-
end
|
295
|
-
tests("get on main thread").returns('1') do
|
296
|
-
connection.request(:method => :get).body
|
297
|
-
end
|
298
|
-
Excon.stubs.clear
|
299
|
-
|
300
|
-
Excon.defaults[:stubs] = original_stubs_value
|
301
|
-
end
|
302
|
-
|
303
|
-
env_restore
|
304
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
Shindo.tests('Excon redirector support') do
|
2
|
-
env_init
|
3
|
-
|
4
|
-
tests("request(:method => :get, :path => '/old').body").returns('new') do
|
5
|
-
Excon.stub(
|
6
|
-
{ :path => '/old' },
|
7
|
-
{
|
8
|
-
:headers => { 'Location' => 'http://127.0.0.1:9292/new' },
|
9
|
-
:body => 'old',
|
10
|
-
:status => 301
|
11
|
-
}
|
12
|
-
)
|
13
|
-
|
14
|
-
Excon.stub(
|
15
|
-
{ :path => '/new' },
|
16
|
-
{
|
17
|
-
:body => 'new',
|
18
|
-
:status => 200
|
19
|
-
}
|
20
|
-
)
|
21
|
-
|
22
|
-
Excon.get(
|
23
|
-
'http://127.0.0.1:9292',
|
24
|
-
:path => '/old',
|
25
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
|
26
|
-
:mock => true
|
27
|
-
).body
|
28
|
-
end
|
29
|
-
|
30
|
-
env_restore
|
31
|
-
end
|
32
|
-
|
33
|
-
Shindo.tests('Excon redirect support for relative Location headers') do
|
34
|
-
env_init
|
35
|
-
|
36
|
-
tests("request(:method => :get, :path => '/old').body").returns('new') do
|
37
|
-
Excon.stub(
|
38
|
-
{ :path => '/old' },
|
39
|
-
{
|
40
|
-
:headers => { 'Location' => '/new' },
|
41
|
-
:body => 'old',
|
42
|
-
:status => 301
|
43
|
-
}
|
44
|
-
)
|
45
|
-
|
46
|
-
Excon.stub(
|
47
|
-
{ :path => '/new' },
|
48
|
-
{
|
49
|
-
:body => 'new',
|
50
|
-
:status => 200
|
51
|
-
}
|
52
|
-
)
|
53
|
-
|
54
|
-
Excon.get(
|
55
|
-
'http://127.0.0.1:9292',
|
56
|
-
:path => '/old',
|
57
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
|
58
|
-
:mock => true
|
59
|
-
).body
|
60
|
-
end
|
61
|
-
|
62
|
-
env_restore
|
63
|
-
end
|
64
|
-
|
65
|
-
Shindo.tests('Excon redirect support for relative Location headers with dot segments') do
|
66
|
-
env_init
|
67
|
-
|
68
|
-
tests("request(:method => :get, :path => '/foo/baz/').body").returns('/foo/bar/') do
|
69
|
-
Excon.stub(
|
70
|
-
{ :path => '/foo/baz/' },
|
71
|
-
{
|
72
|
-
:headers => { 'Location' => '../bar/' },
|
73
|
-
:body => '/foo/baz/',
|
74
|
-
:status => 301
|
75
|
-
}
|
76
|
-
)
|
77
|
-
|
78
|
-
Excon.stub(
|
79
|
-
{ :path => '/foo/bar/' },
|
80
|
-
{
|
81
|
-
:body => '/foo/bar/',
|
82
|
-
:status => 200
|
83
|
-
}
|
84
|
-
)
|
85
|
-
|
86
|
-
Excon.get(
|
87
|
-
'http://127.0.0.1:9292',
|
88
|
-
:path => '/foo/baz/',
|
89
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
|
90
|
-
:mock => true
|
91
|
-
).body
|
92
|
-
end
|
93
|
-
|
94
|
-
env_restore
|
95
|
-
end
|
96
|
-
|
97
|
-
Shindo.tests("Excon redirecting post request") do
|
98
|
-
env_init
|
99
|
-
|
100
|
-
with_rackup('redirecting.ru') do
|
101
|
-
tests("request not have content-length and body").returns('ok') do
|
102
|
-
Excon.post(
|
103
|
-
'http://127.0.0.1:9292',
|
104
|
-
:path => '/first',
|
105
|
-
:middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower],
|
106
|
-
:body => "a=Some_content"
|
107
|
-
).body
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
env_restore
|
112
|
-
end
|
data/tests/pipeline_tests.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
Shindo.tests('Pipelined Requests') do
|
2
|
-
with_server('good') do
|
3
|
-
|
4
|
-
tests('with default :persistent => true') do
|
5
|
-
returns(%w{ 1 2 3 4 }, 'connection is persistent') do
|
6
|
-
connection = Excon.new('http://127.0.0.1:9292', :persistent => true)
|
7
|
-
|
8
|
-
ret = []
|
9
|
-
ret << connection.requests([
|
10
|
-
{:method => :get, :path => '/echo/request_count'},
|
11
|
-
{:method => :get, :path => '/echo/request_count'}
|
12
|
-
]).map(&:body)
|
13
|
-
ret << connection.requests([
|
14
|
-
{:method => :get, :path => '/echo/request_count'},
|
15
|
-
{:method => :get, :path => '/echo/request_count'}
|
16
|
-
]).map(&:body)
|
17
|
-
ret.flatten
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
tests('with default :persistent => false') do
|
22
|
-
returns(%w{ 1 2 1 2 }, 'connection is persistent per call to #requests') do
|
23
|
-
connection = Excon.new('http://127.0.0.1:9292', :persistent => false)
|
24
|
-
|
25
|
-
ret = []
|
26
|
-
ret << connection.requests([
|
27
|
-
{:method => :get, :path => '/echo/request_count'},
|
28
|
-
{:method => :get, :path => '/echo/request_count'}
|
29
|
-
]).map(&:body)
|
30
|
-
ret << connection.requests([
|
31
|
-
{:method => :get, :path => '/echo/request_count'},
|
32
|
-
{:method => :get, :path => '/echo/request_count'}
|
33
|
-
]).map(&:body)
|
34
|
-
ret.flatten
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|