This is cool. Thx. It's inline with what I was hoping to do.
I'm curious though Since we never actually *run* php-fpm on the
PHP script, we never see what PHP actually determines are these
parameters, right?
> On Jun 23, 2017, at 1:50 PM, jchamp...@apache.org wrote:
>
> Author: jchampion
> Date: Fri Jun 23 17:50:31 2017
> New Revision: 1799689
>
> URL: http://svn.apache.org/viewvc?rev=1799689=rev
> Log:
> proxy_fcgi: add regression test for PR61202
>
> Also refactor the FCGI backend daemon and envvar-echo request into a
> callable subroutine.
>
> Added:
>httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/
>httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php (with
> props)
> Modified:
>httpd/test/framework/trunk/t/conf/proxy.conf.in
>httpd/test/framework/trunk/t/modules/proxy_fcgi.t
>
> Modified: httpd/test/framework/trunk/t/conf/proxy.conf.in
> URL:
> http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/proxy.conf.in?rev=1799689=1799688=1799689=diff
> ==
> --- httpd/test/framework/trunk/t/conf/proxy.conf.in (original)
> +++ httpd/test/framework/trunk/t/conf/proxy.conf.in Fri Jun 23 17:50:31 2017
> @@ -63,6 +63,12 @@
> ProxyFCGISetEnvIf true !REMOTE_ADDR
>
>
> +
> +
> +
> +SetHandler proxy:fcgi://127.0.0.1:${FCGI_PORT}
> +
> +
>
>
>
>
> Added: httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php
> URL:
> http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php?rev=1799689=auto
> ==
> --- httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php (added)
> +++ httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php Fri Jun
> 23 17:50:31 2017
> @@ -0,0 +1,3 @@
> + + /* This does nothing; it's just a placeholder. */
> +?>
>
> Propchange: httpd/test/framework/trunk/t/htdocs/modules/proxy/fcgi/index.php
> --
>svn:eol-style = native
>
> Modified: httpd/test/framework/trunk/t/modules/proxy_fcgi.t
> URL:
> http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/proxy_fcgi.t?rev=1799689=1799688=1799689=diff
> ==
> --- httpd/test/framework/trunk/t/modules/proxy_fcgi.t (original)
> +++ httpd/test/framework/trunk/t/modules/proxy_fcgi.t Fri Jun 23 17:50:31 2017
> @@ -5,12 +5,13 @@ use Apache::Test;
> use Apache::TestRequest;
> use Apache::TestUtil;
>
> -plan tests => 7,
> +my $have_fcgisetenvif = have_min_apache_version('2.4.26');
> +
> +plan tests => (7 * $have_fcgisetenvif) + 2,
> need (
> 'mod_proxy_fcgi',
> 'FCGI',
> -'IO::Select',
> -need_min_apache_version('2.4.26')
> +'IO::Select'
> );
>
> require FCGI;
> @@ -76,6 +77,55 @@ sub run_fcgi_handler($$)
> return $pid;
> }
>
> +# Convenience wrapper for run_fcgi_handler() that will echo back the envvars
> in
> +# the response. Returns the child PID; exits on failure.
> +sub launch_envvar_echo_daemon($)
> +{
> +my $fcgi_port = shift;
> +
> +return run_fcgi_handler($fcgi_port, sub {
> +# Echo all the envvars back to the client.
> +print("Content-Type: text/plain\r\n\r\n");
> +foreach my $key (sort(keys %ENV)) {
> +print($key, "=", $ENV{$key}, "\n");
> +}
> +});
> +}
> +
> +# Runs a single request using launch_envvar_echo_daemon(), then returns a
> +# hashref containing the environment variables that were echoed by the FCGI
> +# backend.
> +#
> +# Calling this function will run one test that must be accounted for in the
> test
> +# plan.
> +sub run_fcgi_envvar_request($$)
> +{
> +my $fcgi_port = shift;
> +my $uri = shift;
> +
> +# Launch the FCGI process.
> +my $child = launch_envvar_echo_daemon($fcgi_port);
> +
> +# Hit the backend.
> +my $r = GET($uri);
> +ok t_cmp($r->code, 200, "proxy to FCGI backend works");
> +
> +# 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];
> +}
> +
> +# Rejoin the child FCGI process.
> +waitpid($child, 0);
> +
> +return \%envs;
> +}
> +
> #
> # MAIN
> #
> @@ -85,39 +135,24 @@ sub run_fcgi_handler($$)
> # for the proxy_fcgi vhost is one greater than the reserved FCGI_PORT, but
> # depending on the test conditions, that may not always be the case...
> my $fcgi_port = Apache::Test::vars('proxy_fcgi_port') - 1;
> +my $envs;
>
> -# Launch the FCGI process.
> -my $child = run_fcgi_handler($fcgi_port, sub {
> -# Echo all the envvars back to the