in t/modules/proxy_fcgi.t [109:144]
sub run_fcgi_envvar_request
{
my $fcgi_port = shift;
my $uri = shift;
my $backend = shift || "FCGI";
# Launch the FCGI process.
my $child = launch_envvar_echo_daemon($fcgi_port) unless ($fcgi_port <= 0) ;
# Hit the backend.
my $r = GET($uri);
ok t_cmp($r->code, 200, "proxy to $backend backend works (" . $uri . ")");
# Split the returned envvars into a dictionary.
my %envs = ();
foreach my $line (split /\n/, $r->content) {
t_debug("> $line"); # log the response lines for debugging
my @components = split /=/, $line, 2;
$envs{$components[0]} = $components[1];
}
if ($fcgi_port > 0) {
if ($r->code eq '500') {
# Unknown failure, probably the request didn't hit the FCGI child
# process, so it will hang waiting for our request
kill 'TERM', $child;
} else {
# Rejoin the child FCGI process.
waitpid($child, 0);
}
}
return \%envs;
}