jhthorsen/mojolicious-plugin-cgi — pull request #2 by leejo (2013-08-23 09:43:32+00:00)
Title: fix pipe leak, support redirects

rather than pausing the reactor by calling watch ($fh,0,0) remove
it entirely as the child process will exit and we need the pipe to
close otherwise we will hit the limit on open files when running
the plugin as part of a persistent environment (Mojo::IOLoop will
be in the parent, so having it pause means the handle doesn't go
out of scope).

add a test for the above, possibly not the best way to check the
number of open pipes is as expected, but "it works on my machine"

also explicitly close the cgi.stdin handle before unlinking the
path it points to

support redirects in cgi scripts that send a "Location: " header
by returning a 302 response code so the browser correctly renders
the output. this fixes an issue where you the browser will render
the content of the cgi script as plain text as there will be two
sets of headers. add a test for this