mirrored from git://git.bogomips.org/unicorn.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close client socket after closing response body
Response bodies may capture the block passed to each and save it for body.close, so don't close the socket before we have a chance to call body.close
- Loading branch information
Eric Wong
committed
Jan 6, 2011
1 parent
1b69686
commit b72a86f
Showing
5 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
. ./test-lib.sh | ||
t_plan 4 "write-on-close tests for funky response-bodies" | ||
|
||
t_begin "setup and start" && { | ||
unicorn_setup | ||
unicorn -D -c $unicorn_config write-on-close.ru | ||
unicorn_wait_start | ||
} | ||
|
||
t_begin "write-on-close response body succeeds" && { | ||
test xGoodbye = x"$(curl -sSf http://$listen/)" | ||
} | ||
|
||
t_begin "killing succeeds" && { | ||
kill $unicorn_pid | ||
} | ||
|
||
t_begin "check stderr" && { | ||
check_stderr | ||
} | ||
|
||
t_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class WriteOnClose | ||
def each(&block) | ||
@callback = block | ||
end | ||
|
||
def close | ||
@callback.call "7\r\nGoodbye\r\n0\r\n\r\n" | ||
end | ||
end | ||
use Rack::ContentType, "text/plain" | ||
run(lambda { |_| [ 200, [%w(Transfer-Encoding chunked)], WriteOnClose.new ] }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters