Professional Web Applications Themes

CGI.pm and ModPerl::Registry - PERL Modules

My site has been humming along in blissful ignorance of the latest Perl happenings for several years, running Perl 5.6.0, Apache 1.3, and whatever version of mod_perl was current. I use CGI.pm to do request parsing and response output, because the whole site used to be <shudder> CGI scripts. I'm in the process of upgrading to Perl 5.8.8, Apache 2.0, and ModPerl::Registry, and CGI.pm v3.29. Right now, all the redirects I do that follow POSTs are broken. They produce status 200 instead of status 303 that I coded for. Any ideas why or other advice? Thanks very much. Here's a ...

  1. #1

    Default CGI.pm and ModPerl::Registry

    My site has been humming along in blissful ignorance of the latest
    Perl happenings for several years, running Perl 5.6.0, Apache 1.3, and
    whatever version of mod_perl was current. I use CGI.pm to do request
    parsing and response output, because the whole site used to be
    <shudder> CGI scripts.

    I'm in the process of upgrading to Perl 5.8.8, Apache 2.0, and
    ModPerl::Registry, and CGI.pm v3.29.
    Right now, all the redirects I do that follow POSTs are broken. They
    produce status 200 instead of status 303 that I coded for. Any ideas
    why or other advice?
    Thanks very much.

    Here's a stripped down bit of sample code:

    my headerargs = ('-cookie', $my_cookie) if $my_cookie;

    my redirargs =
    ('-Status', '303 See Other',
    '-Location', $forward_url,
    '-URL', $forward_url);

    push (headerargs, redirargs);
    print $cgi->header(headerargs);

    # print some text ...

    exit();


    -Steve
    steve.yost@gmail.com Guest

  2. #2

    Default Re: CGI.pm and ModPerl::Registry

    On 2007-12-22, com <com> wrote: 

    The CGI.pm doentation suggests to use redirect rather than header
    to creating redirections, so something along the lines of:

    print $cgi->redirect(-uri=>$otherurl, -status=>303)

    should work.

    C

    --
    The address in the "From" header won't work. Email to "usenet" at "intercal" dot
    "dyn-o-saur" dot "com" may or may not reach me, depending on how far it manages
    to go through the spam filter, and other conditions which I won't disclose.
    Claudio Guest

  3. #3

    Default Re: CGI.pm and ModPerl::Registry

    On Dec 22, 2:06 am, Claudio Calvelli
    <zxcvbnm.not> wrote: 
    >
    > The CGI.pm doentation suggests to use redirect rather than header
    > to creating redirections, so something along the lines of:
    >
    > print $cgi->redirect(-uri=>$otherurl, -status=>303)
    >
    > should work.
    >
    > C[/ref]


    Thanks for the reply, Claudio. That didn't help, but I did find that
    the problem was resolved by not printing any text after the header.
    Apparently with text printed, CGI.pm reverts that status back to 200,
    which seems reasonable. If you're redirecting, you shouldn't need any
    text, and if you succesfully produce a web page, it's reasonable that
    the status be 200.
    So the status was coming through as 200 but there was a location in
    the http header, which let to the result being a page that said:

    OK
    The answer to your request is located here

    with *here* being a link to the url I was forwarding to.

    The text was legacy support for browsers that might not support
    forwarding (my service has been around since 1999!).

    Hope all this helps anyone else that runs into this problem.

    Steve
    steve.yost@gmail.com Guest

  4. #4

    Default Re: CGI.pm and ModPerl::Registry

    On 2007-12-22, com <com> wrote: 

    It looks like it's mod_perl which does that.

    I put the following script both in $DOENTROOT/cgi-bin/test.cgi and
    $DOENTROOT/perl/test.cgi:

    ---- cut here ---- script ----
    #!/usr/bin/perl -w
    use strict;
    use CGI;

    my $cgi = new CGI;
    my $location = 'http://www.some-otherp-lace.com/';

    print $cgi->redirect( -uri => $location, -status => 303);
    print "... and if you aren't automatically redirected, see <a href=\"$location\">here</a>\n";
    ---- cut here ----

    The cgi-bin version works as expected:

    ----
    GET /cgi-bin/test.cgi HTTP/1.0

    HTTP/1.1 303 See Other
    Date: Sat, 22 Dec 2007 21:02:58 GMT
    Server: Apache
    Location: http://www.some-otherp-lace.com/
    Connection: close
    Content-Type: text/plain

    .... and if you aren't automatically redirected, see <a href="http://www.some-otherp-lace.com/">here</a>
    ----

    The mod_perl version changes the 303 to 200:

    ----
    GET /perl/test.cgi HTTP/1.0

    HTTP/1.1 200 OK
    Date: Sat, 22 Dec 2007 21:05:05 GMT
    Server: Apache
    Location: http://www.some-otherp-lace.com/
    Connection: close
    Content-Type: text/plain

    .... and if you aren't automatically redirected, see <a href="http://www.some-otherp-lace.com/">here</a>
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>200 OK</title>
    </head><body>
    <h1>OK</h1>
    <p>The answer to your request is located <a href="http://www.some-otherp-lace.com/">here</a>.</p>
    </body></html>
    ----

    Note how the status becomes 200, and a whole new doent with the redirect
    is added after the text!

    C
    --
    The address in the "From" header won't work. Email to "usenet" at "intercal" dot
    "dyn-o-saur" dot "com" may or may not reach me, depending on how far it manages
    to go through the spam filter, and other conditions which I won't disclose.
    Claudio Guest

  5. #5

    Default Re: CGI.pm and ModPerl::Registry

    On Dec 22, 4:08 pm, Claudio Calvelli
    <zxcvbnm.not> wrote: 

    Precisely. Nice test!

    Thanks,
    Steve
    None Guest

Similar Threads

  1. Registry
    By Dave in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: August 6th, 09:21 PM
  2. Windows Xp registry
    By Manuel in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: August 6th, 07:48 PM
  3. no aol in Registry
    By marie Smith in forum Windows XP/2000/ME
    Replies: 3
    Last Post: July 8th, 08:16 PM
  4. Several questions about ModPerl
    By Kio in forum PERL Modules
    Replies: 0
    Last Post: June 28th, 04:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139