Added internal redirect

(Is there a way to get content_type that wouldn't require File::MMagic?)
Apache2::SubRequest's method lookup_file coused segfault in apache, so I scrapped that and used File::MMagic to to content type determing
Also fixed credit and added a currentPage.rankIsN variable to navigation
This commit is contained in:
Jukka Raimovaara 2006-04-30 13:07:00 +00:00
parent a9c3387cb1
commit 1f78c2b077
8 changed files with 58 additions and 5 deletions

View file

@ -29,6 +29,7 @@ use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(OK DECLINED NOT_FOUND DIR_MAGIC_TYPE);
use Apache2::ServerUtil ();
use File::MMagic;
#-------------------------------------------------------------------
@ -104,6 +105,21 @@ sub contentHandler {
$output = page($session);
}
$session->http->setCookie("wgSession",$session->var->{_var}{sessionId}) unless $session->var->{_var}{sessionId} eq $session->http->getCookies->{"wgSession"};
my $filename = $session->http->getStreamedFile();
# print STDERR "file $filename and setting ".$session->config->get("enableStreamingUploads")."!\n";
if ((defined $filename) && ($session->config->get("enableStreamingUploads") eq "1")) {
#my $subr = $r->lookup_file($filename,$r->output_filters);
my $mm = new File::MMagic;
my $ct = $mm->checktype_filename($filename);
my $oldContentType = $r->content_type($ct);
# print STDERR "contenttype ".$r->content_type()."!\n";
if ($r->sendfile($filename) ) {
return Apache2::Const::OK();
} else {
$r->content_type($oldContentType);
}
}
$session->http->sendHeader();
unless ($session->http->isRedirect()) {
$session->output->print($output);