For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2005 > File downloads when I try mod_perl redirect









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File downloads when I try mod_perl redirect
FnBastard

2005-08-28, 6:55 pm

Plat: RedHat, Apache1, mod_perl1

I have the following 2 snippets. The first being a sub from a module,
which redirects. The second being the receiver of the redirect. The
problem is, when it redirects, it forces the browser to download the
file, instead of printing the output of script to the screen. When
this happens, the output is displayed correctly. I also tried sending
the $r->status(REDIRECT). That didn't do anything but make the
response slower. Thanks for any input.

#In Redirect module
sub do_redirect{
#Take in params
my ($url, $r) = @_;
#Get the args from the params
my $content = $r->method eq "POST" ? $r->content : $r->args;
#Set the request method to GET
$r->method("GET");
$r->method_number(M_GET);
#Set the typical headers
$r->headers_in->unset("Content-length");
$r->content_type("text/html");
#Add the content to the response
$r->args($content);
#Do the redirect
$r->internal_redirect_handler($url."?".$content);
}

#Receiver of redirect
$r = shift;
$r->content_type("text/plain\n\n");
$r->print("IN RECEIVER SCRIPT\n\n");
$r->print("YOUR PARAMS ARE:".$r->args."\n\n");
$r->print("REQUEST METHOD WAS:".$r->method."\n\n");

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com