Sha256: e57cb05284c5d54b8320b20bf5370539aa1fc85f37ba9b38bd1450d21bf32ac9
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
require 'rubygems' require 'ebb' Ebb.log = File.open('/dev/null','w') TEST_PORT = 4044 class HelperApp def call(env) commands = env['PATH_INFO'].split('/') if commands.include?('delay') n = commands.last.to_i raise "delay called with n <= 0" if n < 0 sleep n body = "delayed #{n} seconds" status = 200 elsif commands.include?('bytes') n = commands.last.to_i raise "bytes called with n <= 0" if n <= 0 body = "C"*n status = 200 elsif commands.include?('test_post_length') input_body = env['rack.input'].read content_length_header = env['HTTP_CONTENT_LENGTH'].to_i if content_length_header == input_body.length body = "Content-Length matches input length" status = 200 else body = "Content-Length header is #{content_length_header} but body length is #{input_body.length}" status = 500 end else status = 404 body = "Undefined url" end [status, {'Content-Type' => 'text/json'}, body] end end def start puts "starting up ebb"; Thread.start{ Ebb.start_server(HelperApp.new, :port => TEST_PORT) } sleep 0.1 until Ebb.running? Signal.trap( "HUP" ){ Ebb.stop_server sleep 0.1 while Ebb.running? } # keep process alive sleep 0.5 while Ebb.running? end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
evdispatch-0.1.0 | ext/revdispatch/server.rb |
evdispatch-0.1.1 | ext/revdispatch/server.rb |
evdispatch-0.1.2 | ext/revdispatch/server.rb |
evdispatch-0.1.3 | ext/revdispatch/server.rb |