Subject: | url() does not behave as expected on IIS |
Date: | Tue, 29 Oct 2013 00:18:52 +0000 |
To: | "bug-CGI.pm [...] rt.cpan.org" <bug-CGI.pm [...] rt.cpan.org> |
From: | Sune Karlsson <Sune.Karlsson [...] oru.se> |
This problem occurs with IIS6 (Windows Server 2003), IIS7 (Windows 7 and Windows Server 2008) and different versions of Perl and CGI.
The following script called as http://XXX/scripts/test.pl?t=t
#----
use CGI;
$q = new CGI;
print $q->header();
print '<html>';
print "<p>Perl version: $^V\n";
print "<p>CGI version: $CGI::VERSION\n";
print '<p>self_url: ' . $q->self_url() . "\n";
print '<p>url: ' . $q->url() . "\n";
print '<p>url(-full=>1): ' . $q->url(-full=>1) . "\n";
print '<p>url(-relative=>1): ' . $q->url(-relative=>1) . "\n";
print '<p>url(-absolute=>1): ' . $q->url(-absolute=>1) . "\n";
print '<p>url(-path_info=>1): ' . $q->url(-path_info=>1) . "\n";
print '<p>url(-path_info=>1,-query=>1): ' . $q->url(-path_info=>1,-query=>1) . "\n";
print '<p>url(-base => 1): ' . $q->url(-base => 1) . "\n";
print '</html>';
#---
Returns
Perl version: v5.16.3
CGI version: 3.63
self_url: http://XXX/scripts/test.pl?t=t
url: http://XXX
url(-full=>1): http://XXX
url(-relative=>1):
url(-absolute=>1):
url(-path_info=>1): http://XXX/scripts/test.pl
url(-path_info=>1,-query=>1): http://XXX/scripts/test.pl?t=t
url(-base => 1): http://XXX
while the documentation leads me to believe that url() and url(-full=>1) should return http://XXX/scripts/test.pl, url(-relative=>1) should return test.pl and url(-absolute=>1) should return /scripts/test.pl.
If the script is called with additional path information, http://XXX/scripts/test.pl/test?t=t, it behaves as expected:
Perl version: v5.16.3
CGI version: 3.63
self_url: http://XXX/scripts/test.pl/scripts/test.pl/test?t=t
url: http://XXX/scripts/test.pl
url(-full=>1): http://XXX/scripts/test.pl
url(-relative=>1): test.pl
url(-absolute=>1): /scripts/test.pl
url(-path_info=>1): http://XXX/scripts/test.pl/scripts/test.pl/test
url(-path_info=>1,-query=>1): http://XXX/scripts/test.pl/scripts/test.pl/test?t=t
url(-base => 1): http://XXX
/Sune
--
Sune Karlsson
Professor of Statistics
Handelshögskolan/Örebro University School of Business
Örebro University, SE-70182 Örebro, Sweden
Phone +46 19 301257/301415
http://www.oru.se/hh/sune_karlsson
http://econpapers.repec.org/RAS/pka1.htm