[Catalyst] Redirects not working under Catalyst with Debian server in IE

J. Shirley jshirley at gmail.com
Mon Dec 29 17:21:33 GMT 2008


On Mon, Dec 29, 2008 at 9:02 AM, Giancarlo Corcuera
<giancarlo at capybara-software.com> wrote:
>
>
> J. Shirley wrote:
>>
>> On Mon, Dec 29, 2008 at 8:36 AM, Giancarlo Corcuera
>> <giancarlo at capybara-software.com> wrote:
>>
>>>
>>> Sorry, if you referred to this...
>>>
>>> Here is my login method:
>>>
>>> sub login :Chained('lang') :PathPart('sign_in') :Args(0) :Form {
>>>  my ($self, $c) = @_;
>>>    my $url_language = $c->stash->{'language'};
>>>  my $lang_id = $c->stash->{'language_id'};
>>>    my $form_data = load_tags($c,'fe_login_form', $lang_id);
>>>  $c->stash->{'page_title'} = $form_data->{'form_title'};
>>>    my $form = $self->formbuilder->new(
>>>      {
>>>          'source' => $c->config->{'home'}.'/root/forms/login/login.fb',
>>>          'title'  => $form_data->{'form_title'},
>>>          'submit' => $form_data->{'sign_in'},
>>>          'header' => 0
>>>      } );
>>>    $form->field(
>>>      'name'  => 'username',
>>>      'label' => $form_data->{'username'}
>>>  );
>>>    $form->field(
>>>      'name'  => 'password',
>>>      'label' => $form_data->{'password'}
>>>  );
>>>    $form->field(
>>>      'name' => 'qr_submit',
>>>      'type' => 'hidden'
>>>  );
>>>    if ( $form->submitted && $form->validate ) {
>>>      my $qr_submit = $form->field('qr_submit') || 0;
>>>            if ( $c->login( $form->field('username'),
>>> $form->field('password') ) ) {
>>>                    $c->session->{'user_id'}   = $c->user->user_id;
>>>          $c->session->{'is_client'} = $c->user->is_client;
>>>                    if ( $c->user->is_client eq 'Y' ) {
>>>                            $c->session->{'user_cty'} =
>>> $c->user->b_customer_id->
>>>                  b_country_id->country_code;
>>>
>>> $c->forward('set_currency_format',[$c->session->{'user_cty'}]);
>>>                            $url_language =
>>> $c->user->b_customer_id->b_country_id
>>>                  ->language_iso;
>>>                        }
>>>          else {
>>>                            $c->session->{'user_cty'} = 'US';
>>>              $c->forward('set_currency_format', ['US']);
>>>                        };
>>>                    $c->forward('user_roles', [$c->user->user_id]);
>>>          $c->forward('lang_session',[]);
>>>                }
>>>      else {
>>>                    if ( $qr_submit == 1 ) {
>>>                            $c->flash->{'login_username'} =
>>> $form->field('username');
>>>                            $c->flash->{'login_qr'} = 1;
>>>              $c->flash->{'login_error'} = $form_data->{'error_message'};
>>>                            $c->session->{'rq'} = undef;
>>>             _*
>>>  $c->res->redirect($c->uri_for("/$url_language/quotes/edit"));
>>>              $c->detach();*_
>>>                        };
>>>                    $c->flash->{'error'} = $form_data->{'error_message'};
>>>         _*
>>>  $c->res->redirect($c->uri_for("/$url_language/sign_in"));
>>>          $c->detach();*_
>>>                };
>>>            if ( $qr_submit == 1 ) {
>>>                    $c->session->{'rq'} = undef;
>>> _*
>>>  $c->res->redirect($c->uri_for("/$url_language/quotes/edit"));
>>>          $c->detach();*_
>>>                };
>>>            if ( $c->user->is_client eq 'N' ) {
>>>         _*            $c->res->redirect($c->uri_for('/administrator'));
>>>          $c->detach();*_
>>>                }
>>>      else {
>>>                    $c->session->{'rq'} = undef;
>>> _*                     $c->res->redirect($c->uri_for("/$url_language"));
>>>          $c->detach();*_
>>>                };
>>>        };
>>>    $c->stash->{'path'}     = $c->request->{'path'};
>>>  $c->stash->{'template'} = 'login.tt2';
>>> };
>>>
>>> after some operations and/or validations (which are working perfectly)
>>> none
>>> of the redirects works in IE but it does on Firefox.
>>>
>>> Thanks,
>>>
>>> Giancarlo
>>>
>>>
>>> J. Shirley wrote:
>>>
>>>>
>>>> On Mon, Dec 29, 2008 at 8:06 AM, Giancarlo Corcuera
>>>> <giancarlo at capybara-software.com> wrote:
>>>>
>>>>
>>>>>
>>>>> I made an application that works fine in the Debian server with
>>>>> catalyst.
>>>>> The problem comes when I use any redirect inside a controller module.
>>>>>
>>>>> For example:
>>>>> When I sign in the application redirects me to the appropiate page
>>>>> according
>>>>> to the user type but in IE it doesn't redirect and showed an error page
>>>>> that
>>>>> states "IE can't show the desired page". So after I press back and
>>>>> ctrl+F5 I
>>>>> can see that the session is already created so the user is now logged
>>>>> in
>>>>> the
>>>>> system.
>>>>>
>>>>> Any advice will be appreciated,
>>>>>
>>>>> Regards,
>>>>>
>>>>> Giancarlo Corcuera
>>>>>
>>>>>
>>>>>
>>>>
>>>> Hi there,
>>>>
>>>> Please paste in the controller code that is relevant.
>>>>
>>>> Thanks,
>>>> -Jay
>>>>
>>>>
>>
>> (Thank you for bottom posting after this :))
>>
>> In the Catalyst output debug messages, it should say "Redirecting to
>> [URL]" when the redirect happens.  Make sure that the URL is specified
>> in that message.
>>
>> The redirect code itself looks legitimate, but I'm not sure if the 302
>> status code (which is the default on $c->res->redirect) is what you
>> want.  Try setting it to 303 (See
>> http://en.wikipedia.org/wiki/List_of_HTTP_status_codes for more
>> details) and try again.  The syntax for this is simply doing:
>> $c->res->redirect( $uri, 303 );  By default Catalyst uses 302.
>>
>> The other thing to try is to verify that the Response headers are
>> being sent out the way that you expect them to.  Try installing
>> Wireshark (http://www.wireshark.org/) and inspect the HTTP headers
>> between requests in Firefox and IE; compare any differences.
>>
>> Hope this helps,
>> -J
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive:
>> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>>
>
> One more thing that I find unusual:
> Ubuntu server with catalyst: I don't have that problem in any browser (I've
> triedd on firefox, IE, chrome, safari and opera)
> Debian server with catalyst: everyone failed but Firefox.
>
> So maybe could be some stuff in my server but I'm not sure, that's why I'm
> asking for any advice or known issue in this topic.
>
> Thanks for your quick responses,
>
> Giancarlo
>

Ah, ok, in that case I'm guessing you are running a rather old version
of Catalyst::Runtime -- try upgrading Catalyst from CPAN:
$ cpan Catalyst::Runtime

That will update, and should fix your issue.

-J



More information about the Catalyst mailing list