2 use Rack::ContentLength
3 use Rack::ContentType, "text/plain"
6 abort "body.each called after response hijack\n"
10 abort "body.close called after response hijack\n"
15 # wait and see if Rainbows! accidentally closes us
16 sleep((ENV["DELAY"] || 10).to_i)
20 warn "E: #{e.message} (#{e.class})"
30 if env["rack.hijack?"]
31 io = env["rack.hijack"].call
32 if io.respond_to?(:read_nonblock) &&
33 env["rack.hijack_io"].respond_to?(:read_nonblock)
35 # exercise both, since we Rack::Lint may use different objects
36 env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n")
37 io.write("request.hijacked")
39 return [ 500, {}, DieIfUsed.new ]
42 [ 500, {}, [ "hijack BAD\n" ] ]
44 r = "response.hijacked"
47 "Content-Length" => r.bytesize.to_s,
48 "rack.hijack" => proc do |io|