Simple http redirect is failing with Perl 5.8.9 and IIS6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jbach
    New Member
    • Jun 2010
    • 3

    Simple http redirect is failing with Perl 5.8.9 and IIS6

    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:
    Code:
    use strict;
    print "Location: ./cgi-bin/PromptEID.pl\n\n";
    exit(0);
    Using Perl 5.8 this fails, produces no output and never does the redirect.

    we had to change the code to:

    Code:
    use strict;
    use CGI;
    
    my $q = CGI->new;
    print $q->redirect ("./cgi-bin/promptEID.pl");
    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.
    Last edited by numberwhun; Jul 1 '10, 09:44 PM. Reason: Please Use CODE TAGS!
  • RonB
    Recognized Expert Contributor
    • Jun 2009
    • 589

    #2
    You can find the change logs here: http://perldoc.perl.org/index-history.html

    Comment

    • RonB
      Recognized Expert Contributor
      • Jun 2009
      • 589

      #3
      You should reread this portion of the CGI doc.


      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".

      Comment

      • jbach
        New Member
        • Jun 2010
        • 3

        #4
        Originally posted by RonB
        You can find the change logs here: http://perldoc.perl.org/index-history.html
        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:

        Code:
         print "Status: 302 Moved\n";
            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.
        Last edited by numberwhun; Jul 1 '10, 09:45 PM. Reason: Please Use CODE TAGS!

        Comment

        • RonB
          Recognized Expert Contributor
          • Jun 2009
          • 589

          #5
          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?

          Comment

          • jbach
            New Member
            • Jun 2010
            • 3

            #6
            Originally posted by RonB
            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?
            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.

            Comment

            • RonB
              Recognized Expert Contributor
              • Jun 2009
              • 589

              #7
              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.

              Comment

              Working...