Welcome! Log In Create A New Profile

Advanced

Re: Issues with Location: header in perl module

May 12, 2009 01:28AM
On Mon, May 11, 2009 at 01:54:02PM -0700, Michael Shadle wrote:

> trying to use nginx's built-in perl stuff... here's an example. any
> clue why this doesn't work?
>
> in /etc/nginx/nginx.conf:
>
> http {
> perl_modules /etc/nginx/perl/lib;
> perl_require Foo.pm;
> server {
> listen 80;
> server_name hostname.com;
>
> location / {
> perl Foo::handler;
> }
> }
> }
>
>
> in perl/lib/Foo.pm:
>
> package Foo;
> use nginx;
> sub handler
> {
>
> my $r = shift;
> $r->send_http_header("text/html");
>
> $r->header_out('Location', 'http://www.google.com/');
> return HTTP_MOVED_TEMPORARILY;
>
> }
>
> 1;
> __END__
>
> the Location: header is set but browser does not accept it. browser
> sits there indefinately. no infinite loop, just seems to sit there
> doing nothing

The headers should be set before $r->send_http_header().
Try

$r->header_out('Location', 'http://www.google.com/');
$r->send_http_header("text/html");
return OK;

or

$r->header_out('Location', 'http://www.google.com/');
return HTTP_MOVED_TEMPORARILY;


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Issues with Location: header in perl module

mike May 11, 2009 04:54PM

Re: Issues with Location: header in perl module

坏人 May 11, 2009 11:42PM

Re: Issues with Location: header in perl module

mike May 11, 2009 11:59PM

Re: Issues with Location: header in perl module

坏人 May 12, 2009 04:02AM

Re: Issues with Location: header in perl module

raptium May 12, 2009 12:24AM

Re: Issues with Location: header in perl module

Igor Sysoev May 12, 2009 01:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 205
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready