Re: image corruption
Tim, I don't know a lot about mod_perl, but I would guess you may want to look at invoking a subrequest via lookup_file or lookup_uri. E.g. my $ct = $r->lookup_uri('images/logo.tif')->content_type; regards John John Kelly IBM Hursley "Tim Noll" <[EMAIL PROTECTED]> 05/02/2002 12:21 To: <[EMAIL PROTECTED]> cc: Subject:image corruption I'm attempting to use mod_perl and Template Toolkit to serve up templates. However, I'm having a problem with the images in those templates: They're passing through the content handler, and thus getting corrupted. My first thought was to return DECLINED from the content handler if the request is not for text/html content; however, since I'm using a Location directive, the content_type is always empty since there's no direct mapping to an actual image file. I could use an Alias to map the URI to the file, but then I wouldn't have the path_info that I'm using to call the template. Since my test code, using path_info, is based on an example from the Template Toolkit docs, I feel like I'm probably overlooking something basic. So, I'd appreciate it if someone could show me the error of my ways. :-) Here are the relevant chunks of config and code: from httpd.conf --- ... SetHandler perl-script PerlHandler Apache::Test::Mod PerlSetVar WEBROOT /usr/local/apache/tt/html ... Apache::Test::Mod - ... sub handler { my $r = shift; # this doesn't work #return DECLINED unless $r->content_type eq 'text/html'; my $WEBROOT = $r->dir_config('WEBROOT') or return fail( $r, SERVER_ERROR, "'WEBROOT' not specified" ); my $file = $r->path_info; my $vars = { content => $r->content_type, }; $r->content_type('text/html'); $r->no_cache(1); my $template = Template->new( { INCLUDE_PATH => "$WEBROOT:$WEBROOT/include", OUTPUT => $r, } ); $template->process( $file, $vars, $r) or return fail( $r, SERVER_ERROR, $template->error ); $r->send_http_header(); $r->print( $output ); return OK; } ... index.html (test template) -- test content_type: [% content %] image: Thanks. -Tim
Re: questions
Stu, You don't need mod_perl to run PERL programs with Apache It's not clear what the problem is, but it sounds like you can get PERL programs to run if they are called .cgi but not .pl If so, try adding this line to httpd.conf AddHandler cgi-script .pl regards John "stu seven" <[EMAIL PROTECTED]> 02/02/2002 00:24 To: [EMAIL PROTECTED] cc: Subject:questions I am having problems getting Apache to recognize perl files... someone suggested installing mod_perl... 1) Is installing mod_perl necessary to running perl scripts via Apache / webserver ? 2) I saw something in the mod_perl "faqs" about getting a popup save window instead of the perl file running... can I add the PerlSendHeader On to Apache without running mod_perl ? That is what is happening here now... .cgi files run / .pl files give me the save widget. I hope somebody can help with this... I really WOULD like to do some programming with mod_perl too :) _ Chat with friends online, try MSN Messenger: http://messenger.msn.com
Re: Problems changing the realm with auth_name
Hi, I've just moved up to a very recent PPM level of mod_perl and changed my webserver. It's IBM_HTTP_SERVER/1.3.19 Apache/1.3.20 (Win32) mod_perl/1.26_01-dev I'm still getting this problem $r->auth_name("Realm $value"); my $realm = $r->auth_name(); $realm returns the value of the AuthName directive in http.conf. Any ideas ? regards John
Problems changing the realm with auth_name
Hi, I'm running Apache/1.3.20 (Win32) mod_perl/1.25_01-dev and am having problem using auth_name to dynamically set the realm. The call seems to be ignored, using the AuthName directive from http.conf. Excuse me if I've done something obviously wrong, but I've only been writing mod_perl for 4 days. Looking around I saw a note from someone which implied they also had a problem with this on NT (I'm running XP Professional) but that was some time ago. After looking through http://perl.apache.org/dist/mod_perl-1.26/Changes it seems that the problem I am having may well be fixed in 1.26 Being a simple windows programmer, I'd appreciate it if someone could point me to a win32 binary distribution of mod_perl for 1.26 My httpd.conf look like this SetHandler perl-script PerlSendHeader on AuthName temp AuthType Basic require valid-user PerlAccessHandler Apache::AccessPrivate and the access handler part of my AccessPrivate.pm file is here... sub handler { my $r = shift; my $uri = $r->parsed_uri; my @pi = split /\//,$uri->path_info(); shift @pi; my $realm = shift @pi; $r->auth_name("$realm"); $r->set_handlers(PerlAuthenHandler => [\&authenticate]); $r->set_handlers(PerlHandler => [\&content]); return OK; } regards john