CC: | bug-Capture-Tiny [...] rt.cpan.org |
Subject: | Re: Problem with Capture::Tiny, system() and HTTP::Server::Simple::CGI |
Date: | Mon, 25 Oct 2010 23:06:11 -0400 |
To: | Karl Gaissmaier <karl.gaissmaier [...] uni-ulm.de> |
From: | David Golden <dagolden [...] cpan.org> |
Thank you very much for the report. I'll start looking into it. I
suspect that the issues are related to HTTP::Server::Simple::CGI also
munging file descriptors, but I'll give it a try.
For reference, what is your perl -V output?
On Mon, Oct 25, 2010 at 6:28 PM, Karl Gaissmaier
<karl.gaissmaier@uni-ulm.de> wrote:
Show quoted text
> Hi Mr. Golden,
>
> thanks a lot for your work for the perl community!
>
> I'm using your Capture::Tiny to catch STDOUT and STDERR from external
> commands via system(). This works normally perfect, but within a
> request_handler in HTTP::Server::Simple::CGI the capture doesn't work.
>
> I need this simple HTTP server for test suites, sorry.
>
> I shrinked the code to a few couple of lines, perhaps you can find
> the edge case:
>
> #!/usr/bin/env perl
> MyServer->new->run;
>
> package MyServer;
> use base 'HTTP::Server::Simple::CGI';
> use Capture::Tiny qw(capture);
>
> sub handle_request {
> my ( $stdout, $stderr ) = capture { system('echo Hello World!') };
>
> print "HTTP/1.0 200 OK\r\n"
> . "Content-Type: text/html\r\n\r\n"
> . "<html><head></head><body>STDOUT: $stdout</body></html>";
> }
>
> After starting this script you should browse to localhost:8080
>
> The output of system() is displayed on the screen instead getting captured
> and send to the Web-client.
>
> Would be really great if you could find the edge case in
> HTTP::Server::Simple or Capture::Tiny which prevents capturing.
>
> Best Regards
> Charly Gaissmaier
>