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
data/tests/proxy_tests.rb
DELETED
@@ -1,306 +0,0 @@
|
|
1
|
-
Shindo.tests('Excon proxy support') do
|
2
|
-
env_init
|
3
|
-
|
4
|
-
tests('proxy configuration') do
|
5
|
-
|
6
|
-
tests('no proxy') do
|
7
|
-
tests('connection.data[:proxy]').returns(nil) do
|
8
|
-
connection = Excon.new('http://foo.com')
|
9
|
-
connection.data[:proxy]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
tests('empty proxy') do
|
14
|
-
tests('connection.data[:proxy]').returns(nil) do
|
15
|
-
connection = Excon.new('http://foo.com', :proxy => '')
|
16
|
-
connection.data[:proxy]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
tests('with fully-specified proxy: https://myproxy.net:8080') do
|
21
|
-
connection = nil
|
22
|
-
|
23
|
-
tests('connection.data[:proxy][:host]').returns('myproxy.net') do
|
24
|
-
connection = Excon.new('http://foo.com', :proxy => 'https://myproxy.net:8080')
|
25
|
-
connection.data[:proxy][:host]
|
26
|
-
end
|
27
|
-
|
28
|
-
tests('connection.data[:proxy][:port]').returns(8080) do
|
29
|
-
connection.data[:proxy][:port]
|
30
|
-
end
|
31
|
-
|
32
|
-
tests('connection.data[:proxy][:scheme]').returns('https') do
|
33
|
-
connection.data[:proxy][:scheme]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
tests('with fully-specified Unix socket proxy: unix:///') do
|
38
|
-
connection = nil
|
39
|
-
|
40
|
-
tests('connection.data[:proxy][:host]').returns(nil) do
|
41
|
-
connection = Excon.new('http://foo.com', :proxy => 'unix:///tmp/myproxy.sock')
|
42
|
-
connection.data[:proxy][:host]
|
43
|
-
end
|
44
|
-
|
45
|
-
tests('connection.data[:proxy][:port]').returns(nil) do
|
46
|
-
connection.data[:proxy][:port]
|
47
|
-
end
|
48
|
-
|
49
|
-
tests('connection.data[:proxy][:scheme]').returns('unix') do
|
50
|
-
connection.data[:proxy][:scheme]
|
51
|
-
end
|
52
|
-
|
53
|
-
tests('connection.data[:proxy][:path]').returns('/tmp/myproxy.sock') do
|
54
|
-
connection.data[:proxy][:path]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def env_proxy_tests(env)
|
59
|
-
env_init(env)
|
60
|
-
|
61
|
-
tests('an http connection') do
|
62
|
-
connection = nil
|
63
|
-
|
64
|
-
tests('connection.data[:proxy][:host]').returns('myproxy') do
|
65
|
-
connection = Excon.new('http://foo.com')
|
66
|
-
connection.data[:proxy][:host]
|
67
|
-
end
|
68
|
-
|
69
|
-
tests('connection.data[:proxy][:port]').returns(8080) do
|
70
|
-
connection.data[:proxy][:port]
|
71
|
-
end
|
72
|
-
|
73
|
-
tests('connection.data[:proxy][:scheme]').returns('http') do
|
74
|
-
connection.data[:proxy][:scheme]
|
75
|
-
end
|
76
|
-
|
77
|
-
tests('with disable_proxy set') do
|
78
|
-
connection = nil
|
79
|
-
|
80
|
-
tests('connection.data[:proxy]').returns(nil) do
|
81
|
-
connection = Excon.new('http://foo.com', :disable_proxy => true)
|
82
|
-
connection.data[:proxy]
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
tests('an https connection') do
|
88
|
-
connection = nil
|
89
|
-
|
90
|
-
tests('connection.data[:proxy][:host]').returns('mysecureproxy') do
|
91
|
-
connection = Excon.new('https://secret.com')
|
92
|
-
connection.data[:proxy][:host]
|
93
|
-
end
|
94
|
-
|
95
|
-
tests('connection.data[:proxy][:port]').returns(8081) do
|
96
|
-
connection.data[:proxy][:port]
|
97
|
-
end
|
98
|
-
|
99
|
-
tests('connection.data[:proxy][:scheme]').returns('http') do
|
100
|
-
connection.data[:proxy][:scheme]
|
101
|
-
end
|
102
|
-
|
103
|
-
tests('with disable_proxy set') do
|
104
|
-
connection = nil
|
105
|
-
|
106
|
-
tests('connection.data[:proxy]').returns(nil) do
|
107
|
-
connection = Excon.new('https://foo.com', :disable_proxy => true)
|
108
|
-
connection.data[:proxy]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
tests('http proxy from the environment overrides config') do
|
114
|
-
connection = nil
|
115
|
-
|
116
|
-
tests('connection.data[:proxy][:host]').returns('myproxy') do
|
117
|
-
connection = Excon.new('http://foo.com', :proxy => 'http://hard.coded.proxy:6666')
|
118
|
-
connection.data[:proxy][:host]
|
119
|
-
end
|
120
|
-
|
121
|
-
tests('connection.data[:proxy][:port]').returns(8080) do
|
122
|
-
connection.data[:proxy][:port]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
tests('an http connection in no_proxy') do
|
127
|
-
tests('connection.data[:proxy]').returns(nil) do
|
128
|
-
connection = Excon.new('http://somesubdomain.noproxy')
|
129
|
-
connection.data[:proxy]
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
tests('an http connection not completely matching no_proxy') do
|
134
|
-
tests('connection.data[:proxy][:host]').returns('myproxy') do
|
135
|
-
connection = Excon.new('http://noproxy2')
|
136
|
-
connection.data[:proxy][:host]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
tests('an http connection with subdomain in no_proxy') do
|
141
|
-
tests('connection.data[:proxy]').returns(nil) do
|
142
|
-
connection = Excon.new('http://a.subdomain.noproxy2')
|
143
|
-
connection.data[:proxy]
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
env_restore
|
148
|
-
end
|
149
|
-
|
150
|
-
tests('with complete proxy config from the environment') do
|
151
|
-
env = {
|
152
|
-
'http_proxy' => 'http://myproxy:8080',
|
153
|
-
'https_proxy' => 'http://mysecureproxy:8081',
|
154
|
-
'no_proxy' => 'noproxy, subdomain.noproxy2'
|
155
|
-
}
|
156
|
-
tests('lowercase') { env_proxy_tests(env) }
|
157
|
-
upperenv = {}
|
158
|
-
env.each do |k, v|
|
159
|
-
upperenv[k.upcase] = v
|
160
|
-
end
|
161
|
-
tests('uppercase') { env_proxy_tests(upperenv) }
|
162
|
-
end
|
163
|
-
|
164
|
-
tests('with only http_proxy config from the environment') do
|
165
|
-
env_init({'http_proxy' => 'http://myproxy:8080' })
|
166
|
-
|
167
|
-
tests('an https connection') do
|
168
|
-
connection = nil
|
169
|
-
|
170
|
-
tests('connection.data[:proxy][:host]').returns('myproxy') do
|
171
|
-
connection = Excon.new('https://secret.com')
|
172
|
-
connection.data[:proxy][:host]
|
173
|
-
end
|
174
|
-
|
175
|
-
tests('connection.data[:proxy][:port]').returns(8080) do
|
176
|
-
connection.data[:proxy][:port]
|
177
|
-
end
|
178
|
-
|
179
|
-
tests('connection.data[:proxy][:scheme]').returns('http') do
|
180
|
-
connection.data[:proxy][:scheme]
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
env_restore
|
185
|
-
end
|
186
|
-
|
187
|
-
tests('with a unix socket proxy config from the environment') do
|
188
|
-
env_init({
|
189
|
-
'http_proxy' => 'unix:///tmp/myproxy.sock',
|
190
|
-
})
|
191
|
-
|
192
|
-
tests('an https connection') do
|
193
|
-
connection = nil
|
194
|
-
|
195
|
-
tests('connection.data[:proxy][:host]').returns(nil) do
|
196
|
-
connection = Excon.new('https://secret.com')
|
197
|
-
connection.data[:proxy][:host]
|
198
|
-
end
|
199
|
-
|
200
|
-
tests('connection.data[:proxy][:port]').returns(nil) do
|
201
|
-
connection.data[:proxy][:port]
|
202
|
-
end
|
203
|
-
|
204
|
-
tests('connection.data[:proxy][:scheme]').returns('unix') do
|
205
|
-
connection.data[:proxy][:scheme]
|
206
|
-
end
|
207
|
-
|
208
|
-
tests('connection.data[:proxy][:path]').returns('/tmp/myproxy.sock') do
|
209
|
-
connection.data[:proxy][:path]
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
env_restore
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
|
218
|
-
with_rackup('proxy.ru') do
|
219
|
-
|
220
|
-
tests('http proxying: http://foo.com:8080') do
|
221
|
-
response = nil
|
222
|
-
|
223
|
-
tests('response.status').returns(200) do
|
224
|
-
connection = Excon.new('http://foo.com:8080', :proxy => 'http://127.0.0.1:9292')
|
225
|
-
response = connection.request(:method => :get, :path => '/bar', :query => {:alpha => 'kappa'})
|
226
|
-
|
227
|
-
response.status
|
228
|
-
end
|
229
|
-
|
230
|
-
# must be absolute form for proxy requests
|
231
|
-
tests('sent Request URI').returns('http://foo.com:8080/bar?alpha=kappa') do
|
232
|
-
response.headers['Sent-Request-Uri']
|
233
|
-
end
|
234
|
-
|
235
|
-
tests('sent Sent-Host header').returns('foo.com:8080') do
|
236
|
-
response.headers['Sent-Host']
|
237
|
-
end
|
238
|
-
|
239
|
-
tests('sent Proxy-Connection header').returns('Keep-Alive') do
|
240
|
-
response.headers['Sent-Proxy-Connection']
|
241
|
-
end
|
242
|
-
|
243
|
-
tests('response.body (proxied content)').returns('proxied content') do
|
244
|
-
response.body
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
tests('http proxying: http://user:pass@foo.com:8080') do
|
249
|
-
response = nil
|
250
|
-
|
251
|
-
tests('response.status').returns(200) do
|
252
|
-
connection = Excon.new('http://foo.com:8080', :proxy => 'http://user:pass@127.0.0.1:9292')
|
253
|
-
response = connection.request(:method => :get, :path => '/bar', :query => {:alpha => 'kappa'})
|
254
|
-
|
255
|
-
response.status
|
256
|
-
end
|
257
|
-
|
258
|
-
# must be absolute form for proxy requests
|
259
|
-
tests('sent Request URI').returns('http://foo.com:8080/bar?alpha=kappa') do
|
260
|
-
response.headers['Sent-Request-Uri']
|
261
|
-
end
|
262
|
-
|
263
|
-
tests('sent Host header').returns('foo.com:8080') do
|
264
|
-
response.headers['Sent-Host']
|
265
|
-
end
|
266
|
-
|
267
|
-
tests('sent Proxy-Connection header').returns('Keep-Alive') do
|
268
|
-
response.headers['Sent-Proxy-Connection']
|
269
|
-
end
|
270
|
-
|
271
|
-
tests('response.body (proxied content)').returns('proxied content') do
|
272
|
-
response.body
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
end
|
277
|
-
|
278
|
-
with_unicorn('proxy.ru', 'unix:///tmp/myproxy.sock') do
|
279
|
-
pending if RUBY_PLATFORM == 'java' # need to find suitable server for jruby
|
280
|
-
|
281
|
-
tests('http proxying over unix socket: http://foo.com:8080') do
|
282
|
-
response = nil
|
283
|
-
|
284
|
-
tests('response.status').returns(200) do
|
285
|
-
connection = Excon.new('http://foo.com:8080', :proxy => 'unix:///tmp/myproxy.sock')
|
286
|
-
response = connection.request(:method => :get, :path => '/bar', :query => {:alpha => 'kappa'})
|
287
|
-
|
288
|
-
response.status
|
289
|
-
end
|
290
|
-
|
291
|
-
tests('sent Sent-Host header').returns('foo.com:8080') do
|
292
|
-
response.headers['Sent-Host']
|
293
|
-
end
|
294
|
-
|
295
|
-
tests('sent Proxy-Connection header').returns('Keep-Alive') do
|
296
|
-
response.headers['Sent-Proxy-Connection']
|
297
|
-
end
|
298
|
-
|
299
|
-
tests('response.body (proxied content)').returns('proxied content') do
|
300
|
-
response.body
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
env_restore
|
306
|
-
end
|
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
|
-
})
|