CGI::Application::FastCGI -> The page isn't redirecting properly???

View: New views
12 Messages — Rating Filter:   Alert me  

CGI::Application::FastCGI -> The page isn't redirecting properly???

by CGI User :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I encounter very strange problem using CGI::Application::FastCGI module.
Firefox browser displays this warning:
"The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address
in a way that will never complete."
when I try to redirect to another page using CGI::Application::Plugin::Redirect
module.

I check session conditions in cgi_prerun method like this:
sub cgiapp_prerun {
     my $self = shift;
     my $rm = $self->get_current_runmode;

     # Get sess_id from URL
     my $url_sess_id = $self->get_sess_id('url');
     my $sess_id = $self->param(('sess_id');

     # 1. No sess_id in URL
     if (!$url_sess_id) {
         $self->delete_old_sess($sess_sess_id) if $sess_sess_id;
         $self->create_new_sess;
         return $self->redirect('warning.html');
     }

     return $self;
}

However, when I switch back to the plane CGI::Application module, everything
works very well.

I'm using fcgid (replacement for fcgi) module with Apache.
I checked my fcgid and Apache configurations. Everything works properly.

If I use CGI::Application::FastCGI module and comment out
'$self->redirect_url('warning.html');' line - the application works correctly.

Could somebody tell me please why CGI::Application::FastCGI module doesn't
redirect to the proper HTML page when CGI::Application does it all the time?

Many thanks in advance,

Alex



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by Ron Savage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alex

>      my $sess_id = $self->param(('sess_id');

There's a syntax error in this line.  What's the real code :-)))?
--
Ron Savage
ron@...
http://savage.net.au/index.html



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by CGI User :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ron,
My bad.
I mistyped it in my email.
The real code is

my $sess_id = $self->param('sess_id');

of course.

Do you have any idea why redirect does work in
CGI::Application and it doesn't in CGI::Application::FastCGI
module?

Thank you in advance,

Alex





Ron Savage wrote:
> Hi Alex
>
>>      my $sess_id = $self->param(('sess_id');
>
> There's a syntax error in this line.  What's the real code :-)))?


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by Dan Horne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


CGI User said:
>
> Do you have any idea why redirect does work in
> CGI::Application and it doesn't in CGI::Application::FastCGI
> module?
>

Hi

It has been reported that there are issues with CGI::Application::FastCGI,
but I don't know if these affect you:

http://www.mail-archive.com/cgiapp@.../msg05359.html

I use CGI::Application and FastCGI without C::A::FastCGI, and make heavy
use of C::A::P::Redirect. If you have any questions on how to use them
together, I'll respond on this list

Dan


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by Ron Savage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alex

On Thu, 2008-05-22 at 18:04 -0700, CGI User wrote:
> Hi Ron,
> My bad.
> I mistyped it in my email.
> The real code is
>
> my $sess_id = $self->param('sess_id');
>
> of course.

I thought so, but it's very frustrating debugging fake code.

Please always copy-and-paste real code.

If you wish to hide stuff, understandbly, delete from the email.

> Do you have any idea why redirect does work in
> CGI::Application and it doesn't in CGI::Application::FastCGI
> module?

Nope.

I use FCGI without problems, but I've never used redirect or
CGI::Application::FastCGI, so I can't help there.
--
Ron Savage
ron@...
http://savage.net.au/index.html



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by CGI User :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Dan,
Thank you very much for your information.
Apparently this C::A::FastCGI "feature" affects me.
I would like to know how to overcome this
C::A::FastCGI bug without wrecking all my application code.

Could you please provide me any link or a sample of code which would show
how to use CGI::Application and FastCGI together, and
especially how to redirect url in cgiapp_prerun method.

Thanks again in advance.

Alex


Dan Horne wrote:

> CGI User said:
>> Do you have any idea why redirect does work in
>> CGI::Application and it doesn't in CGI::Application::FastCGI
>> module?
>>
>
> Hi
>
> It has been reported that there are issues with CGI::Application::FastCGI,
> but I don't know if these affect you:
>
> http://www.mail-archive.com/cgiapp@.../msg05359.html
>
> I use CGI::Application and FastCGI without C::A::FastCGI, and make heavy
> use of C::A::P::Redirect. If you have any questions on how to use them
> together, I'll respond on this list
>
> Dan
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Parent Message unknown Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by Todd Ross-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Probably unrelated, I'm not really familiar with FastCGI, but this doesn't look right to me:

     my $sess_id = $self->param('sess_id'); // removed extra paren as others pointed out

     if (!$url_sess_id) {
         $self->delete_old_sess($sess_sess_id) if $sess_sess_id;

What is $sess_sess_id?  Are you using strict and warnings?

What does Firebug, Live HTTP Headers, and/or Tamper Data show as the response (include headers) for the redirect?

Todd


----- Original Message ----
From: CGI User <cgiapp@...>
To: CGI Application <cgiapp@...>
Sent: Thursday, May 22, 2008 7:00:22 PM
Subject: [cgiapp] CGI::Application::FastCGI -> The page isn't redirecting properly???

Hello,

I encounter very strange problem using CGI::Application::FastCGI module.
Firefox browser displays this warning:
"The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address
in a way that will never complete."
when I try to redirect to another page using CGI::Application::Plugin::Redirect
module.

I check session conditions in cgi_prerun method like this:
sub cgiapp_prerun {
     my $self = shift;
     my $rm = $self->get_current_runmode;

     # Get sess_id from URL
     my $url_sess_id = $self->get_sess_id('url');
     my $sess_id = $self->param(('sess_id');

     # 1. No sess_id in URL
     if (!$url_sess_id) {
         $self->delete_old_sess($sess_sess_id) if $sess_sess_id;
         $self->create_new_sess;
         return $self->redirect('warning.html');
     }

     return $self;
}

However, when I switch back to the plane CGI::Application module, everything
works very well.

I'm using fcgid (replacement for fcgi) module with Apache.
I checked my fcgid and Apache configurations. Everything works properly.

If I use CGI::Application::FastCGI module and comment out
'$self->redirect_url('warning.html');' line - the application works correctly.

Could somebody tell me please why CGI::Application::FastCGI module doesn't
redirect to the proper HTML page when CGI::Application does it all the time?

Many thanks in advance,

Alex



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:  http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


     

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by CGI User :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Todd,

In my application session ID has four sources. It is embedded in the template
$tmpl_sess_id, stored in database $sess_sess_id, derived from URL string as
$url_sess_id and available via $self->param() function as $sess_id;

This partial piece of code which brought your attention does not represent the
complete code for the whole session validation algorithm.
I'm sorry for your confusion, but the whole thing works OK if I use
CGI::Application module, and it doesn't if I use CGI::Application::FastCGI.
That was the primary reason for my initial posting.

Alex


Todd Ross wrote:

> Probably unrelated, I'm not really familiar with FastCGI, but this doesn't look right to me:
>
>      my $sess_id = $self->param('sess_id'); // removed extra paren as others pointed out
>
>      if (!$url_sess_id) {
>          $self->delete_old_sess($sess_sess_id) if $sess_sess_id;
>
> What is $sess_sess_id?  Are you using strict and warnings?
>
> What does Firebug, Live HTTP Headers, and/or Tamper Data show as the response (include headers) for the redirect?
>
> Todd
>
>
> ----- Original Message ----
> From: CGI User <cgiapp@...>
> To: CGI Application <cgiapp@...>
> Sent: Thursday, May 22, 2008 7:00:22 PM
> Subject: [cgiapp] CGI::Application::FastCGI -> The page isn't redirecting properly???
>
> Hello,
>
> I encounter very strange problem using CGI::Application::FastCGI module.
> Firefox browser displays this warning:
> "The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for this address
> in a way that will never complete."
> when I try to redirect to another page using CGI::Application::Plugin::Redirect
> module.
>
> I check session conditions in cgi_prerun method like this:
> sub cgiapp_prerun {
>      my $self = shift;
>      my $rm = $self->get_current_runmode;
>
>      # Get sess_id from URL
>      my $url_sess_id = $self->get_sess_id('url');
>      my $sess_id = $self->param(('sess_id');
>
>      # 1. No sess_id in URL
>      if (!$url_sess_id) {
>          $self->delete_old_sess($sess_sess_id) if $sess_sess_id;
>          $self->create_new_sess;
>          return $self->redirect('warning.html');
>      }
>
>      return $self;
> }
>
> However, when I switch back to the plane CGI::Application module, everything
> works very well.
>
> I'm using fcgid (replacement for fcgi) module with Apache.
> I checked my fcgid and Apache configurations. Everything works properly.
>
> If I use CGI::Application::FastCGI module and comment out
> '$self->redirect_url('warning.html');' line - the application works correctly.
>
> Could somebody tell me please why CGI::Application::FastCGI module doesn't
> redirect to the proper HTML page when CGI::Application does it all the time?
>
> Many thanks in advance,
>
> Alex
>
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:  http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>
>      
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Using CGI::Application with FastCGI and C::A::P::Redirect

by Dan Horne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alex

As requested. You instance script should look something like:

#!/usr/bin/perl -w
use strict;
use FindBin qw($B
use Webapp;
use CGI::Fast();

while (my $q = new CGI::Fast){
    my $webapp = Webapp->new(
        QUERY  => $q,
    );
    $webapp->run();
}

In you application class simply put "return $self->redirect(<URL>)" in
our runmodes as you would without FastCGI

Dan

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: CGI::Application::FastCGI -> The page isn't redirecting properly???

by Alexandr Ciornii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.

Is 'warning.html' a real page or it is generated with
CGI::Application? If it is generated, you should try patch from
http://rt.cpan.org/Public/Bug/Display.html?id=17736, I checked it and
it is really necessary - without it redirect header is repeated on
next request.

2008/5/23 CGI User <cgiapp@...>:

> I encounter very strange problem using CGI::Application::FastCGI module.
> Firefox browser displays this warning:
> "The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for this
> address in a way that will never complete."
> when I try to redirect to another page using
> CGI::Application::Plugin::Redirect module.
>
>        return $self->redirect('warning.html');
>    }
>
>    return $self;
> }

--
Alexandr Ciornii, http://chorny.net

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: SOLVED -> Using CGI::Application with FastCGI and C::A::P::Redirect

by CGI User :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you Dan and everybody who replied to my postings.
It was a really CGI::Application::FastCGI module problem and
the easy fix for it is to include additional header directives into
cgiapp_prerun method as shown below.

sub cgiapp_prerun {
       my $self = shift;

       # This is a fix for FastCGI mode
       # http://rt.cpan.org/Public/Bug/Display.html?id=17736
       $self->header_type('header');
       $self->header_props( {} );

. . . .

The rest of the code

. . . .

       return $self;
}

Now everything is working correctly in plain CGI and FastCGI modes.
Thanks again to everyone who tried to help me,

Alex



Dan Horne wrote:

> Hi Alex
>
> As requested. You instance script should look something like:
>
> #!/usr/bin/perl -w
> use strict;
> use FindBin qw($B
> use Webapp;
> use CGI::Fast();
>
> while (my $q = new CGI::Fast){
>    my $webapp = Webapp->new(
>        QUERY  => $q,
>    );
>    $webapp->run();
> }
>
> In you application class simply put "return $self->redirect(<URL>)" in
> our runmodes as you would without FastCGI
>
> Dan
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Using CGI::Application with FastCGI and C::A::P::Redirect

by Ron Savage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Folks

Just for the record, here's a similar program to Dan's, but using
FCGI::ProcManager:

> #!/usr/bin/perl -w
> use strict;
> use FindBin qw($B
> use Webapp;
> use CGI::Fast();
>
> while (my $q = new CGI::Fast){
>     my $webapp = Webapp->new(
>         QUERY  => $q,
>     );
>     $webapp->run();
> }
>
> In you application class simply put "return $self->redirect(<URL>)" in
> our runmodes as you would without FastCGI
>
> Dan

#!/usr/bin/perl

use strict;
use warnings;

use CGI::Application::Dispatch;
use CGI::Fast;
use FCGI::ProcManager;

# ---------------------

my($proc_manager) = FCGI::ProcManager -> new({processes => 2});

$proc_manager -> pm_manage();

my($cgi);

while ($cgi = CGI::Fast -> new() )
{
        $proc_manager -> pm_pre_dispatch();
        CGI::Application::Dispatch -> dispatch
        (
         args_to_new => {QUERY => $cgi},
         prefix      => 'Local::Application',
         table       =>
         [
          ''         => {app => 'main-menu', rm => 'menu'},
          ':app/:rm' => {},
         ],
        );
        $proc_manager -> pm_post_dispatch();
}

You need the {QUERY => $cgi} code to get access to user-submitted CGI
form variables and their values, since they are captured by the $cgi
object, and so are not available to the default CGI::App $self ->
query() object.

The code above makes the $self -> query() call return the very same $cgi
variable returned by CGI::Fast.

--
Ron Savage
ron@...
http://savage.net.au/index.html



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################