Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Apache::ParseControl a work in progress

by dpatrick (Scribe)
on Aug 15, 2001 at 01:33 UTC ( #104888=perlquestion: print w/replies, xml ) Need Help??

dpatrick has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing this module for apache. It is nearing a first release. This will be the first module I've ever written. It makes mod_dav useable in environments where a server embedded scripting language, such as PHP, is used. I seek the wisdom of the Perlmonks for guidance as to any features that may be useful to have, as well as places to announce the availability of the module and any other advice anyone could offer. Thanks all. dap

package Apache::ParseControl; use strict; use Apache::Constants qw(:common); sub handler { my $r = shift; my $debug; $debug = $r->dir_config('debugNoParse') eq 'on' ? 1 : 0; my $flags = 'O_RDONLY'; my $filename = $r->filename; $r->send_http_header; if ($debug == 1){ my $host = $r->get_remote_host; my $ct = $r->content_type; my $uri = $r->uri; my $filetype =""; if (-B $filename) { $filetype = "binary"; } else { $filetype = "text"; } $r->print("$host\n$ct\n$uri\n$filename\n$filetype\n"); } print $r->dir_config('debugNoParse'); sysopen(FH, $filename, $flags); while(<FH>){ print; } close(FH); return OK; } 1; __END__ =head1 NAME Apache::ParseControl - an apache module to control the parsing of serv +er-side scripts =head1 SYNOPSIS In a VirtualHost, Location, or Directory directive SetHandler perl-script PerlHandler Apache::ParseControl =head1 ABSTRACT This module operates at the content handling stage of resource retriev +al in Apache, returning binary files as binary and text files as text +, that is, it will return the source of cgi, php, etc. instead of par +sing any server-side scriping. =head1 DESCRIPTION =head1 AUTHOR INFORMATION Copyright 2001, D. Anthony Patrick. All rights reserved. Originally conceived and written for the College and Graduate School o +f Education at Kent State University. Released with permission of The College and Graduate School of Educati +on, Kent State University. This library is free software; you can distribute it and/or modify it + under the same terms as Perl itself. Check and +ng/perl/ for new versions and updates. =head1 CREDITS =head1 BUGS =head1 SEE ALSO Stein & MacEachern, Writing Apache Modules with Perl and C, 1999, O'Re +illy and Associates, ISBN 1-56592-567-X WebDAV Resources Site - =head1 THANKS To MDK for listening (and not listening) to my endless drone about the + wonders of Perl and nature of computing today. =cut

Replies are listed 'Best First'.
Re: Apache::ParseControl a work in progress
by echo (Pilgrim) on Aug 15, 2001 at 13:26 UTC
    Suggestion: instead of using
        sysopen(FH, $filename, $flags); 
    you could use:
        my $fh = Apache::File->new($filename);
        close $fh;
    You'll have to use Apache::File() for this
    to work. It'll let Apache core routines send the file
    and that can lead to good performance optimisations
    (e.g. mmap or sendfile).
    You should also handle HEAD requests, do not send the file if $r->header_only.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://104888]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2023-03-21 02:28 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.