这工作正常(重定向到不同的域):
#! /usr/bin/perl
print "Location:http://AnyDomainBesidesMyOwn.com/\n\n";
close(STDOUT); close(STDIN); close(STDERR);
[some long process]
但是以下方式会使浏览器停止,拒绝重定向,直到漫长的过程完成。上面唯一的变化是我重定向到运行脚本的同一域上的另一个页面。
#! /usr/bin/perl
print "Location:http://MyOwnDomain.com/\n\n";
close(STDOUT); close(STDIN); close(STDERR);
[some long process]
我知道我可以通过分叉一个新进程来让它工作,但必须有一个更简单的方法......对吗?
更新:这是我从 Firefox 中的 Live Headers 获得的输出:
http://example.com/test3.cgi
GET /test3.cgi HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 302 Found
Date: Sun, 27 Jan 2013 23:31:49 GMT
Server: Apache
Location: http://example.com/
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 187
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
然后在它设计重定向之后:
http: //example.com/ [Have to include the space b/c stackoverflow limits the number of links I can include in a post]
GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 200 OK
Date: Sun, 27 Jan 2013 23:31:54 GMT
Server: Apache
Accept-Ranges: bytes
X-Mod-Pagespeed: 0.10.21.2-1381 [Same problem even on a domain w/o pagespeed installed]
Vary: Accept-Encoding
Content-Encoding: gzip
MS-Author-Via: DAV
Cache-Control: max-age=0, no-cache
Content-Length: 12189
Keep-Alive: timeout=2, max=99
Connection: Keep-Alive
Content-Type: text/html