Hi,I want to develop a script like this:the script randomly send a html page or mp3 file, but I met some problems,#!/usr/bin/perl
use Apache;
my $r=Apache->request;my @file = ( { '/1.mp3' => 'audio/mpeg' },
{ '/aaa.html' => 'text/html' },
{ '/bbb.html' => 'text/html' },
{ '/1.png' => 'image/png'}
);my $idx = int rand(4);
my @ks = keys %{$file[$idx]};
my $key = shift @ks;warn("$file[$idx]{$key} -- $key"); # log
$r->content_type($file[$idx]{$key}); # content-type
#$r->send_http_header; # this seems can be omited$r->internal_redirect_handler($key); # redirect to file , also tryed "internal_redirect"
#### end
I am using apache1.3.x+mod_perl 1.29
<IfModule mod_perl.c>
PerlModule Apache::Registry
<IfModule mod_alias.c>
Alias /perl/ /var/www/perl/
</IfModule>
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Location>
</IfModule>the url is http://192.168.0.1/rand/asd.mp3 , rand is the script name, asd.mp3 is just a fake path_info.
tested with MSIE6 and firefox2 on windowsXP-pro-sp2,
firefox2 works fine, when mp3 file reached, it ask for download or play
MSIE6 sometimes works,
but sometimes:
1. sometimes text file was processed by windows mediaplayer
2. sometimes png file was processed by windows mediaplayer
3. sometimes mp3 file was showed as text file, (losts of non-string char in IE)and I am sure the content-type is sended correctly (watching the log warn)
are the problems as IE6 natures ?
is there any other proper way to do this ?
question 2:
with mod_perl2, internal_redirect seems can access system file, such as /etc/*, but mod_perl1 seems can only access files under apache documentroot
right ?
thanks!
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.