May 11, 2009 04:54PM
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


2009/05/11 13:29:42 [debug] 2761#0: *1 write new buf t:1 f:0
000000000E912518, pos 000000000E912518, size: 205 file: 0, size: 0
2009/05/11 13:29:42 [debug] 2761#0: *1 http write filter: l:0 f:0 s:205
2009/05/11 13:29:42 [debug] 2761#0: *1 perl sv2str: 04840304 "Location"
2009/05/11 13:29:42 [debug] 2761#0: *1 perl sv2str: 04840304
"http://www.google.com"
2009/05/11 13:29:42 [debug] 2761#0: *1 call_sv: 302
2009/05/11 13:29:42 [debug] 2761#0: *1 perl handler done: 302
2009/05/11 13:29:42 [debug] 2761#0: *1 http finalize request: 302, "/?" 1
2009/05/11 13:29:42 [debug] 2761#0: *1 http special response: 302, "/?"
2009/05/11 13:29:42 [debug] 2761#0: *1 http set discard body
2009/05/11 13:29:42 [debug] 2761#0: *1 xslt filter header
2009/05/11 13:29:42 [debug] 2761#0: *1 HTTP/1.1 302 Moved Temporarily^M
Server: nginx^M
Date: Mon, 11 May 2009 20:29:42 GMT^M
Content-Type: text/html; charset=utf-8^M
Content-Length: 154^M
Transfer-Encoding: chunked^M
Connection: close^M
Vary: Accept-Encoding^M
Content-Encoding: gzip^M
Location: http://www.google.com^M

2009/05/11 13:29:42 [debug] 2761#0: *1 write old buf t:1 f:0
000000000E912518, pos 000000000E912518, size: 205 file: 0, size: 0
2009/05/11 13:29:42 [debug] 2761#0: *1 write new buf t:1 f:0
000000000E912648, pos 000000000E912648, size: 274 file: 0, size: 0
2009/05/11 13:29:42 [debug] 2761#0: *1 http write filter: l:0 f:0 s:479
2009/05/11 13:29:42 [debug] 2761#0: *1 malloc: 000000000E90BA90:4096
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: 58
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready