summaryrefslogtreecommitdiffhomepage
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/ruby/at_exit/config.ru8
-rw-r--r--test/ruby/body_array/config.ru5
-rw-r--r--test/ruby/body_each_error/config.ru6
-rw-r--r--test/ruby/body_empty/config.ru5
-rw-r--r--test/ruby/body_file/config.ru6
-rw-r--r--test/ruby/body_file/file1
-rw-r--r--test/ruby/empty/config.ru9
-rw-r--r--test/ruby/errors_puts/config.ru6
-rw-r--r--test/ruby/errors_puts_int/config.ru6
-rw-r--r--test/ruby/errors_write/config.ru6
-rw-r--r--test/ruby/errors_write_int/config.ru6
-rw-r--r--test/ruby/errors_write_to_s_custom/config.ru15
-rw-r--r--test/ruby/header_custom/config.ru8
-rw-r--r--test/ruby/header_rack/config.ru8
-rw-r--r--test/ruby/header_status/config.ru8
-rw-r--r--test/ruby/input_each/config.ru11
-rw-r--r--test/ruby/input_gets/config.ru8
-rw-r--r--test/ruby/input_gets_all/config.ru14
-rw-r--r--test/ruby/input_read_buffer/config.ru9
-rw-r--r--test/ruby/input_read_buffer_not_empty/config.ru9
-rw-r--r--test/ruby/input_read_empty/config.ru6
-rw-r--r--test/ruby/input_read_parts/config.ru10
-rw-r--r--test/ruby/input_rewind/config.ru8
-rw-r--r--test/ruby/mirror/config.ru8
-rw-r--r--test/ruby/query_string/config.ru8
-rw-r--r--test/ruby/server_port/config.ru8
-rw-r--r--test/ruby/status_int/config.ru5
-rw-r--r--test/ruby/syntax_error/config.ru5
-rw-r--r--test/ruby/variables/config.ru24
29 files changed, 236 insertions, 0 deletions
diff --git a/test/ruby/at_exit/config.ru b/test/ruby/at_exit/config.ru
new file mode 100644
index 00000000..0e2c40c6
--- /dev/null
+++ b/test/ruby/at_exit/config.ru
@@ -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
diff --git a/test/ruby/body_array/config.ru b/test/ruby/body_array/config.ru
new file mode 100644
index 00000000..05dcc760
--- /dev/null
+++ b/test/ruby/body_array/config.ru
@@ -0,0 +1,5 @@
+app = Proc.new do |env|
+ ['200', {'Content-Length' => '10'}, ['0123', '4567', '89']]
+end
+
+run app
diff --git a/test/ruby/body_each_error/config.ru b/test/ruby/body_each_error/config.ru
new file mode 100644
index 00000000..0d34603d
--- /dev/null
+++ b/test/ruby/body_each_error/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ io = IO.new(0, 'r')
+ ['200', {'Content-Length' => '0'}, io]
+end
+
+run app
diff --git a/test/ruby/body_empty/config.ru b/test/ruby/body_empty/config.ru
new file mode 100644
index 00000000..a8684b9b
--- /dev/null
+++ b/test/ruby/body_empty/config.ru
@@ -0,0 +1,5 @@
+app = Proc.new do |env|
+ ['200', {}, []]
+end
+
+run app
diff --git a/test/ruby/body_file/config.ru b/test/ruby/body_file/config.ru
new file mode 100644
index 00000000..2b229699
--- /dev/null
+++ b/test/ruby/body_file/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ file = File.open('file', 'r')
+ ['200', {'Content-Length' => '5'}, file]
+end
+
+run app
diff --git a/test/ruby/body_file/file b/test/ruby/body_file/file
new file mode 100644
index 00000000..273a402f
--- /dev/null
+++ b/test/ruby/body_file/file
@@ -0,0 +1 @@
+body
diff --git a/test/ruby/empty/config.ru b/test/ruby/empty/config.ru
new file mode 100644
index 00000000..eeeab5d3
--- /dev/null
+++ b/test/ruby/empty/config.ru
@@ -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
diff --git a/test/ruby/errors_puts/config.ru b/test/ruby/errors_puts/config.ru
new file mode 100644
index 00000000..75d0d87e
--- /dev/null
+++ b/test/ruby/errors_puts/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ env['rack.errors'].puts('Error in application')
+ ['200', {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/errors_puts_int/config.ru b/test/ruby/errors_puts_int/config.ru
new file mode 100644
index 00000000..bc1e664a
--- /dev/null
+++ b/test/ruby/errors_puts_int/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ env['rack.errors'].puts(1234567890)
+ ['200', {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/errors_write/config.ru b/test/ruby/errors_write/config.ru
new file mode 100644
index 00000000..47619d6b
--- /dev/null
+++ b/test/ruby/errors_write/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ env['rack.errors'].write('Error in application')
+ ['200', {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/errors_write_int/config.ru b/test/ruby/errors_write_int/config.ru
new file mode 100644
index 00000000..55d6c9d3
--- /dev/null
+++ b/test/ruby/errors_write_int/config.ru
@@ -0,0 +1,6 @@
+app = Proc.new do |env|
+ env['rack.errors'].write(1234567890)
+ ['200', {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/errors_write_to_s_custom/config.ru b/test/ruby/errors_write_to_s_custom/config.ru
new file mode 100644
index 00000000..9eb06d1a
--- /dev/null
+++ b/test/ruby/errors_write_to_s_custom/config.ru
@@ -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
diff --git a/test/ruby/header_custom/config.ru b/test/ruby/header_custom/config.ru
new file mode 100644
index 00000000..8570fd2b
--- /dev/null
+++ b/test/ruby/header_custom/config.ru
@@ -0,0 +1,8 @@
+app = Proc.new do |env|
+ ['200', {
+ 'Content-Length' => '0',
+ 'Custom-Header' => env['rack.input'].read
+ }, []]
+end
+
+run app
diff --git a/test/ruby/header_rack/config.ru b/test/ruby/header_rack/config.ru
new file mode 100644
index 00000000..40f53249
--- /dev/null
+++ b/test/ruby/header_rack/config.ru
@@ -0,0 +1,8 @@
+app = Proc.new do |env|
+ ['200', {
+ 'Content-Length' => '0',
+ 'rack.header' => 'hello'
+ }, ['']]
+end
+
+run app
diff --git a/test/ruby/header_status/config.ru b/test/ruby/header_status/config.ru
new file mode 100644
index 00000000..29f038c2
--- /dev/null
+++ b/test/ruby/header_status/config.ru
@@ -0,0 +1,8 @@
+app = Proc.new do |env|
+ ['200', {
+ 'Content-Length' => '0',
+ 'Status' => '200'
+ }, []]
+end
+
+run app
diff --git a/test/ruby/input_each/config.ru b/test/ruby/input_each/config.ru
new file mode 100644
index 00000000..02446998
--- /dev/null
+++ b/test/ruby/input_each/config.ru
@@ -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
diff --git a/test/ruby/input_gets/config.ru b/test/ruby/input_gets/config.ru
new file mode 100644
index 00000000..1a6633ab
--- /dev/null
+++ b/test/ruby/input_gets/config.ru
@@ -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
diff --git a/test/ruby/input_gets_all/config.ru b/test/ruby/input_gets_all/config.ru
new file mode 100644
index 00000000..186b2418
--- /dev/null
+++ b/test/ruby/input_gets_all/config.ru
@@ -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
diff --git a/test/ruby/input_read_buffer/config.ru b/test/ruby/input_read_buffer/config.ru
new file mode 100644
index 00000000..1e8bf7b4
--- /dev/null
+++ b/test/ruby/input_read_buffer/config.ru
@@ -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
diff --git a/test/ruby/input_read_buffer_not_empty/config.ru b/test/ruby/input_read_buffer_not_empty/config.ru
new file mode 100644
index 00000000..5f1f0434
--- /dev/null
+++ b/test/ruby/input_read_buffer_not_empty/config.ru
@@ -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
diff --git a/test/ruby/input_read_empty/config.ru b/test/ruby/input_read_empty/config.ru
new file mode 100644
index 00000000..92e885c5
--- /dev/null
+++ b/test/ruby/input_read_empty/config.ru
@@ -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
diff --git a/test/ruby/input_read_parts/config.ru b/test/ruby/input_read_parts/config.ru
new file mode 100644
index 00000000..59016a7b
--- /dev/null
+++ b/test/ruby/input_read_parts/config.ru
@@ -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
diff --git a/test/ruby/input_rewind/config.ru b/test/ruby/input_rewind/config.ru
new file mode 100644
index 00000000..fc0d6535
--- /dev/null
+++ b/test/ruby/input_rewind/config.ru
@@ -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
diff --git a/test/ruby/mirror/config.ru b/test/ruby/mirror/config.ru
new file mode 100644
index 00000000..a4bba0e6
--- /dev/null
+++ b/test/ruby/mirror/config.ru
@@ -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
diff --git a/test/ruby/query_string/config.ru b/test/ruby/query_string/config.ru
new file mode 100644
index 00000000..57ad7758
--- /dev/null
+++ b/test/ruby/query_string/config.ru
@@ -0,0 +1,8 @@
+app = Proc.new do |env|
+ ['200', {
+ 'Content-Length' => '0',
+ 'Query-String' => env['QUERY_STRING']
+ }, ['']]
+end
+
+run app
diff --git a/test/ruby/server_port/config.ru b/test/ruby/server_port/config.ru
new file mode 100644
index 00000000..af308177
--- /dev/null
+++ b/test/ruby/server_port/config.ru
@@ -0,0 +1,8 @@
+app = Proc.new do |env|
+ ['200', {
+ 'Content-Length' => '0',
+ 'Server-Port' => env['SERVER_PORT']
+ }, ['']]
+end
+
+run app
diff --git a/test/ruby/status_int/config.ru b/test/ruby/status_int/config.ru
new file mode 100644
index 00000000..305be2d3
--- /dev/null
+++ b/test/ruby/status_int/config.ru
@@ -0,0 +1,5 @@
+app = Proc.new do |env|
+ [200, {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/syntax_error/config.ru b/test/ruby/syntax_error/config.ru
new file mode 100644
index 00000000..45c42dad
--- /dev/null
+++ b/test/ruby/syntax_error/config.ru
@@ -0,0 +1,5 @@
+app = Proc.new |env|
+ ['200', {'Content-Length' => '0'}, ['']]
+end
+
+run app
diff --git a/test/ruby/variables/config.ru b/test/ruby/variables/config.ru
new file mode 100644
index 00000000..4caac3c2
--- /dev/null
+++ b/test/ruby/variables/config.ru
@@ -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