Tests: Ruby module.
This commit is contained in:
8
test/ruby/at_exit/config.ru
Normal file
8
test/ruby/at_exit/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
at_exit do
|
||||
env['rack.errors'].puts('At exit called.')
|
||||
end
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
5
test/ruby/body_array/config.ru
Normal file
5
test/ruby/body_array/config.ru
Normal file
@@ -0,0 +1,5 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {'Content-Length' => '10'}, ['0123', '4567', '89']]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/body_each_error/config.ru
Normal file
6
test/ruby/body_each_error/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
io = IO.new(0, 'r')
|
||||
['200', {'Content-Length' => '0'}, io]
|
||||
end
|
||||
|
||||
run app
|
||||
5
test/ruby/body_empty/config.ru
Normal file
5
test/ruby/body_empty/config.ru
Normal file
@@ -0,0 +1,5 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {}, []]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/body_file/config.ru
Normal file
6
test/ruby/body_file/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
file = File.open('file', 'r')
|
||||
['200', {'Content-Length' => '5'}, file]
|
||||
end
|
||||
|
||||
run app
|
||||
1
test/ruby/body_file/file
Normal file
1
test/ruby/body_file/file
Normal file
@@ -0,0 +1 @@
|
||||
body
|
||||
9
test/ruby/empty/config.ru
Normal file
9
test/ruby/empty/config.ru
Normal file
@@ -0,0 +1,9 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].gets
|
||||
#body += env['rack.input'].gets
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/errors_puts/config.ru
Normal file
6
test/ruby/errors_puts/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
env['rack.errors'].puts('Error in application')
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/errors_puts_int/config.ru
Normal file
6
test/ruby/errors_puts_int/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
env['rack.errors'].puts(1234567890)
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/errors_write/config.ru
Normal file
6
test/ruby/errors_write/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
env['rack.errors'].write('Error in application')
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/errors_write_int/config.ru
Normal file
6
test/ruby/errors_write_int/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
env['rack.errors'].write(1234567890)
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
15
test/ruby/errors_write_to_s_custom/config.ru
Normal file
15
test/ruby/errors_write_to_s_custom/config.ru
Normal file
@@ -0,0 +1,15 @@
|
||||
app = Proc.new do |env|
|
||||
|
||||
class Custom
|
||||
def to_s()
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
e = Custom.new()
|
||||
|
||||
env['rack.errors'].write(e)
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/header_custom/config.ru
Normal file
8
test/ruby/header_custom/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {
|
||||
'Content-Length' => '0',
|
||||
'Custom-Header' => env['rack.input'].read
|
||||
}, []]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/header_rack/config.ru
Normal file
8
test/ruby/header_rack/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {
|
||||
'Content-Length' => '0',
|
||||
'rack.header' => 'hello'
|
||||
}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/header_status/config.ru
Normal file
8
test/ruby/header_status/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {
|
||||
'Content-Length' => '0',
|
||||
'Status' => '200'
|
||||
}, []]
|
||||
end
|
||||
|
||||
run app
|
||||
11
test/ruby/input_each/config.ru
Normal file
11
test/ruby/input_each/config.ru
Normal file
@@ -0,0 +1,11 @@
|
||||
app = Proc.new do |env|
|
||||
body = ''
|
||||
env['rack.input'].each do |value|
|
||||
body += value
|
||||
end
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/input_gets/config.ru
Normal file
8
test/ruby/input_gets/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].gets
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
14
test/ruby/input_gets_all/config.ru
Normal file
14
test/ruby/input_gets_all/config.ru
Normal file
@@ -0,0 +1,14 @@
|
||||
app = Proc.new do |env|
|
||||
body = ''
|
||||
buf = ''
|
||||
loop do
|
||||
buf = env['rack.input'].gets
|
||||
break if buf == nil
|
||||
body += buf
|
||||
end
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
9
test/ruby/input_read_buffer/config.ru
Normal file
9
test/ruby/input_read_buffer/config.ru
Normal file
@@ -0,0 +1,9 @@
|
||||
app = Proc.new do |env|
|
||||
body = ''
|
||||
env['rack.input'].read(nil, body)
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
9
test/ruby/input_read_buffer_not_empty/config.ru
Normal file
9
test/ruby/input_read_buffer_not_empty/config.ru
Normal file
@@ -0,0 +1,9 @@
|
||||
app = Proc.new do |env|
|
||||
body = 'blah'
|
||||
env['rack.input'].read(nil, body)
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
6
test/ruby/input_read_empty/config.ru
Normal file
6
test/ruby/input_read_empty/config.ru
Normal file
@@ -0,0 +1,6 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].read
|
||||
['200', {'Content-Length' => body.length.to_s}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
10
test/ruby/input_read_parts/config.ru
Normal file
10
test/ruby/input_read_parts/config.ru
Normal file
@@ -0,0 +1,10 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].read(4)
|
||||
body += env['rack.input'].read(4)
|
||||
body += env['rack.input'].read(1)
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/input_rewind/config.ru
Normal file
8
test/ruby/input_rewind/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
env['rack.input'].read
|
||||
env['rack.input'].rewind
|
||||
body = env['rack.input'].read
|
||||
['200', {'Content-Length' => body.length.to_s}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/mirror/config.ru
Normal file
8
test/ruby/mirror/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].read
|
||||
['200', {
|
||||
'Content-Length' => body.length.to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/query_string/config.ru
Normal file
8
test/ruby/query_string/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {
|
||||
'Content-Length' => '0',
|
||||
'Query-String' => env['QUERY_STRING']
|
||||
}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
8
test/ruby/server_port/config.ru
Normal file
8
test/ruby/server_port/config.ru
Normal file
@@ -0,0 +1,8 @@
|
||||
app = Proc.new do |env|
|
||||
['200', {
|
||||
'Content-Length' => '0',
|
||||
'Server-Port' => env['SERVER_PORT']
|
||||
}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
5
test/ruby/status_int/config.ru
Normal file
5
test/ruby/status_int/config.ru
Normal file
@@ -0,0 +1,5 @@
|
||||
app = Proc.new do |env|
|
||||
[200, {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
5
test/ruby/syntax_error/config.ru
Normal file
5
test/ruby/syntax_error/config.ru
Normal file
@@ -0,0 +1,5 @@
|
||||
app = Proc.new |env|
|
||||
['200', {'Content-Length' => '0'}, ['']]
|
||||
end
|
||||
|
||||
run app
|
||||
24
test/ruby/variables/config.ru
Normal file
24
test/ruby/variables/config.ru
Normal file
@@ -0,0 +1,24 @@
|
||||
app = Proc.new do |env|
|
||||
body = env['rack.input'].read
|
||||
version = env['rack.version'].join('')
|
||||
|
||||
['200', {
|
||||
'Content-Type' => env['CONTENT_TYPE'],
|
||||
'Content-Length' => body.length.to_s,
|
||||
'Request-Method' => env['REQUEST_METHOD'],
|
||||
'Request-Uri' => env['REQUEST_URI'],
|
||||
'Http-Host' => env['HTTP_HOST'],
|
||||
'Server-Protocol' => env['SERVER_PROTOCOL'],
|
||||
'Custom-Header' => env['HTTP_CUSTOM_HEADER'],
|
||||
'Rack-Version' => version,
|
||||
'Rack-Url-Scheme' => env['rack.url_scheme'],
|
||||
'Rack-Multithread' => env['rack.multithread'].to_s,
|
||||
'Rack-Multiprocess' => env['rack.multiprocess'].to_s,
|
||||
'Rack-Run-Once' => env['rack.run_once'].to_s,
|
||||
'Rack-Hijack-Q' => env['rack.hijack?'].to_s,
|
||||
'Rack-Hijack' => env['rack.hijack'].to_s,
|
||||
'Rack-Hijack-IO' => env['rack.hijack_io'].to_s
|
||||
}, [body]]
|
||||
end
|
||||
|
||||
run app
|
||||
Reference in New Issue
Block a user