in reply to Re^3: mod_perl give 404 not_found with content
in thread mod_perl give 404 not_found with content
This works<Location /perl> SetHandler perl-script PerlResponseHandler ModPerl::Registry Options +ExecCGI PerlOptions +ParseHeaders PerlOptions +SetupEnv </Location> #!/usr/bin/perl -- use strict; use warnings; use CGI; use Data::Dumper; Main(@ARGV); exit(0); sub Main { my $cgi = CGI->new; print $cgi->header( -status => 404, -nph => 0, ); print $cgi->start_html, $cgi->b(rand time, ' ', scalar gmtime), print '<table border="1" width="%100"><tr><td>', $cgi->Dump, '</td><td><div style="white-space: pre-wrap; overflow: scroll;">', $cgi->escapeHTML( Dumper( $cgi ) ), '</div></td></tr></table>', CGI->new( \%ENV )->Dump; print $cgi->hr; print $cgi->end_form, $cgi->end_html; }
Using $r->status() is keyPerlModule Apache2::Hello404 <Location /hello404> SetHandler perl-script PerlResponseHandler Apache2::Hello404 </Location> package Apache2::Hello404; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const -compile => qw(OK NOT_FOUND); sub handler { my $r = shift; my $package = __PACKAGE__; my $req = Apache2::Request->new($r); my $val = $req->param('key') || ''; my $msg = $val ? qq{You passed in a value of "$val" for "key"} : 'No "key" parameter was passed '; my $time = scalar localtime; $r->status(Apache2::Const::NOT_FOUND); $r->content_type('text/html'); $r->print(<<"END"); <html> <head><title>$package handler</title></head> <body> Hello from $package. It is $time.<br /> $msg </body> </html> END return Apache2::Const::OK; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Different context
by Jaap (Curate) on Apr 07, 2011 at 13:16 UTC | |
by ikegami (Patriarch) on Apr 07, 2011 at 16:09 UTC | |
by Jaap (Curate) on Apr 07, 2011 at 20:03 UTC | |
by ikegami (Patriarch) on Apr 07, 2011 at 20:40 UTC | |
by Jaap (Curate) on Apr 07, 2011 at 21:39 UTC | |
| |
by Anonymous Monk on Apr 07, 2011 at 13:37 UTC |