By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

Simple http redirect is failing with Perl 5.8.9 and IIS6

P: 3
We recently started a move of our web sites to Server 2003 from 2000 while upgrading Perl from 5.6 to 5.8. Most of our web sites use a simple perl script that redirects a web client to a login page. Under 5.6.1 we used:
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. print "Location: ./cgi-bin/PromptEID.pl\n\n";
  3. exit(0);
  4.  
Using Perl 5.8 this fails, produces no output and never does the redirect.

we had to change the code to:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use CGI;
  3.  
  4. my $q = CGI->new;
  5. print $q->redirect ("./cgi-bin/promptEID.pl");
  6. exit(0);
This works fine. We've been trying to find out what changed in Perlis.dll between 5.6.1 and 5.8.9 and I can't find a thing. Any help is appreciated.
Jun 28 '10 #1
Share this Question
Share on Google+
6 Replies


Expert Mod 100+
P: 589
You can find the change logs here: http://perldoc.perl.org/index-history.html
Jun 29 '10 #2

Expert Mod 100+
P: 589
You should reread this portion of the CGI doc.
http://search.cpan.org/~lds/CGI.pm-3...RECTION_HEADER

The key part is this:
You should always use full URLs (including the http: or ftp: part) in redirection requests. Relative URLs will not work correctly.
It might be better to say "Relative URLs will have unpredictable and unreliable results".
Jun 29 '10 #3

P: 3
@RonB
We still don't have a definative answer why our redirect command ( print "Location: ./cgi-bin/nli.pl\n\n";) ran under 5.6 and failed under 5.8. A couple of our programmers didn't like loading the CGI module so came up with:

Expand|Select|Wrap|Line Numbers
  1.  print "Status: 302 Moved\n";
  2.     print "Location: ./cgi-bin/nli.pl\n\n";
and it seems to have fixed the problem with redirection on the new web servers.
Actually, you only need a 3xx code after status - no text afterward is even required.

Simpler and less code.
Jul 1 '10 #4

Expert Mod 100+
P: 589
Yes that will work, but it's recommended to use the full URL instead of the relative path when doing redirects. One reason being that if you're using a proxy server, that proxy server is allowed to alter the relative url path (adding its hostname). It also may forward the request to another proxy server and that server may/can alter relative urls.

What reasons do your programmers have for not wanting to load/use the CGI module? Is their objection the added overhead when the script is only doing a redirect and nothing more, or is their objection more broad?
Jul 1 '10 #5

P: 3
@RonB
Since CGI is a pretty big module and this redirect is on the home page of multiple web sites they were concerned about the overhead and performance penalties. BTW thanks your your replies.
Jul 1 '10 #6

Expert Mod 100+
P: 589
For simple redirects and nothing more, then I'd agree that using the CGI module would be overkill.

But if you're doing more involved things, then IMO it's a must, especially for form processing.
Jul 1 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.