| 1 | use strictscip-perl cpan FCGI-Client 0.09 strict/; |
| 2 | use warningsscip-perl cpan FCGI-Client 0.09 warnings/; |
| 3 | use Test::Morescip-perl cpan FCGI-Client 0.09 Test/More/; |
| 4 | use Test::TCPscip-perl cpan FCGI-Client 0.09 Test/TCP/; |
| 5 | use FCGIscip-perl cpan FCGI-Client 0.09 FCGI/; |
| 6 | use FCGI::Client::Connectionscip-perl cpan FCGI-Client 0.09 FCGI/Client/Connection/; |
| 7 | |
| 8 | test_tcpscip-perl cpan FCGI-Client 0.09 main/test_tcp().( |
| 9 | client => sub { |
| 10 | my $port = shiftscip-perl cpan FCGI-Client 0.09 main/shift().; |
| 11 | my $sock = IO::Socket::INET->newscip-perl cpan FCGI-Client 0.09 IO/Socket/INET/new().( |
| 12 | PeerAddr => '127.0.0.1', |
| 13 | PeerPort => $port, |
| 14 | ) or diescip-perl cpan FCGI-Client 0.09 main/die(). $!scip-perl cpan FCGI-Client 0.09 main/`$!`.; |
| 15 | my $client = FCGI::Client::Connection->newscip-perl cpan FCGI-Client 0.09 FCGI/Client/Connection/new().(sock => $sock); |
| 16 | my ( $stdout, $stderr ) = $client->requestscip-perl cpan FCGI-Client 0.09 FCGI/Client/Connection/request().( |
| 17 | +{ |
| 18 | REQUEST_METHOD => 'GET', |
| 19 | QUERY_STRING => 'foo=bar', |
| 20 | }, |
| 21 | '' |
| 22 | ); |
| 23 | isscip-perl cpan FCGI-Client 0.09 main/is(). $stdout, "Content−type: text/html\r\n\r\nhello external world"; |
| 24 | done_testing; |
| 25 | }, |
| 26 | server => sub { |
| 27 | my $port = shiftscip-perl cpan FCGI-Client 0.09 main/shift().; |
| 28 | my %env; |
| 29 | my $sock = FCGI::OpenSocketscip-perl cpan FCGI-Client 0.09 FCGI/OpenSocket().(':'.$port, 100) or diescip-perl cpan FCGI-Client 0.09 main/die().; |
| 30 | my $request = FCGI::Requestscip-perl cpan FCGI-Client 0.09 FCGI/Request().( |
| 31 | \*STDIN, |
| 32 | \*STDOUT, |
| 33 | \*STDOUT, |
| 34 | \%env, |
| 35 | $sock, |
| 36 | &FCGI::FAIL_ACCEPT_ON_INTRscip-perl cpan FCGI-Client 0.09 FCGI/FAIL_ACCEPT_ON_INTR()., |
| 37 | ); |
| 38 | while ($request->Acceptscip-perl cpan FCGI-Client 0.09 main/Accept(). >= 0) { |
| 39 | printscip-perl cpan FCGI-Client 0.09 main/print().("Content−type: text/html\r\n\r\nhello external world"); |
| 40 | } |
| 41 | }, |
| 42 | ); |
| 43 |