Commit 4c1e9158 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Adding debug log for CGI variables, and tests.

parent 3761cb68
......@@ -31,6 +31,7 @@ check_SCRIPTS = \
t/Language.t \
t/LockedFile.t \
t/Regexps.t \
t/WWW_Tools.t \
t/compile_modules.t \
t/compile_executables.t \
t/compile_scenarios.t \
......
......@@ -1107,6 +1107,15 @@ while ($query = Sympa::WWW::FastCGI->new) {
## Though I don't know why, __DIE__ handler is cleared after INIT.
Sympa::Crash::register_handler();
 
foreach my $envvar (
qw(ORIG_PATH_INFO ORIG_SCRIPT_NAME
PATH_INFO QUERY_STRING REMOTE_ADDR REMOTE_HOST REQUEST_METHOD
SCRIPT_NAME SERVER_NAME SERVER_PORT
SYMPA_DOMAIN)
) {
$log->syslog('debug', '%s=%s', $envvar, $ENV{$envvar});
}
## Get params in a hash
%in = $query->Vars;
 
......@@ -1940,8 +1949,6 @@ sub _crash_handler {
sub _split_params {
my $args_string = shift;
 
$log->syslog('debug', "PATH_INFO: %s", $ENV{'PATH_INFO'});
$args_string =~ s+^/++;
 
my $ending_slash = 0;
......
......@@ -42,6 +42,8 @@ sub new {
# N.B. As of 6.2.34, wwsympa_url parameter may be optional.
my @vars = Sympa::WWW::Tools::get_robot('http_host', 'wwsympa_url');
if (@vars) {
@ENV{qw(ORIG_SCRIPT_NAME ORIG_PATH_INFO)} =
@ENV{qw(SCRIPT_NAME PATH_INFO)};
@ENV{qw(SYMPA_DOMAIN SCRIPT_NAME PATH_INFO)} = @vars;
} else {
delete $ENV{SYMPA_DOMAIN};
......
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
use strict;
use warnings;
use English qw(-no_match_vars);
use File::Path qw(make_path rmtree);
use Test::More;
BEGIN {
use_ok 'Sympa::WWW::Tools';
}
# get_robot()
%Conf::Conf = (
domain => 'mail.example.org',
listmaster => 'listmaster@example.org',
wwsympa_url => 'http://web.example.org/sym/pa',
etc => 't/tmp/etc',
);
make_path $Conf::Conf{'etc'} or die $ERRNO;
$ENV{SERVER_NAME} = 'web.example.org';
$ENV{SCRIPT_NAME} = '/sym/pa';
$ENV{PATH_INFO} = undef;
is_deeply [Sympa::WWW::Tools::get_robot('wwsympa_url')],
['mail.example.org', '/sym/pa', ''],
'SCRIPT_NAME & empty PATH_INFO';
$ENV{SERVER_NAME} = 'web.example.org';
$ENV{SCRIPT_NAME} = '/sym/pa';
$ENV{PATH_INFO} = '/help';
is_deeply [Sympa::WWW::Tools::get_robot('wwsympa_url')],
['mail.example.org', '/sym/pa', '/help'],
'SCRIPT_NAME & non-empty PATH_INFO';
$ENV{SERVER_NAME} = 'web.example.org';
$ENV{SCRIPT_NAME} = '/sym';
$ENV{PATH_INFO} = '/pa/help';
is_deeply [Sympa::WWW::Tools::get_robot('wwsympa_url')],
['mail.example.org', '/sym/pa', '/help'],
'split script-path (e.g. mod_proxy_fcgi on httpd)';
$ENV{SERVER_NAME} = 'web.example.org';
$ENV{SCRIPT_NAME} = '/sym/pa/help';
$ENV{PATH_INFO} = undef;
is_deeply [Sympa::WWW::Tools::get_robot('wwsympa_url')],
['mail.example.org', '/sym/pa', '/help'],
'no PATH_INFO (e.g. nginx without fastcgi_split_path_info)';
done_testing();
rmtree 't/tmp';
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment