1 DIR = File.dirname(__FILE__)
9 n = (seconds / 0.01).to_i
12 #File.read(DIR + '/yahoo.html')
24 commands = env['PATH_INFO'].split('/')
27 if commands.include?('periodical_activity') and @count % 10 != 1
28 return [200, {'Content-Type'=>'text/plain'}, "quick response!\r\n"]
31 if commands.include?('fibonacci')
32 n = commands.last.to_i
33 raise "fibonacci called with n <= 0" if n <= 0
34 body = (1..n).to_a.map { |i| fib(i).to_s }.join(' ')
37 elsif commands.include?('wait')
38 n = commands.last.to_i
39 raise "wait called with n <= 0" if n <= 0
41 body = "waited about #{n} seconds"
44 elsif commands.include?('bytes')
45 n = commands.last.to_i
46 raise "bytes called with n <= 0" if n <= 0
47 body = @@responses[n] || "C"*n
50 elsif commands.include?('test_post_length')
52 while chunk = env['rack.input'].read(512)
55 if env['HTTP_CONTENT_LENGTH'].to_i == input_body.length
56 body = "Content-Length matches input length"
59 body = "Content-Length doesn't matches input length!
60 content_length = #{env['HTTP_CONTENT_LENGTH'].to_i}
61 input_body.length = #{input_body.length}"
67 body = "Undefined url"
70 [status, {'Content-Type' => 'text/plain'}, body + "\r\n\r\n"]
76 require DIR + '/../ruby_lib/ebb'
81 server = Ebb::Server.new(SimpleApp.new, :port => 4001)
82 puts "Ebb started on http://0.0.0.0:4001/"