Issues with Location: header in perl module
Michael Shadle
mike503 at gmail.com
Tue May 12 00:54:02 MSD 2009
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
More information about the nginx
mailing list