2 use Rack::ContentLength
3 use Rack::ContentType, "text/plain"
7 abort "body.each called after response hijack\n"
11 warn "closed DieIfUsed #{@@n += 1}\n"
20 if env["rack.hijack?"]
21 io = env["rack.hijack"].call
23 if io.respond_to?(:read_nonblock) &&
24 env["rack.hijack_io"].respond_to?(:read_nonblock)
26 # exercise both, since we Rack::Lint may use different objects
27 env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n")
28 io.write("request.hijacked")
30 return [ 500, {}, DieIfUsed.new ]
33 [ 500, {}, [ "hijack BAD\n" ] ]
35 r = "response.hijacked"
38 "Content-Length" => r.bytesize.to_s,
39 "rack.hijack" => proc do |io|
48 b = "#{env.object_id}\n"
50 'Content-Type' => 'text/plain',
51 'Content-Length' => b.bytesize.to_s,