From fedb5e50829e6dfad30ca18ea525c812eccbec70 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Jan 2013 23:52:14 +0000 Subject: ignore normal Rack response at request-time hijack Once a connection is hijacked, we ignore it completely and leave the connection at the mercy of the application. --- t/hijack.ru | 7 ++++++- t/t0200-rack-hijack.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/hijack.ru b/t/hijack.ru index 105e0d7..fcb0b6d 100644 --- a/t/hijack.ru +++ b/t/hijack.ru @@ -17,7 +17,12 @@ run lambda { |env| io = env["rack.hijack"].call if io.respond_to?(:read_nonblock) && env["rack.hijack_io"].respond_to?(:read_nonblock) - return [ 200, {}, [ "hijack.OK\n" ] ] + + # exercise both, since we Rack::Lint may use different objects + env["rack.hijack_io"].write("HTTP/1.0 200 OK\r\n\r\n") + io.write("request.hijacked") + io.close + return [ 500, {}, DieIfUsed.new ] end end [ 500, {}, [ "hijack BAD\n" ] ] diff --git a/t/t0200-rack-hijack.sh b/t/t0200-rack-hijack.sh index 23a9ee4..f772071 100755 --- a/t/t0200-rack-hijack.sh +++ b/t/t0200-rack-hijack.sh @@ -9,7 +9,7 @@ t_begin "setup and start" && { } t_begin "check request hijack" && { - test "xhijack.OK" = x"$(curl -sSfv http://$listen/hijack_req)" + test "xrequest.hijacked" = x"$(curl -sSfv http://$listen/hijack_req)" } t_begin "check response hijack" && { -- cgit v1.2.3-24-ge0c7