home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / ASP.pm < prev    next >
Encoding:
Perl POD Document  |  2003-08-06  |  314.6 KB  |  8,875 lines

  1.  
  2. # For documentation for this module, please see the end of this file
  3. # or try `perldoc Apache::ASP`
  4.  
  5. package Apache::ASP;
  6.  
  7. $VERSION = 2.55;
  8.  
  9. #require DynaLoader;
  10. #@ISA = qw(DynaLoader);
  11. #bootstrap Apache::ASP $VERSION;
  12.  
  13. use Digest::MD5 qw(md5_hex);
  14. use Cwd qw(cwd);
  15.  
  16. # create multiple entries for this symbols for StatINC
  17. use Fcntl qw(:flock O_RDWR O_CREAT); 
  18.  
  19. # load these always, but only load ::State, ::Session, ::Application
  20. # at runtime in non mod_perl environments since they may not be needed
  21. use Apache::ASP::GlobalASA;
  22. use Apache::ASP::Response;
  23. use Apache::ASP::Request;
  24. use Apache::ASP::Server;
  25. use Apache::ASP::Date;
  26. use Apache::ASP::Lang::PerlScript;
  27.  
  28. use Carp qw(confess cluck);
  29.  
  30. use strict;
  31. no strict qw(refs);
  32. use vars qw($VERSION
  33.         %NetConfig %LoadedModules %LoadModuleErrors 
  34.         %Codes %includes %Includes %CompiledIncludes
  35.         @Objects %Register %XSLT
  36.         $ServerID $ServerPID $SrandPid 
  37.             $CompileErrorSize $CacheSize @CompileChecksumKeys
  38.         %ScriptLanguages $ShareDir $INCDir $AbsoluteFileMatch
  39.             $QuickStartTime
  40.             $SessionCookieName
  41.             $LoadModPerl
  42.             $ModPerl2
  43.        );
  44.  
  45. # other common modules load now, these are optional though, so we do not error upon failure
  46. # just do this once perl mod_perl parent startup
  47. unless($LoadModPerl++) {
  48.     my @load_modules = qw( Config lib Time::HiRes );
  49.     if($ENV{MOD_PERL}) {
  50.     # Only pre-load these if in a mod_perl environment for sharing memory post fork.
  51.     # These will not be loaded then for CGI until absolutely necessary at runtime
  52.     push(@load_modules, qw( 
  53.           Apache2 mod_perl
  54.           MLDBM::Serializer::Data::Dumper Devel::Symdump CGI
  55.           Apache::ASP::StateManager Apache::ASP::Session Apache::ASP::Application
  56.           Apache::ASP::StatINC Apache::ASP::Error
  57.           )
  58.         );
  59.     }
  60.     
  61.     for my $module ( @load_modules ) {
  62.          eval "use $module ();";
  63.     }
  64.  
  65.     if($ENV{MOD_PERL}) {
  66.     $ModPerl2 = ($mod_perl::VERSION >= 1.99);
  67.     if($ModPerl2) {
  68.         eval "use Apache::ASP::ApacheCommon ();";
  69.     }
  70.     }
  71. }
  72.  
  73. ## HEADER TOKEN TWEAK
  74. # This must be called outside the above load module block, so that
  75. # its gets run whenever this module is loaded
  76. # This didn't work in 1.27 mod_perl, with DSO enabled, would
  77. # put the Apache::ASP token in front.
  78. # eval {     &Apache::add_version_component("Apache::ASP/$VERSION"); };
  79. # $Apache::Server::AddPerlVersion = 1;
  80.  
  81. #use integer; # don't use screws up important numeric logic
  82.  
  83. @Objects = ('Application', 'Session', 'Response', 'Server', 'Request');
  84. map { eval "sub $_ { shift->{$_} }" } @Objects;
  85.  
  86. # use regexp directly, not sub for speed
  87. $AbsoluteFileMatch = '^(/|[a-zA-Z]:)';
  88. $CacheSize = 1024*1024*10;
  89. $SessionCookieName = 'session-id';
  90.  
  91. # ServerID creates a unique identifier for the server
  92. srand();
  93. $ServerID = substr(md5_hex($$.rand().time().(-M('..')||'').(-M('/')||'')), 0, 16);
  94. $ServerPID  = $$;
  95.  
  96. # DEFAULT VALUES
  97. $Apache::ASP::CompileErrorSize = 500;
  98. @CompileChecksumKeys = qw ( Global DynamicIncludes UseStrict XMLSubsMatch XMLSubsPerlArgs XMLSubsStrict GlobalPackage UniquePackages IncludesDir InodeNames PodComments );
  99.  
  100. %ScriptLanguages = (
  101.             'PerlScript' => 1,
  102.            );
  103.  
  104. &InitPaths();
  105.  
  106. %Apache::ASP::LoadModuleErrors = 
  107.   (
  108.    'Filter' => 
  109.    "Apache::Filter was not loaded correctly for using SSI filtering.  ".
  110.    "If you don't want to use filtering, make sure you turn the Filter ".
  111.    "config option off whereever it's being used",
  112.  
  113.    Clean => undef,
  114.    
  115.    CreateObject => 
  116.    'OLE-active objects not supported for this platform, '.
  117.    'try installing Win32::OLE',
  118.    
  119.     Gzip =>
  120.    'Compress::Zlib is needed to make gzip content-encoding work, '.
  121.    'If you want to use this feature, get yourself the latest '.
  122.    'Compress::Zlib from CPAN. ',
  123.    
  124.    HiRes => undef,
  125.  
  126.    FormFill => 
  127.    'HTML::FillInForm is needed to use the FormFill feature '.
  128.    'for auto filling forms with $Response->Form() data',
  129.  
  130.    MailAlert => undef,
  131.    
  132.    SendMail => "No mailing support",
  133.    
  134.    StateDB => 
  135.    'cannot load StateDB '.
  136.    'must be a valid perl module with a db tied hash interface '.
  137.    'such as: SDBM_File (default), or DB_File',
  138.    
  139.    StateSerializer =>
  140.    'cannot load StateSerializer '.
  141.    'must be a valid serializing perl module for use with MLDBM '.
  142.    'such as Data::Dumper (default), or Storable',
  143.  
  144.    StatINC => "You need this module for StatINC, please download it from CPAN",
  145.    
  146.    'Cache' => "You need this module for xml output caching",
  147.  
  148.    XSLT => 'Cannot load XML::XSLT.  Try installing the module.',
  149.  
  150.   );
  151.  
  152.  
  153. sub handler {
  154.     my($package, $r) = @_;
  155.     my $status = 200;
  156.     
  157.     # allows it to be called as an object method
  158.     ref $package and $r = $package;
  159.  
  160.     # default to Apache request object if not passed in, for possible DSO fix
  161.     # rarely happens, but just in case
  162.     my $filename;
  163.     unless($filename = eval { $r->filename }) {
  164.     if($filename = eval { Apache->request->filename }) {
  165.         $r = Apache->request;
  166.     } else {
  167.         return &DSOError($r);
  168.     }
  169.     }
  170.  
  171.     # better error checking ?
  172.     $filename ||= $r->filename();
  173.     # using _ is optimized to use last stat() record
  174.     return(404) if (! -e $filename or -d _);
  175.  
  176.     # alias $0 to filename, bind to glob for bug workaround
  177.     local *0 = \$filename;
  178.  
  179.     # ASP object creation, a lot goes on in there!
  180.     # method call used for speed optimization, as OO calls are slow
  181.     my $self = Apache::ASP::new('Apache::ASP', $r, $filename);
  182.  
  183.     # for runtime use/require library loads from global/INCDir
  184.     # do this in the handler section to cover all the execution stages
  185.     # following object set up as possible.
  186.     local @INC = ($self->{global}, $INCDir, @INC);
  187.  
  188.     # Execute if no errors
  189.     $self->{errs} || &Run($self);
  190.     
  191.     # moved print of object to the end, so we'll pick up all the 
  192.     # runtime config directives set while the code is running
  193.  
  194.     $self->{dbg} && $self->Debug("ASP Done Processing $self", $self );
  195.  
  196.     # error processing
  197.     if($self->{errs}) {
  198.     require Apache::ASP::Error;
  199.     $status = $self->ProcessErrors;
  200.     }
  201.  
  202.     # XX return code of 302 hangs server on WinNT
  203.     # STATUS hook back to Apache
  204.     my $response = $self->{Response};
  205.     if($status != 500 and defined $response->{Status} and $response->{Status} != 302) {
  206.     # if still default then set to what has been set by the 
  207.     # developer
  208.     $status = $response->{Status};
  209.     }
  210.  
  211.     # X: we DESTROY in register_cleanup, but if we are filtering, and we 
  212.     # handle a virtual request to an asp app, we need to free up the 
  213.     # the locked resources now, or the session requests will collide
  214.     # a performance hack would be to share an asp object created between
  215.     # virtual requests, but don't worry about it for now since using SSI
  216.     # is not really performance oriented anyway.
  217.     # 
  218.     # If we are not filtering, we let RegisterCleanup get it, since
  219.     # there will be a perceived performance increase on the client side
  220.     # since the connection is terminated before the garabage collection is run.
  221.     # 
  222.     # Also need to destroy if we return a 500, as we could be serving an
  223.     # error doc next, before the cleanup phase
  224.  
  225.     if($self->{filter} || ($status == 500) || ( $r->isa('Apache::ASP::CGI'))) {
  226.     $self->DESTROY();
  227.     }
  228.  
  229.     $status;
  230. }
  231.  
  232. sub Warn {
  233.     shift if(ref($_[0]) or $_[0] eq 'Apache::ASP');
  234.     print STDERR "[ASP WARN] ", @_;
  235. }
  236.  
  237. sub new {
  238.     my($class, $r, $filename) = @_;
  239.     $r || die("need Apache->request() object to Apache::ASP->new(\$r)");
  240.  
  241.     # $StartTime is set by asp-perl early on before modules are loaded
  242.     # for more accurate per time tracking.  Unset, so this init load time does 
  243.     # not get used more than once.
  244.     my $start_time;
  245.     if($QuickStartTime) {
  246.     $start_time = $QuickStartTime;
  247.     $QuickStartTime = undef;
  248.     } else {
  249.     $start_time = eval { &Time::HiRes::time(); } || time();
  250.     }
  251.  
  252.     local $SIG{__DIE__} = \&Carp::confess;
  253.     # like cgi, operate in the scripts directory
  254.     $filename ||= $r->filename();
  255.     $filename =~ m|^(.*?[/\\]?)([^/\\]+)$|;
  256.     my $dirname = $1 || '.';
  257.     my $basename = $2;
  258.     chdir($dirname) || die("can't chdir to $dirname: $!");
  259.  
  260.     # temp object just to call config() on, do not bless since we
  261.     # do not want the object to be DESTROY()'d
  262.     my $dir_config = $r->dir_config;
  263.     my $headers_in = $r->headers_in;
  264.     my $self = { r => $r, dir_config => $dir_config };
  265.  
  266.     # global is the default for the state dir and also 
  267.     # a default lib path for perl, as well as where global.asa
  268.     # can be found
  269.     my $global = &get_dir_config($dir_config, 'Global') || '.';
  270.     $global = &AbsPath($global, $dirname);
  271.  
  272.     # asp object is handy for passing state around
  273.     $self = bless 
  274.       { 
  275.        'basename'       => $basename,
  276.        'cleanup'        => [],
  277.        'dbg'            => &get_dir_config($dir_config, 'Debug') || 0,  # debug level
  278.        'destroy'        => 1,
  279.        'dir_config'     => $dir_config,
  280.        'headers_in'     => $headers_in,
  281.        filename         => $filename,
  282.        global           => $global,
  283.        global_package   => &get_dir_config($dir_config, 'GlobalPackage'),
  284.        inode_names      => &get_dir_config($dir_config, 'InodeNames'),
  285.        no_cache         => &get_dir_config($dir_config, 'NoCache'),
  286.        'r'              => $r, # apache request object 
  287.        start_time       => $start_time,
  288.        stat_scripts     => &config($self, 'StatScripts', undef, 1),
  289.        stat_inc         => &get_dir_config($dir_config, 'StatINC'),    
  290.        stat_inc_match   => &get_dir_config($dir_config, 'StatINCMatch'),
  291.        use_strict       => &get_dir_config($dir_config, 'UseStrict'),
  292.        win32            => ($^O eq 'MSWin32') ? 1 : 0,
  293.        xslt             => &get_dir_config($dir_config, 'XSLT'),
  294.       }, $class;
  295.  
  296.     # Only if debug is negative do we kick out all the internal stuff
  297.     if($self->{dbg}) {
  298.     if($self->{dbg} < 0) {
  299.         *Debug = *Out;
  300.         $self->{dbg} = -1 * $self->{dbg};
  301.     } else {
  302.         *Debug = *Null;
  303.     }
  304.     $self->Debug('RUN ASP (v'. $VERSION .") for $self->{filename}");
  305.  
  306.     } else {
  307.     *Debug = *Null;
  308.     }
  309.     
  310.     # Ken said no need for seed ;), now we just make sure its called post fork
  311.     # Patch from Ime suggested no need for %SrandPid, just srand() again when $$ has changed
  312.     unless($SrandPid && $SrandPid == $$) {
  313.     $self->{dbg} && $self->Debug("call srand() post fork");
  314.     srand();
  315.     $SrandPid = $$;
  316.     }
  317.  
  318.     # filtering support
  319.     my $filter_config = &get_dir_config($dir_config, 'Filter');
  320.     if($filter_config) { 
  321.         if($self->LoadModules('Filter', 'Apache::Filter')) {
  322.         # new filter_register with Apache::Filter 1.013
  323.         if($r->can('filter_register')) {
  324.         $self->{r} = $r = $r->filter_register;
  325.         }
  326.         
  327.         if ($r->can('filter_input') && $r->can('get_handlers')) {
  328.         $self->{filter} = 1;
  329.         #X: do something with the return code, can't now because
  330.         # apache constants aren't working on my win32
  331.         my($fh, $rc) = $r->filter_input();
  332.         $self->{filehandle} = $fh;
  333.         }
  334.     } else {
  335.         if(! $r->can('get_handlers')) {
  336.         $self->Error("You need at least mod_perl 1.16 to use SSI filtering");
  337.         } else {
  338.         $self->Error("Apache::Filter was not loaded correctly for using SSI filtering.  ".
  339.                  "If you don't want to use filtering, make sure you turn the Filter ".
  340.                  "config option off whereever it's being used");
  341.         }
  342.     }
  343.     }
  344.     
  345.     # gzip content encoding option by ime@iae.nl 28/4/2000
  346.     my $compressgzip_config = &get_dir_config($dir_config, 'CompressGzip');
  347.     if($compressgzip_config) {
  348.     if($self->LoadModule('Gzip','Compress::Zlib')) {
  349.         $self->{compressgzip} = 1;
  350.     }
  351.     }    
  352.      
  353.     # must have global directory into which we put the global.asa
  354.     # and possibly state files, optimize out the case of . or ..
  355.     if($self->{global} !~ /^(\.|\.\.)$/) {
  356.     -d $self->{global} or 
  357.       $self->Error("global path, $self->{global}, is not a directory");
  358.     }
  359.  
  360.     # includes_dir calculation
  361.     if($filename =~ m,^((/|[a-zA-Z]:).*[/\\])[^/\\]+?$,) {
  362.     $self->{dirname} = $1;
  363.     } else {
  364.     $self->{dirname} = '.';
  365.     }
  366.     $self->{includes_dir} = [
  367.                  $self->{dirname},
  368.                  $self->{global}, 
  369.                  split(/;/, &config($self, 'IncludesDir') || ''),
  370.                 ];
  371.  
  372.     # register cleanup before the state files get set in InitObjects
  373.     # this way DESTROY gets called every time this script is done
  374.     # we must cache $self for lookups later
  375.     &RegisterCleanup($self, sub { $self->DESTROY });
  376.  
  377.     #### WAS INIT OBJECTS, REMOVED DECOMP FOR SPEED
  378.  
  379.     # GLOBALASA, RESPONSE, REQUEST, SERVER
  380.     # always create these
  381.     # global_asa assigns itself to parent object automatically
  382.     my $global_asa = &Apache::ASP::GlobalASA::new($self);
  383.     $self->{Request}   = &Apache::ASP::Request::new($self);
  384.     $self->{Response}  = &Apache::ASP::Response::new($self);
  385.     # Server::new() is just one line, so execute directly
  386.     $self->{Server}    = bless {asp => $self}, 'Apache::ASP::Server';
  387.     #&Apache::ASP::Server::new($self);
  388.  
  389.     # After GlobalASA Init, init the package that this script will execute in
  390.     # must be here, and not end of new before things like Application_OnStart get run
  391.     # UniquePackages & NoCache configs do not work together, NoCache wins here
  392.     if(&config($self, 'UniquePackages')) {
  393.     # id is not generally useful for the ASP object now, so calculate
  394.     # it here now, only to twist the package object for this script
  395.  
  396.     # pass in basename for where to find the file for InodeNames, and the full path
  397.     # for the FileId otherwise
  398.     my $package = $global_asa->{'package'}.'::'.&FileId($self, $self->{basename}, $self->{filename});
  399.     $self->{'package'} = $package;
  400.     $self->{init_packages} = ['main', $global_asa->{'package'}, $self->{'package'}];    
  401.     } else {
  402.     $self->{'package'} = $global_asa->{'package'};
  403.     $self->{init_packages} = ['main', $global_asa->{'package'}];    
  404.     }
  405.  
  406.     $self->{state_dir}   = &config($self, 'StateDir', undef, $self->{global}.'/.state');
  407.     $self->{state_dir}   =~ tr///; # untaint
  408.  
  409.     # if no state has been config'd, then set up none of the 
  410.     # state objects: Application, Internal, Session
  411.     unless(&get_dir_config($dir_config, 'NoState')) {
  412.     # load at runtime for CGI environments, preloaded for mod_perl
  413.     require Apache::ASP::StateManager;
  414.     &InitState($self);
  415.     }
  416.  
  417.     $self;
  418. }
  419.  
  420. # called upon every end of connection by RegisterCleanup
  421. sub DESTROY {
  422.     my $self = shift;
  423.     return unless $self->{destroy}; # still active object
  424.     $self->{dbg} && $self->Debug("destroying ASP object $self");
  425.  
  426.     # do before undef'ing the object references in main
  427.     for my $code ( @{$self->{cleanup}} ) {
  428.     $self->{dbg} && $self->Debug("executing cleanup $code");
  429.     eval { &$code() };
  430.     $@ && $self->Error("executing cleanup $code error: $@");
  431.     }
  432.  
  433.     local $^W = 0; # suppress untie while x inner references warnings
  434.     select(STDOUT); 
  435.     untie *RESPONSE if tied *RESPONSE;
  436.  
  437.     # can't move this to Request::DESTROY(), then CGI object compatibility
  438.     # in test ./site/eg/cgi.htm test fails, don't know why, --jc, 12/06/2002
  439.     untie *STDIN if tied *STDIN;
  440.  
  441.     # in case there is a dummy session here by the 
  442.     # end of object execution
  443.     if($self->{Session}) {
  444.         if(eval { $self->{Session}->isa('Apache::ASP::Session') }) {
  445.         # only the cleanup master may cleanup groups now, so OK
  446.         # to call just CleanupGroups
  447.         $self->CleanupGroups();
  448.     } else {
  449.             $self->Debug("$self->{Session} is not an Apache::ASP::Session");
  450.             eval { $self->{Session}->DESTROY };
  451.             $self->{Session} = undef;
  452.         }
  453.     }
  454.  
  455.     # free file handles here.  mod_perl tends to be pretty clingy
  456.     # to memory
  457.     for('Application', 'Internal', 'Session') {
  458.     # all this stuff in here is very necessary for total cleanup
  459.     # the DESTROY is the most important, as we need to explicitly free
  460.     # state objects, just in case anyone else is keeping references to them
  461.     # But the destroy won't work without first untieing, go figure
  462.     next unless defined $self->{$_};
  463.     my $tied = tied %{$self->{$_}};
  464.     next unless $tied;
  465.     untie %{$self->{$_}};
  466.     $tied->DESTROY(); # call explicit DESTROY
  467.     }
  468.  
  469.     if(my $caches = $self->{Caches}) {
  470.     # default cache size to 10M
  471.     $self->{cache_size} = &config($self, 'CacheSize') || $CacheSize;
  472.     if($self->{cache_size} =~ /^([\d\.]+)(M|K|B)?$/) {
  473.         my($size, $unit) = ($1, $2);
  474.         if($unit eq 'M') {
  475.         $size *= 1024*1024;
  476.         } elsif($unit eq 'K') {
  477.         $size *= 1024;
  478.         }
  479.         if($size ne $self->{cache_size}) {
  480.         $self->{dbg} && $self->Debug("converting CacheSize $self->{cache_size} to $size bytes");
  481.         $self->{cache_size} = $size;
  482.         }
  483.     }
  484.     for my $cache (values %$caches) {
  485.         my $tied = $cache;
  486.         if($tied->{writes} && $tied->Size > $self->{cache_size}) {
  487.         $self->{dbg} && $self->Debug("deleting cache $cache, size: ".$tied->Size);
  488.         $tied->Delete;
  489.         } else {
  490.         $self->{dbg} && $self->Debug("cache $cache OK size, size: ".$tied->Size);
  491.         }
  492.         $tied->DESTROY();
  493.     }
  494.     }
  495.  
  496.     #    $self->{'dbg'} && $self->Debug("END ASP DESTROY");
  497.     $self->{Request} && &Apache::ASP::Request::DESTROY($self->{Request});
  498.     $self->{Server} && ( %{$self->{Server}} = () );
  499.     $self->{Response} && ( %{$self->{Response}} = () );
  500.     %$self = ();
  501.  
  502.     1;
  503. }
  504.  
  505. sub RegisterCleanup {
  506.     my $self = shift;
  507.  
  508.     if($ModPerl2) {
  509.     $self->{r}->pool->cleanup_register(@_);
  510.     } else {
  511.     $self->{r}->register_cleanup(@_);
  512.     }
  513. }
  514.  
  515. sub InitPaths {
  516.  
  517.     # we load this module just to detect where the shared directory really is
  518.     use Apache::ASP::Share::CORE;
  519.  
  520.     # major problem with %INC if we cannot get this information
  521.     my $share_path = $INC{'Apache/ASP/Share/CORE.pm'} 
  522.       || die(q(can't find path for $INC{'Apache/ASP/Share/CORE.pm'}));
  523.  
  524.     $share_path =~ s/CORE\.pm$//s;
  525.     unless($share_path =~ /$AbsoluteFileMatch/) {
  526.     # this %ENV manipulation is just to allow cwd() to run in taint check mode
  527.     local %ENV = %ENV;
  528.     $ENV{PATH} = '/bin:/usr/bin:/usr/sbin';
  529.     delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
  530.     my $currdir = cwd();
  531.     $share_path = "$currdir/$share_path";
  532.     }
  533.  
  534.     # not finding the ShareDir creates a hard error, because the Apache/ASP/Share
  535.     # directory will become one of the fundamental underpinings of the project
  536.     # People will need to rely on being able to load shared includes, and not have
  537.     # to discover the lack of loading Share:: at runtime, rather this is a compile
  538.     # time error.
  539.     -d $share_path || die("Apache::ASP::Share directory not found.  ".
  540.               "Please make sure to install all the modules that make up the Apache::ASP installation."
  541.              );
  542.     $ShareDir = $share_path;
  543.  
  544.     # once we find the $ShareDir, we can truncate the library path
  545.     # and push it onto @INC with use lib... this is to help with loading
  546.     # future Apache::ASP::* modules when the lib path it was found at is 
  547.     # relative to some directory.  This was needed to have the "make test"
  548.     # test suite to work which loads libraries from "blib/lib", but Apache::ASP
  549.     # will chdir() into the script directory so that can ruin this
  550.     # library lookup.
  551.     #
  552.     my $lib_path = $share_path;
  553.     $lib_path =~ s/Apache.ASP.Share.?$//s;
  554.     -d $lib_path || die("\%INC library path $lib_path not found.");
  555.     $INCDir = $lib_path;
  556.     
  557.     # clear taint, for some reason, tr/// or s/^(.*)$/ did not work on perl 5.6.1
  558.     $INCDir =~ /^(.*)$/s;
  559.     $INCDir = $1;
  560.  
  561.     # make sure this gets on @INC at startup, can't hurt
  562.     eval "use lib qw($INCDir);";
  563.  
  564.     1;
  565. }
  566.  
  567. sub FileId {
  568.     my($self, $file, $abs_file, $no_compile_checksum) = @_;
  569.     $file || die("no file passed to FileId()");
  570.     my $id;
  571.  
  572.     # calculate compile checksum for file id
  573.     unless($self->{compile_checksum}) {
  574.     my $r = $self->{r};
  575.     my $checksum = md5_hex(join('&-+', 
  576.                     $VERSION,
  577.                     map { &config($self, $_) || '' }
  578.                     @CompileChecksumKeys
  579.                    )
  580.                   );
  581.     #    $self->{dbg} && $self->Debug("compile checksum $checksum");
  582.     $self->{compile_checksum} = $checksum;
  583.     }
  584.  
  585.     my $compile_checksum = $no_compile_checksum ? '' : $self->{compile_checksum};
  586.  
  587.     my @inode_stat = ();
  588.     if($self->{inode_names}) {
  589.     @inode_stat = stat($file);
  590.     # one or the other device or file ids must be not 0
  591.     unless($inode_stat[0] || $inode_stat[1]) {
  592.         @inode_stat = ();
  593.     }
  594.     }
  595.  
  596.     if(@inode_stat) {
  597.     $id = sprintf("____DEV%X_INODE%X",@inode_stat[0,1]);
  598.     $id .= 'x'.$compile_checksum;
  599.     } else {
  600.     if($abs_file) {
  601.         $file = $abs_file;
  602.     }
  603.     $file =~ s|/+|/|sg;
  604.     $file =~ s/[\Wx]/_/sg;
  605.     my $file_name_length = length($file);
  606.     if($file_name_length >= 35) {
  607.         $id = substr($file, $file_name_length - 35, 36);
  608.         # only do the hex of the original file to create a unique identifier for the long id
  609.         $id .= 'x'.&md5_hex($file.$compile_checksum);
  610.     } else {
  611.         $id = $file.'x'.$compile_checksum;
  612.     }
  613.     }
  614.  
  615.     $id = '__ASP_'.$id;
  616. }
  617.  
  618. # defaults to parsing the script's file, or data from a file handle 
  619. # in the case of filtering, but we can also pass in text to parse,
  620. # which is useful for doing includes separately for compiling
  621. sub Parse {
  622.     my($self, $file) = @_;
  623.     my $file_exists = 0;
  624.     my $parse_file = $file;
  625.     my $r = $self->{r};
  626.     my $data;
  627.  
  628.     # get script data, from varied data sources; 
  629.     $file || die("can't parse without file data");
  630.  
  631.     $self->{dbg} && $self->Debug("parse file $file");
  632.     # file can be a filename, scalar ref, or scalar
  633.     if(ref $file) {
  634.     if ($file =~ /SCALAR/) {
  635.         $data = $$file;
  636.     } elsif ($file =~ /GLOB/) {
  637.         local $/ = undef;
  638.         $data = <$file>
  639.     }
  640.     } elsif((length($file) < 1024) && ($file !~ /^GLOB/) && (-e $file)) {
  641.     # filename has length < 1024, should be fine across OS's
  642.     $self->{dbg} && $self->Debug("parsing $file");
  643.     $data = ${$self->ReadFile($file)};
  644.     $file_exists = 1;
  645.     $self->{parse_file_count}++;
  646.     } else {
  647.     $data = $file; # raw script, no ref
  648.     }
  649.  
  650.     # moved parsing config here since not needed for normal
  651.     # eval execution of scripts after compilation
  652.     unless($self->{parse_config}) {
  653.     $self->{parse_config} = 1;
  654.     $self->{compile_includes} = &config($self, 'DynamicIncludes');
  655.     $self->{pod_comments} = &config($self, 'PodComments', undef, 1);
  656.     $self->{xml_subs_strict} = &config($self, 'XMLSubsStrict');
  657.     # default XMLSubsPerlArgs to 1 for now, until 3.0
  658.     $self->{xml_subs_perl_args} = &config($self, 'XMLSubsPerlArgs', undef, 1);
  659.  
  660.     # reduce (pattern) patterns to (?:pattern) to not create $1 side effect
  661.     if($self->{xml_subs_match} = &config($self, 'XMLSubsMatch')) {
  662.         $self->{xml_subs_match} =~ s/\(\?\:([^\)]*)\)/($1)/isg;
  663.         $self->{xml_subs_match} =~ s/\(([^\)]*)\)/(?:$1)/isg;
  664.     }
  665.  
  666.     my $lang = &config($self, 'ScriptLanguage', undef, 'PerlScript');
  667.     my $module = "Apache::ASP::Lang::".$lang;
  668.     unless($ScriptLanguages{$lang}) {
  669. #        eval "use $module;";
  670.         $self->Error("ScriptLanguage for $lang could not be loaded: $@");        
  671.         return;
  672.     }
  673.     eval {
  674.         my $lang_object = $module->new(ASP => $self);
  675.         $self->{lang_object} = $lang_object;
  676.         $self->{lang_module} = $module;
  677.         $self->{lang_language} = $lang;
  678.         $self->{lang_comment} = $lang_object->CommentStart;
  679.     };
  680.     if($@) {
  681.         $self->Error("ScriptLanguage object for $lang failed init: $@");
  682.         return;
  683.     }
  684.     }
  685.  
  686.     my $comment = $self->{lang_comment};
  687.     if(&config($self, 'CgiDoSelf')) {
  688.     $data =~ s,^(.*?)__END__,,so;
  689.     }
  690.  
  691.     # do both before and after, so =pods can span includes with =pods
  692.     if($self->{pod_comments}) {
  693.     &PodComments($self, \$data);
  694.     }
  695.  
  696.     # if compiling includes, then do now before includes conversion
  697.     # each include will also have its Script_OnParse run on it.
  698.     if($self->{compile_includes} && $self->{GlobalASA}{'exists'}) {    
  699.     $self->{Server}{ScriptRef} = \$data;
  700.     $self->{GlobalASA}->ExecuteEvent('Script_OnParse');        
  701.     }
  702.  
  703.     # do includes as early as possible !! so included text gets done too
  704.     # this section is for file includes, we do this here instead of ssi
  705.     # so it can be parsed and compiled with the script
  706.     local %includes; # trap recursive includes with this
  707.  
  708.     # JUST ONCE
  709.     # there should only be one of these, <%@ LANGUAGE="PerlScript" %>, rip it out
  710.     # we keep white space and substitue text in so the perlscript sync's up with lines
  711.     # only take out the first one 
  712.     $data =~ s/^\#\![^\n]+(\n\s*)/\<\%$1\%\>/s; #X cgi compat ?
  713.     $data =~ s/^(\s*)\<\%(\s*)\@([^\n]*?)\%\>/$1\<\%$2 ; \%\>/so; 
  714.  
  715.     my $root_file = $file;
  716.     my $line1_added = 0;
  717.     my $munge = $data;
  718.     $data = '';
  719.     my($file_context, $file_line_number, $code_block);
  720.     while($munge =~ s/^(.*?)\<!--\#include\s+file\s*=\s*\"?([^\s\"]*?)\"?(\s+args\s*=\s*\"?.*?)?\"?\s*--\>//so) {
  721.     $data .= $1; # append the head
  722.     my $file = $2;
  723.  
  724.     # only need all this if we are in inline include mode
  725.     my $head_data;
  726.     if (! $self->{compile_includes}) {
  727.         $head_data = $1;
  728.  
  729.         unless($line1_added) {
  730.         $line1_added = 1;
  731.         $head_data = ($file_exists ? "<% \n#line 1 $root_file\n %>" : '').$head_data;
  732.         }
  733.  
  734.         if ($head_data =~ s/.*\n\#line (\d+) ([^\n]+)\n(\%\>)?//s) {
  735.         $file_line_number = $1;
  736.         $file_context = $2;
  737.         $code_block = $3 ? 0 : 1;
  738.         }
  739.         $file_line_number += $head_data =~ s/\n//sg;
  740.         $head_data =~ s/\<\%.*?\%\>//sg;
  741. #        print STDERR "HEAD: $head_data\n";
  742.         my $code_blocks_open   = $head_data =~ s/\<\%//sg;
  743.         my $code_blocks_closed = $head_data =~ s/\%\>//sg;
  744.         $code_block += $code_blocks_open;
  745.         $code_block -= $code_blocks_closed;
  746.         if (($code_block < 0)) {
  747.         $code_block = 0; # stray percents like height=100%> kinds of tags
  748.         }
  749.  
  750. #        print STDERR "CODEBLOCK: $code_block $file; open $code_blocks_open closed $code_blocks_closed\n";
  751. #        print STDERR "FILE CONTEXT: $file_context LINENO: $file_line_number\n\n";
  752.     }
  753.  
  754.     # compiled include args handling
  755.     my $has_args = $3;
  756.     my $args = undef;
  757.     if($has_args) {
  758.         $args = $has_args;
  759.         $args =~ s/^\s+args\s*\=\s*\"?//sgo;
  760.     }
  761.  
  762.     # global directory, as well as includes dirs
  763.     my $include = &SearchDirs($self, $file);
  764.     unless(defined $include) { 
  765.         $self->Error("include file with name $file does not exist");
  766.         return;
  767.     }
  768.     if($self->{dbg}) {
  769.         if($include ne $file) {
  770.         $self->{dbg} && $self->Debug("found $file at $include");
  771.         }
  772.     }
  773.  
  774.     # trap the includes here, at 100 levels like perl debugger
  775.     if(defined($args) || $self->{compile_includes}) {
  776.         # because the script is literally different whether there 
  777.         # are includes or not, whether we are compiling includes
  778.         # need to be part of the script identifier, so the global
  779.         # caching does not return a script with different preferences.
  780.         $args ||= '';
  781.         $self->{dbg} && $self->Debug("runtime exec of dynamic include $file args (".
  782.                      ($args).')');
  783.         $data .= "<% \$Response->Include('$include', $args); %>";
  784.         
  785.         # compile include now, so Loading() works for dynamic includes too
  786.         unless($self->CompileInclude($include)) {
  787.         $self->Error("compiling include $include failed when compiling script");
  788.         }           
  789.     } else {
  790.         $self->{dbg} && $self->Debug("inlining include $include");
  791.         # DEFAULT, not compile includes, or inline includes,
  792.         # the included text is inlined directly into the script
  793.         if($includes{$include}++ > 100) {
  794.         $self->Error("Recursive include detected for $include 100 levels deep! ".
  795.                  "Your includes are including each other.  If you ".
  796.                  "are getting this error with a legitimate use of includes ".
  797.                  "please mail support about this error "
  798.                 );
  799.         return;
  800.         }
  801.         
  802.         # put the included text into what we are parsing, allows for
  803.         # includes having includes
  804.         if ($file_exists && $parse_file) {
  805.         $self->{parse_inline_count}++;
  806.         $self->{dbg} && $self->Debug("include $include found for file $parse_file");
  807.         $Apache::ASP::Includes{$parse_file}->{$include} = time();
  808.         }
  809.         my $text = ${$self->ReadFile($include)};
  810.         $text =~ s/\n$//sg;
  811.         $text =~ s/^\#\![^\n]+(\n\n?)/$1/s; #X cgi compat ?
  812.           ;
  813.         if ($text =~ /\n/s) {
  814.         my $code_open = $code_block ? '' : '<%';
  815.         my $code_close = $code_block ? '' : '%>';
  816.         my $file_context_edge = $file_context ? 
  817.           $code_open."\n#line $file_line_number $file_context\n".$code_close : '';
  818.         $munge =
  819.           $code_open."\n#line 1 $include\n".$code_close.
  820.             $text .
  821.               $file_context_edge .
  822.             $munge;
  823.         } else {
  824.         # if inserting less than one line of text, then don't
  825.         # do line renumbering
  826.         $munge = $text . $munge;
  827.         }
  828.     }
  829.     }
  830.     $data .= $munge; # append what's left   
  831. #    print STDERR $file."\n\n".$data."\n\n";
  832.  
  833.  
  834.     # so we have the full script for people
  835.     if(! $self->{compile_includes}) {    
  836.     # do pod comments again if we have any included files
  837.     if(%includes && $self->{pod_comments}) {
  838.         &PodComments($self, \$data);
  839.     }
  840.     if($self->{GlobalASA}{'exists'}) {    
  841.         $self->{Server}{ScriptRef} = \$data;
  842.         $self->{GlobalASA}->ExecuteEvent('Script_OnParse');        
  843.     }
  844.     }
  845.  
  846. #    $self->Debug("parsing includes done $self->{'basename'}");
  847.  
  848.     # strip carriage returns; do this as early as possible, but after includes
  849.     # since we want to rip out the carriage returns from them too, these
  850.     # changes should make things Win & Mac compatible
  851. #    my $CRLF = "\015\012";
  852.     $data =~ s/\015?\012/\n/sgo;
  853.     $data =~ s/\s+$//so; # strip trailing white space
  854.  
  855.     my $script = &ParseHelper($self, \$data, 1);
  856.     if($script) {
  857.     my $strict = $self->{use_strict} ? "use strict;" : "no strict";
  858.     $$script = join(";;", 
  859.             $strict,
  860.             "use vars qw(\$".join(" \$",@Apache::ASP::Objects).')',
  861.             ($file_exists ? "\n#line 1 $root_file\n" : ''),
  862.             $$script,
  863.                );
  864.     return {
  865.         is_perl => 1,
  866.         data => $script,
  867.            };
  868.     } else {
  869.     return {
  870.         is_raw => 1,
  871.         data => \$data,
  872.            };
  873.     }
  874. }
  875.  
  876. sub ParseHelper {
  877.     my($self, $data, $check_static_file) = @_;
  878.     my($script, $text, $perl);
  879.  
  880.     if($self->{xml_subs_match}) {
  881.     my $start = $$data;
  882.     $self->{dbg} && $self->Debug("start parse of data", length($$data));
  883.     $$data = $self->ParseXMLSubs($$data);
  884. #    print STDERR "START $start\n\n";
  885. #    print STDERR "END $$data\n\n";
  886.     }
  887.  
  888.     # we only do this check the first time we call ParseHelper() from
  889.     # Parse() with $check_static_file set.  Calls from ParseXMLSubs()
  890.     # will leave this off.  This is where we start to throw data 
  891.     # back that lets the system render a static file as is instead
  892.     # of executing it as a per subroutine.
  893.     return if ($check_static_file && $$data !~ /\<\%.*?\%\>/s);
  894.  
  895.     my(@out, $perl_block, $last_perl_block);
  896.     $$data .= "<%;;;%>"; # always end with some perl code for parsing.
  897.  
  898. # can't do it for <%= %><% %> constructions
  899. #    $$data =~ s/\%\>(\s*)\<\%/;$1/isg; # compress close code blocks, move white space to code
  900.  
  901.     while($$data =~ s/^(.*?)\<\%(.*?)\%\>//so) {
  902.     ($text, $perl) = ($1,$2);
  903.     $perl_block = ($perl =~ /^\s*\=(.*)$/so) ? 0 : 1;
  904.     my $perl_scalar = $1;
  905.  
  906.     # with some extra text parsing, we remove asp formatting from
  907.     # influencing the generated html formatting, in particular
  908.     # dealing with perl blocks and new lines
  909.     if($text) {
  910.         # don't touch the white space, to preserve line numbers
  911.         $text =~ s/\\/\\\\/gso;
  912.         $text =~ s/\'/\\\'/gso;
  913.  
  914.         if($last_perl_block) {
  915.         $last_perl_block = 0;
  916.         }
  917.  
  918.         push(@out, "\'".$text."\'")
  919.     }
  920.  
  921.     if($perl) {
  922.         if(! $perl_block) {
  923.         # we have a scalar assignment here
  924.         push(@out, '('.$perl_scalar.')');
  925.         } else {
  926.         $last_perl_block = 1;
  927.         if(@out) {
  928.             # we pass by reference here with the idea that we are not
  929.             # copying the HTML twice this way.  This might be large
  930.             # saving on a typical site with rich HTML headers & footers
  931.             $script .= '&Apache::ASP::WriteRef($main::Response, \('.join('.', @out).'));';
  932. #            $script .= '$main::Response->{Bit} = \('.join('.', @out).');';
  933. #            $script .= '($main::Response->{Buffer} && ! $main::Response->{Ended}) ? '.
  934. #              '${$main::Response->{out}} .= ${$main::Response->{Bit}} : '.
  935. #            '$main::Response->WriteRef($main::Response->{Bit}); ';
  936.             @out = ();
  937.         }             
  938.  
  939.         # allow old <% #comment %> style to still work, but we
  940.         # need to insert a newline at the end of the comment for 
  941.         # it to still exist, with the lines now being sync'd up
  942.         # if these old comments still exist, they perl script
  943.         # will be off by one line from the asp script
  944.         if ($perl !~ /\n\s*$/so) {
  945.             if($perl =~ /\#[^\n]*$/so) {
  946. #            print STDERR "NEW adding newline to [$perl]\n";
  947.             $perl .= "\n";
  948.             }
  949.         }
  950.  
  951.         # skip if the perl code is just a placeholder        
  952.         unless($perl eq ';;;') {
  953. #            print STDERR "PERL, adding ; to [$perl]\n";
  954.             $script .= $perl . '; ';
  955.         }
  956.         }
  957.     }
  958.     }
  959.  
  960.     \$script;
  961. }
  962.  
  963. sub ParseXMLSubs {
  964.     my($self, $data) = @_;
  965.  
  966.     $data = &CodeTagEncode($self, $data);
  967.  
  968.     unless($self->{xslt}) {
  969.     $data =~ s|\s*\<\?xml\s+version\s*\=[^\>]+\?\>||is;
  970.     }
  971.     # (?<!\s|\>) ... use later when robustifying XMLSubs
  972.     $data =~ s@\<\s*($self->{xml_subs_match})(\s+[^\>]*)?/\>
  973.       @ {
  974.          my($func, $args) = ($1, $2);
  975.          $args = &CodeTagDecode($self, $args);
  976.          $func =~ s/\:+/\:\:/g;
  977.              $func =~ s/\-/\_/g;
  978.          $args && ($args = &ParseXMLSubsArgs($self, $args));
  979.          $args ||= '';
  980.          $self->{xmlsubs_compiled_tag_short}++;
  981.              "<% &$func({ $args }, ''); %>"
  982.         } @sgex;
  983.  
  984.     while (1) {
  985.     #       \<\s*($self->{xml_subs_match})(\s+[^\>]*)?\>(?!.*\<\s*\1[^\>]*\>)(.*?)\<\/\1\s*>
  986.     last unless $data =~ s@
  987.       \<\s*($self->{xml_subs_match})(\s+[^\>]*)?\>(?!.*?\<\s*\1[^\>]*\>)(.*?)\<\/\1\s*>
  988.           @ {
  989.           my($func, $args, $text) = ($1, $2, $3);
  990.           $args = &CodeTagDecode($self, $args);
  991.           $func =~ s/\:+/\:\:/g;
  992.           $args && ($args = &ParseXMLSubsArgs($self, $args));
  993.           $args ||= '';
  994.           $self->{xmlsubs_compiled_tag_long}++;
  995.           $text = &CodeTagDecode($self, $text);
  996.  
  997.         if($text =~ m/\<\%|\<($self->{xml_subs_match})/) {
  998.             # parse again, and control output buffer for this level
  999.             $self->{xmlsubs_compiled_tag_recurse_parse}++;
  1000.             my $sub_script = &ParseHelper($self, \$text, 0);
  1001.             #            my $sub_script = \$text;
  1002.             $text = (
  1003.                  ' &{sub{ my $out = ""; '.
  1004.                  'local $Response->{out} =  local $Response->{BinaryRef} = \$out; '.
  1005.                  'local *Apache::ASP::Response::Flush = *Apache::ASP::Response::Null; '.
  1006.                  $$sub_script .
  1007.                  ' ; ${$Response->{out}}; }} '
  1008.                 );
  1009.         } else {
  1010.             # raw text
  1011.             $text =~ s/\\/\\\\/gso;
  1012.             $text =~ s/\'/\\\'/gso;    
  1013.             $text = "'$text'";
  1014.         }
  1015.         
  1016.         "<% &$func({ $args }, $text); %>"
  1017.       } @sgex;
  1018.     }
  1019.  
  1020.     $data = &CodeTagDecode($self, $data);
  1021.  
  1022. #    print STDERR "\nXMLSubs:\n$data\n\n";
  1023.  
  1024.     $data;
  1025. }
  1026.  
  1027. sub CodeTagEncode {
  1028.     my($self, $data) = @_;
  1029. #    return $data;
  1030.  
  1031.     if(defined $data) {
  1032.        $data =~ s@\<\%(.*?)\%\>@
  1033.          {
  1034.              my $temp = $self->{Server}->HTMLEncode($1);
  1035.              "[-AsP-[".$temp."]-AsP-]";
  1036.          }
  1037.            @esgx;
  1038.     }
  1039.     $data;
  1040. }
  1041.  
  1042. sub CodeTagDecode {
  1043.     my($self, $data) = @_;
  1044. #    return $data;
  1045.  
  1046.     if(defined $data) {
  1047.        $data =~ s@\[\-AsP\-\[(.*?)\]\-AsP\-\]@
  1048.          {
  1049.              my $temp = $self->{Server}->HTMLDecode($1);
  1050.              "<%".$temp."%>";
  1051.          }
  1052.            @esgx;
  1053.     }
  1054.  
  1055.     $data;
  1056. }
  1057.  
  1058. sub ParseXMLSubsArgs {
  1059.     my($self, $args) = @_;
  1060.     $args ||= '';
  1061.  
  1062.     if ($self->{xml_subs_strict}) {
  1063.     my %args;
  1064.     while ($args =~ s/(\s*)([^\s]+)(\s*)\=\s*([\'\"])(.*?)(\4)\s*//s) {
  1065.         $args{$2} = $5;
  1066.     }
  1067.     $args = join(', ', map { "'$_' => '$args{$_}'" } keys %args);
  1068.     } elsif($self->{xml_subs_perl_args}) {
  1069.     $args =~ s/(\s*)([^\s]+?)(\s*)\=(\s*[^\s]+)/,$1'$2'$3\=\>$4/sg;
  1070.     $args =~ s/^(\s*),/$1/s;
  1071.     } else {
  1072.     my %args;
  1073.     while ($args =~ s/(\s*)([^\s]+?)(\s*)\=\s*([\'\"])(.*?)(\4)\s*//s) {
  1074.         my($key, $value) = ($2, $5);
  1075.         # we go through the pain of @value_bits so that someone can 
  1076.         # pass in non scalar data to XMLSubs args like:
  1077.         #   <my:tag data="<%= [ 'data' ] %>" />
  1078.         # As long as the <%= %> bits are flush against the 
  1079.         # 
  1080.         my @value_bits;
  1081.         while($value =~ s/^(.*?)<\%\=(.*?)\%\>/
  1082.           {
  1083.            length($1) && push(@value_bits, "'$1'");
  1084.            push(@value_bits, "($2)");
  1085.            ''; # return nothing to replace with
  1086.           }
  1087.           /exs
  1088.          ) { 1 };
  1089.         length($value) && push(@value_bits, "'$value'");
  1090.         $args{$key} = join('.', @value_bits);
  1091.     }
  1092.     $args = join(', ', map { "'$_' => $args{$_}" } keys %args);
  1093.     }
  1094.  
  1095. #    print STDERR "ARGS: $args\n";
  1096.     $args;
  1097. }
  1098.  
  1099. sub PodComments {
  1100.     my $data = $_[1];
  1101.     
  1102.     # we do a little extra work to sync pod comment lines up, we do this
  1103.     # by wiping out the pod comments, and replacing them with the equivalent
  1104.     # number of newlines
  1105.     $$data =~ s/\015?\012/\n/sgo;
  1106.     $$data =~ s,(^|\n)(\=pod\n.*?\n\=cut\n),
  1107.       {
  1108.        my $pod = $1.$2;
  1109.        $pod =~ s/[^\n]+//sg;
  1110.        $pod;
  1111.       }
  1112.     ,sgex;
  1113.     
  1114.     $data;
  1115. }
  1116.  
  1117. sub SearchDirs {
  1118.     my($self, $file) = @_;
  1119.     return unless defined $file;
  1120.  
  1121.     my $share_search;
  1122.     if($file =~ s/^Share:://) {
  1123.     $share_search = 1;
  1124.     }
  1125.  
  1126.     my @includes_dir = @{$self->{includes_dir}};
  1127.     if($share_search) {
  1128.     push(@includes_dir, $ShareDir);
  1129.     }
  1130.  
  1131.     # optimization for includes in tight for loops, a typical usage,
  1132.     # to save on the stats per request.  This must occur after @include_dir
  1133.     # per lookup because @includes_dir may change during the request
  1134.     #
  1135.     my $cache_key = join('||', $file, @includes_dir);
  1136.     if(my $path = $self->{search_dirs_cache}{$cache_key}) {
  1137.     # $self->Debug("found $path search cached for $file, key $cache_key");
  1138.     return $path;
  1139.     }
  1140.  
  1141.     # test & return if absolute
  1142.     if($file =~ m,^/|^[a-zA-Z]\:,) {
  1143.     if(-e $file && ! -d _) {
  1144.         return $file;
  1145.     } else {
  1146.         return undef;
  1147.     }
  1148.     }
  1149.  
  1150.     for my $dir (@includes_dir) {
  1151.     my $path = "$dir/$file";
  1152.     $path =~ s|/+|/|isg;
  1153.     if(-e $path && ! -d _) {
  1154.         $self->{search_dirs_cache}{$cache_key} = $path;
  1155.         return $path;
  1156.     }
  1157.     }
  1158.  
  1159.     undef;
  1160. }
  1161.  
  1162. sub RegisterIncludes {
  1163.     my($self, $script) = @_;
  1164.  
  1165.     # compile includes at compile time, for prefork parse optimization
  1166.     my $copy = $$script;
  1167.     $copy =~ s/\$Response\-\>Include\([\'\"]([^\$]+?)[\'\"]/
  1168.       {
  1169.        my $include = $1;
  1170.        # prevent recursion
  1171.        unless($self->{register_includes}{$include}) {
  1172.        $self->{register_includes}{$include} = 1;
  1173.        local $self->{compile_error} = undef;
  1174.        local $self->{compile_eval} = undef;
  1175.        my $code = eval { $self->CompileInclude($include); };
  1176.        my $debug = $code ? "success" : "error: $@";
  1177.        $self->{dbg} && $self->Debug("register include $include with $debug");
  1178.        }
  1179.        '';
  1180.       }
  1181.     /exsgi;
  1182. }
  1183.  
  1184. sub CompileInclude {
  1185.     my($self, $include, $package, $is_base_script) = @_;
  1186.     my($include_ref, $mtime, $subid);
  1187.  
  1188.     local $self->{use_strict} = $self->{use_strict};
  1189.     if($include =~ /^Share::/) {
  1190.     # Share:: components must always run under UseStrict
  1191.     $self->{use_strict} = 1;
  1192.     }
  1193.     
  1194.     if ( ref $include ) {
  1195. #    $self->{dbg} && $self->Debug("compiling scalar data $include for include");
  1196.     $include_ref = $include;
  1197. #    $include = $$include;
  1198.     } else { # file here
  1199.     if($is_base_script) {
  1200.         # if its the base script being executed, then we already know
  1201.         # it exists because of earlier file tests, and do not need to
  1202.         # search for it
  1203.         #
  1204.         # leave $include alone
  1205.     } else {
  1206.         # streamlined, SearchDirs now caches per request
  1207.         my $file = &SearchDirs($self, $include);
  1208.         die("no include $include") unless defined $file;
  1209.         $include = $file;
  1210.     }
  1211.  
  1212.     # treat as anonymous subroutine compilation like data passed in 
  1213.     # as a scalar ref as above if we have NoCache set
  1214.     if($self->{no_cache}) {
  1215.         $include = $self->ReadFile($include);
  1216.         $include_ref = $include;
  1217.         goto COMPILE_INCLUDE_PARSE;
  1218.     }
  1219.  
  1220.     my $id = &FileId($self, $include);
  1221.     $subid = ($package || $self->{GlobalASA}{'package'})."::$id".'xINC';
  1222.  
  1223.     my $compiled = $Apache::ASP::CompiledIncludes{$subid};
  1224.     if($compiled && ! $self->{stat_scripts}) {
  1225.         $self->{dbg} && $self->Debug("no stat: found cached code for include $id");
  1226.         return $compiled;
  1227.     }
  1228.     
  1229.     # return cached code if include hasn't been modified recently
  1230.     $mtime = (stat($include))[9];
  1231.     if($compiled && ($compiled->{mtime} > $mtime)) {
  1232.         #    $self->Debug("found cached code for include $id");
  1233.  
  1234.         # now check for changed includes, return if not changed
  1235.         my $includes_changed = 0;
  1236.         if(my $includes = $Apache::ASP::Includes{$include}) {
  1237.         for my $k (keys %$includes) {
  1238.             my $v = $includes->{$k} || 0;
  1239.             my @stat = stat($k);
  1240.             if(@stat) {
  1241.             if($stat[9] >= $v) {
  1242.                 $self->{dbg} && $self->Debug("file $k mtime changed from $v to $stat[9]");
  1243.                 $includes_changed = 1;
  1244.                 last;
  1245.             }
  1246.             } else {
  1247.             $self->{dbg} && $self->Debug("can't get mtime for file $k: $!");
  1248.             $includes_changed = 1;
  1249.             last;
  1250.             }
  1251.         }
  1252.         }
  1253.  
  1254.         if(! $includes_changed) {
  1255.         return $compiled;
  1256.         } else {
  1257.         $self->{dbg} && $self->Debug("includes changed for $include, recompiling");
  1258.         }
  1259.     }
  1260.     }
  1261.  
  1262. COMPILE_INCLUDE_PARSE:
  1263.     
  1264.     my $parse_data = $self->Parse($include);
  1265.     my $no_cache = $self->{no_cache};
  1266.     my $data;
  1267.  
  1268. #    use Data::Dumper qw(Dumper);
  1269. #    print STDERR Dumper($include, $parse_data);
  1270. #    $self->Debug($self);
  1271.  
  1272.     if ($parse_data->{is_perl}) {
  1273.        my $sub = $self->CompilePerl($parse_data->{data}, $subid, $package);
  1274.  
  1275.        # for perl with subs in it, do not cache the code compilation
  1276.        # to help prevent my closure problems for newbies, --jc 2/11/2003
  1277.        unless($no_cache) {
  1278.        $no_cache = $self->TestForSubs($parse_data->{data});
  1279.        if($no_cache) {
  1280.            $self->Debug("test for subs returned $no_cache, no_cache = $no_cache");
  1281.        }
  1282.        }
  1283.  
  1284.        if ($sub) {
  1285.        $data = { 
  1286.             mtime => time(), 
  1287.             code => $sub,
  1288.                     perl => $parse_data->{data},
  1289.             file => $include_ref || $include,
  1290.            };
  1291.        }
  1292.     } elsif($parse_data->{is_raw}) {
  1293.        $data = {
  1294.                 mtime => time(),
  1295.                 code => $parse_data->{data},
  1296.                 perl => $parse_data->{data},
  1297.                 file => $include_ref || $include,
  1298.                };
  1299.     } else {
  1300.     $data = undef;
  1301.     }
  1302.  
  1303.     if ($data && $subid && ! $no_cache) { # for a returned code ref, don't cache
  1304.     $Apache::ASP::CompiledIncludes{$subid} = $data;
  1305.     }
  1306.  
  1307.     $data;
  1308. }
  1309.  
  1310. sub UndefRoutine {
  1311.     my($self, $subid) = @_;
  1312.  
  1313.     my $code = \&{$subid};
  1314.     if($code) {
  1315.     $self->{dbg} && $self->Debug("undefing sub $subid code $code");
  1316.     undef(&$code); # method for perl 5.6.1
  1317.     undef($code);  # older perls ??
  1318.     }
  1319. }
  1320.  
  1321. sub ReadFile {
  1322.     my($self, $file) = @_;
  1323.  
  1324.     local *READFILE;
  1325.     open(READFILE, $file) || $self->Error("can't open file $file for reading");
  1326.     local $/ = undef;
  1327.     my $data = <READFILE>;
  1328.     close READFILE;
  1329.  
  1330.     \$data;
  1331. }
  1332.  
  1333. # if the $file is an absolute path, then just return the file
  1334. # if the $file is a relative path, concat it with the passed in directory
  1335. sub AbsPath {
  1336.     my($file, $dir) = @_;
  1337.  
  1338.     # we test for first unix style and then win32 style path conventions
  1339.     if($file =~ m|^/| or $file =~ m|^.\:|) {
  1340.     $file;
  1341.     } else {
  1342.     # we only can absolute the path if the directory path is absolute
  1343.     if($dir =~ m|^/| or $dir =~ m|^.\:|) {
  1344.         $file = $dir.'/'.$file;
  1345.     } else {
  1346.         $file;
  1347.     }
  1348.     }
  1349. }       
  1350.  
  1351. sub CompilePerl {
  1352.     my($self, $script, $subid, $package) = @_;
  1353.     $package ||= $self->{GlobalASA}{'package'};
  1354.     $subid ||= '';
  1355.  
  1356.     ref($script) || die("no ref to perl script to compile");
  1357.     $subid && $self->UndefRoutine($subid);
  1358.     $self->{dbg} && $self->Debug("compiling into package $package subid [$subid]");    
  1359.  
  1360.     $self->{compile_perl_count}++; # counter used in test case closure.t
  1361.  
  1362.     my $eval = 
  1363.       join(" ;; ", 
  1364.        "package $package;", # for no sub closure
  1365.        "sub $subid { ",
  1366.        "package $package;", # for sub closure
  1367.        $$script,
  1368.        '}',
  1369.       );
  1370. #    $eval =~ tr///; # untaint
  1371.     $eval =~ /^(.*)$/s;
  1372.     $eval = $1;
  1373.  
  1374.     my $sub_ref;
  1375.  
  1376.     if($self->{use_strict}) { 
  1377.     local $SIG{__WARN__} = sub { die("maybe use strict error: ", @_) };
  1378.  
  1379.     # comment out for now, until 3.0 release for this may create lots
  1380.     # of compile time errors for people that will need to fix scripts
  1381.     #    local $^W = 1; # trigger my closure errors, --jc 9/7/2002
  1382.     $sub_ref = eval $eval;
  1383.     } else {
  1384.     local $SIG{__WARN__} = sub { $self->Out(@_) };
  1385.     $sub_ref = eval $eval;
  1386.     }
  1387.  
  1388.     my $rv; # for readability
  1389.     my $error = $@;
  1390.  
  1391.     if($@) {
  1392.     $self->CompileError($eval); # don't throw error, so we can throw die later
  1393.     $subid && $self->UndefRoutine($subid);
  1394.     $rv = undef;
  1395.     } else {
  1396.     if($subid) {
  1397.         if(&config($self, 'RegisterIncludes')) {
  1398.         $self->RegisterIncludes($script);
  1399.         }
  1400.         $rv = $subid;
  1401.     } else {
  1402.         $rv = $sub_ref;
  1403.     }
  1404.     }
  1405.  
  1406.     $@ = $error;
  1407.     $rv;
  1408. }
  1409.  
  1410. sub TestForSubs {
  1411.     my($self, $script) = @_;
  1412.     $$script =~ /(^|\n)\s*sub\s+([^\s\{]+)\s*\{/ ? 1 : 0;
  1413. }
  1414.  
  1415. sub InitPackageGlobals {
  1416.     my $self = shift;
  1417.  
  1418.     unless($self->{response_tied}) {
  1419.     # set printing to Response object
  1420.     $self->{response_tied} = 1;
  1421.     tie *RESPONSE, 'Apache::ASP::Response', $self->{Response};
  1422.     select(RESPONSE);
  1423.     }
  1424.  
  1425.     # ---- init package objects ----
  1426.     # unoptimized this because we should only call this function once
  1427.     # and maybe twice if there is a defined Script_OnStart
  1428.     for my $object (@Apache::ASP::Objects) {
  1429.     for my $import_package (@{$self->{init_packages}}) {
  1430.         my $init_var = $import_package.'::'.$object;
  1431.         $$init_var = $self->{$object};    }
  1432.     }
  1433.  
  1434.     undef;
  1435. }
  1436.  
  1437. sub Run {
  1438.     my $self = shift;    
  1439.  
  1440.     ($self->{stat_inc_match} || $self->{stat_inc}) && $self->StatINC;
  1441.  
  1442.     my $compiled;
  1443.     if(! $self->{errs}) {
  1444.     my $compile_file = $self->{filehandle}; # filehandle for filtering
  1445.     unless($compile_file) {
  1446.         # need SearchDirs() to make full path for base file, test suite is 
  1447.         # not OK with using $self->{filename}
  1448.         $compile_file = $self->SearchDirs($self->{basename});
  1449.         unless($compile_file) { 
  1450.         $self->Error("no file found for $self->{basename}");
  1451.         return;
  1452.         }
  1453.     }
  1454.  
  1455.     $compiled = $self->CompileInclude($compile_file, $self->{'package'}, 1);
  1456.  
  1457.     unless($compiled) {
  1458.         $self->Error("error compiling $self->{basename}: $@");
  1459.         return;
  1460.     }
  1461.     $self->{run_perl_script} = $compiled->{perl};
  1462.     }
  1463.  
  1464.     # must have all the variabled defined outside the scope
  1465.     # of the eval in case End() jumps to the goto below, since
  1466.     # the variables in the local eval{} scope will be cleared
  1467.     # upon return.
  1468.     my $global_asa = $self->{GlobalASA};
  1469.  
  1470.     eval { 
  1471.     $global_asa->{'exists'} && $global_asa->ScriptOnStart;
  1472.     $self->{errs} || $self->Execute($compiled->{code});
  1473.  
  1474.       APACHE_ASP_EXECUTE_END:
  1475.     $self->{errs} || ( $global_asa->{'exists'} && $global_asa->ScriptOnEnd() );
  1476.     $self->{errs} || $self->{Response}->EndSoft();
  1477.     };
  1478.  
  1479.     if($@) {
  1480.     # its not really a compile time error, but might be useful
  1481.     # to render for a runtime error anyway
  1482.     # $self->CompileError($compiled->{perl});
  1483.     $self->Error("error executing $self->{basename}: $@");
  1484.     }
  1485.  
  1486.     ! $@;
  1487. }
  1488.  
  1489. sub Execute {
  1490.     my($self, $code) = @_;
  1491.     $code || die("no subroutine passed to Execute()");
  1492.     $self->{dbg} && $self->Debug("executing $code");
  1493.  
  1494.     # set up globals as early as Application_OnStart, also
  1495.     # allows variables to be changed in Script_OnStart for running script
  1496.     &InitPackageGlobals($self);
  1497.  
  1498.     if(my $ref = ref $code) {
  1499.     if($ref eq 'CODE') {
  1500.         eval { &$code(); };
  1501.     } elsif($ref eq 'SCALAR') {
  1502. #        $self->{dbg} && $self->Debug("writing cached static file data $code, length: ".length($$code));
  1503.         $self->{Response}->WriteRef($code);
  1504.     } else {
  1505.         $self->Error("$code is a ref, but not CODE or SCALAR!");
  1506.     }
  1507.     } else {
  1508.     # if absolute package already, then no need to set to package namespace
  1509.     my $subid = ( $code =~ /::/ ) ? $code : $self->{GlobalASA}{'package'}.'::'.$code;
  1510.     eval { &$subid(); };
  1511.     }
  1512.  
  1513.     if($@) { 
  1514.     $self->Error($@); 
  1515.     }
  1516.     
  1517.     ! $@;
  1518. }
  1519.  
  1520. sub Cache {
  1521.     my($self, $cache_name, $key, $value, $expires, $last_modified, $no_check_meta) = @_;
  1522.     $cache_name || die("no cache_name given");
  1523.     grep($cache_name eq $_, qw(XSLT Response)) || die("cache_name $cache_name is invalid");
  1524.     return unless defined($key);
  1525.  
  1526.     my $cache_dbm = $self->{Caches}{$cache_name};
  1527.     if(defined $cache_dbm) {
  1528.     $self->{dbg} && $self->Debug("found cache $cache_dbm for $cache_name");
  1529.     } else {
  1530.     # load at runtime for CGI environments, preloaded for mod_perl
  1531.     require Apache::ASP::State;
  1532.  
  1533.     local $self->{state_dir} = &config($self, 'CacheDir') || $self->{state_dir};
  1534.     local $self->{state_db} = &config($self, 'CacheDB') || 'MLDBM::Sync::SDBM_File';
  1535.     $self->{dbg} && $self->Debug("CacheDB set to $self->{state_db}");
  1536.     $cache_dbm = Apache::ASP::State::new($self, $cache_name, 'cache')
  1537.       || ($self->Error("could not do cache $cache_name: $!") && return);
  1538.     $self->{Caches}{$cache_name} = $cache_dbm;
  1539.     $self->{dbg} && $self->Debug("init cache $cache_dbm for $cache_name");
  1540.     }
  1541.  
  1542.     $key = (ref($key) && ($key =~ /SCALAR/)) ? $$key : $key;
  1543.     my $checksum = &md5_hex($key).'x'.length($key);
  1544.     my $metakey = $checksum . 'xMETA';
  1545.     my $rv;
  1546.  
  1547.     eval {
  1548.     $cache_dbm->{dbm}->Lock;
  1549.     if(defined $value) {
  1550.         my $meta = { ServerID => $ServerID, Creation => time() };
  1551.         if(defined $expires && ($expires =~ /^\-?\d+$/)) {
  1552.         $meta->{Expires} = $expires;
  1553.         $meta->{Timeout} = time + $expires;
  1554.         };
  1555.         $self->{dbg} && $self->Debug("storing $checksum in $cache_name cache");
  1556.         $cache_dbm->STORE($metakey, $meta);
  1557.         $self->{cache_count_store}++;
  1558.         $rv = $cache_dbm->STORE($checksum, $value);
  1559.     } else {
  1560.         # don't check meta data for XSLT since transformations don't expire ever
  1561.         if($no_check_meta) {
  1562.         $self->{dbg} && $self->Debug("cache $cache_name fetch checksum $checksum no check meta");
  1563.         $self->{cache_count_fetch}++;
  1564.         $rv = $cache_dbm->{dbm}->FETCH($checksum);
  1565.         } else {
  1566.         my $meta = $cache_dbm->{dbm}->FETCH($metakey);
  1567.         my $new;
  1568.         if(! $meta) {
  1569.             $meta = { Creation => 0, ServerID => 'NULL' };
  1570.             $new = 1;
  1571.         } else {
  1572.             # NEW EXPIRES FOR EXISTING ITEM
  1573.             if(defined $expires && ($expires =~ /^\-?\d+$/) && ($expires != $meta->{Expires})) {
  1574.             $self->Debug("new expires $expires, old ".($meta->{Expires} || '')." for $checksum");
  1575.             $meta->{Expires} = $expires;
  1576.             # use creation timestamp for expires calculation, not current
  1577.             # time, or we would refresh the entry
  1578.             $meta->{Timeout} = $meta->{Creation} + $expires;
  1579.             $cache_dbm->STORE($metakey, $meta);
  1580.             };
  1581.         }
  1582.         
  1583.         # LastModified calculations
  1584.         if(defined $last_modified) {
  1585.             if($last_modified !~ /^\d+$/) {
  1586.             my $old_last_modified = $last_modified;
  1587.             $last_modified = &Apache::ASP::Date::str2time($last_modified);
  1588.             $self->{dbg} && $self->Debug("converting string date for LastModified $old_last_modified to unix time $last_modified");
  1589.             }
  1590.             if($last_modified < 0) {
  1591.             $self->{dbg} && $self->Debug("negative LastModified $last_modified ignored");
  1592.             $last_modified = undef;
  1593.             }
  1594.         }
  1595.         
  1596.         # EARLY TIMEOUT CALCULATION
  1597.         if($meta->{Timeout}) {
  1598.             # 10% chance to expire early to prevent collision
  1599.             my $early = ($meta->{Expires} || 0) * rand() * '.1';
  1600.             $self->{dbg} && $self->Debug("will reduce expires for $meta->{Expires} by random $early seconds, checksum $checksum");
  1601.             $meta->{Timeout} = $meta->{Timeout} - $early;
  1602.         }
  1603.         
  1604.         $self->{dbg} && $self->Debug("meta cache data for checksum $checksum", $meta);
  1605.         
  1606.         if($new) {
  1607.             $self->{dbg} && $self->Debug("no cache entry, checksum $checksum");
  1608.             $self->{cache_count_miss}++;
  1609.             $rv = undef;
  1610.         } elsif(defined $meta->{ServerID} && ($$ ne $ServerPID) && ($meta->{ServerID} ne $ServerID)) {
  1611.             # can only run like this when running in preloaded mod_perl mode
  1612.             # This will allow for caching in other modes that simply does not reset
  1613.             # upon server restart
  1614.             $self->{dbg} && $self->Debug("cache expires new server $ServerID, was $meta->{ServerID}");
  1615.             $self->{cache_count_restart}++;
  1616.             $rv = undef;
  1617.         } elsif($meta->{Timeout} && ($meta->{Timeout} <= time())) {
  1618.             $self->{dbg} && $self->Debug("cache expires timeout $meta->{Timeout}, checksum $checksum, time ".time);
  1619.             $self->{cache_count_expires}++;
  1620.             $rv = undef;
  1621.         } elsif(defined($last_modified) && ($last_modified >= $meta->{Creation})) {
  1622.             $self->{dbg} && $self->Debug("cache expires, checksum $checksum, LastModified $last_modified, Creation $meta->{Creation}");
  1623.             $self->{cache_count_last_modified_expires}++;
  1624.             $rv = undef;
  1625.         } else {
  1626.             $self->{dbg} && $self->Debug("cache $cache_name fetch checksum $checksum");
  1627.             $self->{cache_count_fetch}++;
  1628.             $rv = $cache_dbm->{dbm}->FETCH($checksum);
  1629.         }
  1630.         }
  1631.     }
  1632.     $cache_dbm->{dbm}->UnLock;
  1633.     };
  1634.     if($@) {
  1635.     $self->Out("[ASP WARN] error using cache $cache_name: $@");
  1636.     $self->{cache_count_error}++;
  1637.     eval { $cache_dbm->{dbm}->UnLock; };
  1638.     }
  1639.  
  1640.     $rv;
  1641. }
  1642.  
  1643. sub XSLT {
  1644.     my($self, $xsl_data, $xml_data) = @_;
  1645.     my $asp = $self;
  1646.  
  1647.     my $cache = &config($self, 'XSLTCache');
  1648.     my $cache_data = $$xsl_data.$$xml_data;
  1649.  
  1650.     if($cache) {
  1651.     if(my $data = $self->Cache('XSLT', \$cache_data, undef, undef, undef, 1)) {
  1652.         return $data;
  1653.     }
  1654.     }
  1655.  
  1656.     ref($xsl_data) || die("xsl data must be a scalar ref");
  1657.  
  1658.     my $xslt_parser = &config($self, 'XSLTParser') || 'XML::XSLT';
  1659.  
  1660.     my @parsers = ('XML::XSLT 0.32', 'XML::Sablotron', 'XML::LibXSLT');
  1661.     my $xslt_parser_lib;
  1662.     unless (($xslt_parser_lib) = grep(/^$xslt_parser/, @parsers)) {
  1663.     die("$xslt_parser must be one of: ".join(',', @parsers));
  1664.     }
  1665.  
  1666.     $asp->{dbg} && $asp->Debug("using xslt parser $xslt_parser_lib");
  1667.     eval "use $xslt_parser_lib";
  1668.     $@ && die("failed to load $xslt_parser_lib: $@");
  1669.  
  1670.     my $xslt_data = '';
  1671.     return \$xslt_data unless(length($$xsl_data) && length($$xml_data));
  1672.  
  1673.     if ($xslt_parser eq 'XML::XSLT') {
  1674.     my $xslt = XML::XSLT->new($xsl_data);
  1675.     $xslt->transform($xml_data);
  1676.     $xslt_data = $xslt->toString;
  1677.     $xslt->dispose;
  1678.     } elsif ($xslt_parser eq 'XML::Sablotron') {
  1679.     my $error = &XML::Sablotron::ProcessStrings($$xsl_data, $$xml_data, $xslt_data);
  1680.     if ($error) {
  1681.         die "error on XML::Sabltron::ProcessStrings: $error, $@, $!";
  1682.     }
  1683.     } elsif ($xslt_parser eq 'XML::LibXSLT') {
  1684.     my $parser = XML::LibXML->new();
  1685.     my $xslt = XML::LibXSLT->new();
  1686.     my $source = $parser->parse_string($$xml_data);
  1687.     my $style_doc = $parser->parse_string($$xsl_data);
  1688.     my $stylesheet = $xslt->parse_stylesheet($style_doc);
  1689.     my $results = $stylesheet->transform($source);
  1690.     $xslt_data = $stylesheet->output_string($results);
  1691.     }
  1692.  
  1693.     if($cache) {
  1694.     $self->Cache('XSLT', \$cache_data, \$xslt_data);
  1695.     }
  1696.  
  1697.     \$xslt_data;
  1698. }
  1699.  
  1700. sub Log {
  1701.     my($self, @msg) = @_;
  1702.     my $msg = join(" ", @msg);
  1703.     $msg =~ s/[\r\n]+/ \<\-\-\> /sg;    
  1704.     if($self->{r}) {
  1705.     $self->{r}->log_error("[asp] [$$] $msg");
  1706.     } else {
  1707.     print STDERR "[WARN] [asp] [$$] [Invalid ASP Object $self] $msg\n";
  1708.     }
  1709. }
  1710.  
  1711. sub CompileErrorThrow {
  1712.     my($self, $eval, @errors) = @_;
  1713.     $self->CompileError($eval);
  1714.     $self->Error(@errors);
  1715. }
  1716.  
  1717. sub CompileError {
  1718.     my($self, $eval) = (shift, shift);
  1719.     $self->{compile_error} = 1;
  1720.     if(ref $eval) {
  1721.     my $copy_eval = $$eval;
  1722.     $self->{compile_eval} = \$copy_eval;
  1723.     } else {
  1724.     $self->{compile_eval} = \$eval;
  1725.     }
  1726. }
  1727.  
  1728. sub Error {
  1729.     my($self, $msg) = @_;
  1730.     
  1731.     my($package, $filename, $line) = caller;
  1732.     $msg .= ", $filename line $line";
  1733.     
  1734.     # error logging in $self
  1735.     $self->{errs}++;
  1736.     my $pretty_msg = $msg;
  1737.     $pretty_msg = $self->Escape($pretty_msg);
  1738.     $pretty_msg =~ s/\n/<br>/sg;
  1739.  
  1740.     push(@{$self->{errors_output}}, $msg);
  1741.     push(@{$self->{debugs_output}}, $msg);
  1742.     
  1743.     $self->Log("[error] $msg");
  1744.     
  1745.     1;
  1746. }   
  1747.  
  1748. # sub Debug { # for matching
  1749. *Debug = *Out; # default
  1750. sub Null() { 0; }; # prototype for inlining hopefully
  1751. sub Out {
  1752.     my($self, @args) = @_;
  1753.  
  1754.     # already know because of aliasing
  1755.     #    return unless $_[0]->{dbg};
  1756.  
  1757.     my(@data, $arg);
  1758.     while(@args) {
  1759.     $arg = shift @args;
  1760.     my($ref, $data);
  1761.     if($ref = ref($arg)) {
  1762.         if($arg =~ /HASH/) {
  1763.         $data = '';
  1764.         for my $key (sort keys %{$arg}) {
  1765.             my $value = defined($arg->{$key}) ? $arg->{$key} : '';
  1766.             $data .= "$key: $value; ";
  1767.         }
  1768.         } elsif($arg =~ /ARRAY/) {
  1769.         $data = join('; ', @$arg);
  1770.         } elsif($arg =~ /SCALAR/) {
  1771.         $data = $$arg;
  1772.         } elsif($arg =~ /CODE/) {
  1773.         my $out = eval { &$arg };
  1774.         if($@) {
  1775.             $data = $@;
  1776.         } else {
  1777.             unshift(@args, $out);
  1778.             next;
  1779.         }
  1780.         } else {
  1781.         $data = $arg;
  1782.         }
  1783.     } else {
  1784.         $data = $arg;
  1785.     }
  1786.     push(@data, $data);
  1787.     }
  1788.  
  1789.     my $debug = join(' - ', @data);
  1790.     my $time = '';
  1791.     if($self->{dbg} >= 3) {
  1792.     # use require, not LoadModule, so to avoid Debug recursion
  1793.     if(eval { require Time::HiRes; }) {
  1794.         $time = sprintf("%.4f", Time::HiRes::time());
  1795.         my $diff = sprintf("%.4f", $time - ($self->{last_time} || $time));
  1796.         $self->{last_time} = $time;
  1797.         $time = " [$time;$diff]";        
  1798.     }
  1799.     }
  1800.     $self->Log("[debug]$time $debug");
  1801.     push(@{$self->{debugs_output}}, $debug);
  1802.     
  1803.     # someone might try to insert a debug as a scalar, better 
  1804.     # not to print anything
  1805.     undef; 
  1806. }
  1807.  
  1808. sub Escape {
  1809.     my($self, $html) = @_;
  1810.  
  1811.     $html =~s/&/&/gs;
  1812.     $html =~s/\"/"/gs;
  1813.     $html =~s/>/>/gs;
  1814.     $html =~s/</</gs;
  1815.  
  1816.     $html;
  1817. }
  1818.  
  1819. # quickly decomped out of Apache::ASP just to optionally load
  1820. # it at runtime for CGI programs ( which shouldn't need it anyway )
  1821. # will still precompile this for mod_perl
  1822. #
  1823. sub StatINC {
  1824.     my $self = shift;
  1825.     require Apache::ASP::StatINC;
  1826.     $self->StatINCRun;
  1827. }
  1828.  
  1829. sub SendMail {
  1830.     my($self, $mail, %args) = @_;
  1831.     my($smtp, @to, $server);
  1832.     my $rv = 1;
  1833.  
  1834.     # load option mail modules
  1835.     for('Net::Config', 'Net::SMTP') {
  1836.     eval "use $_";
  1837.     if($@) {
  1838.         die("no mailing errors because can't load $_: $@");
  1839.         return 0;
  1840.     }
  1841.     }
  1842.     
  1843.     # configure mail host
  1844.     if($self->{mail_host} = &config($self, 'MailHost')) {
  1845.     unless($NetConfig{smtp_hosts} && (($NetConfig{smtp_hosts}->[0] || '') eq $self->{mail_host})) {
  1846.         unshift(@{$NetConfig{smtp_hosts}}, $self->{mail_host});
  1847.     }
  1848.     }
  1849.     $mail->{From} ||= &config($self, 'MailFrom');
  1850.  
  1851.     unless($mail->{Test}) {
  1852.     for('To', 'Body', 'Subject', 'From') {
  1853.         $mail->{$_} ||
  1854.           die("need $_ argument to send mail");
  1855.     }
  1856.     }
  1857.  
  1858.     # debugging set in mail args, or general debugging
  1859.     if(! defined($args{Debug}) && defined($mail->{Debug})) {
  1860.     $args{Debug} = $mail->{Debug};
  1861.     delete $mail->{Debug};
  1862.     }
  1863.     if(! defined($args{Debug})) {
  1864.     # in case of system level debugging, mark Net::SMTP debug also
  1865.     if((&config($self, 'Debug') || 0) < 0) {
  1866.         $args{Debug} = 1;
  1867.     }
  1868.     }
  1869.  
  1870.     # connect to server
  1871.     {
  1872.     local $SIG{__WARN__} = sub { $self->Debug('Net::SMTP->new() warning', @_) };
  1873.     if($mail->{Test}) {
  1874.         $args{Timeout} = 5;
  1875.     }
  1876.     $smtp = Net::SMTP->new(%args);
  1877.     }
  1878.     unless($smtp) {
  1879.     $self->Out("[ERROR] can't connect to SMTP server with args ", \%args);
  1880.     return 0;
  1881.     } else {
  1882.     $self->Debug("connected to SMTP server with args ", \%args);
  1883.     }
  1884.  
  1885.     for my $receivers (qw(To BCC CC)) {
  1886.     next unless $mail->{$receivers};
  1887.     my @receivers = (ref $mail->{$receivers}) ? @{$mail->{$receivers}} : (split(/\s*,\s*/, $mail->{$receivers}));
  1888.     push(@to, @receivers);
  1889.     }
  1890.  
  1891.     $self->Debug("sending mail to: ".join(',', @to));
  1892.     ($mail->{From}) = split(/\s*,\s*/,($mail->{From} || '')); # just the first one
  1893.  
  1894.     $smtp->mail($mail->{From}) || return(0);
  1895.  
  1896.     # put test before $smtp->to() because we might get a relaying denied error otherwise
  1897.     if($mail->{Test}) {
  1898.     return $rv;
  1899.     }
  1900.  
  1901.     $smtp->to(@to) || return(0);
  1902.  
  1903.     my($data);
  1904.     my $body = $mail->{Body};
  1905.     delete $mail->{Body};
  1906.  
  1907.     # assumes MIME-Version 1.0 for Content-Type header, according to RFC 1521
  1908.     # http://www.ietf.org/rfc/rfc1521.txt
  1909.     if($mail->{'Content-Type'} && ! $mail->{'MIME-Version'}) {
  1910.     $mail->{'MIME-Version'} = '1.0';
  1911.     }
  1912.  
  1913.     my %done;
  1914.     for('Subject', 'From', 'Reply-To', 'Organization', 'To', keys %$mail) {
  1915.     next unless $mail->{$_};
  1916.     next if $done{lc($_)}++;    
  1917.     my $add = ref($mail->{$_}) ? join(",", @{$mail->{$_}}) : $mail->{$_};
  1918.     $add =~ s/^[\n]*(.*?)[\n]*$/$1/;
  1919.     $data .= "$_: $add\n";
  1920.     }
  1921.     $data .= "\n" . $body;
  1922.  
  1923.     $smtp->data($data) || ($rv = 0);
  1924.     $smtp->quit();
  1925.  
  1926.     $rv && $self->Debug("mail sent successfully");
  1927.     $rv;
  1928. }
  1929.  
  1930. *LoadModule = *LoadModules;
  1931. sub LoadModules {
  1932.     my($self, $category, @modules) = @_;
  1933.     my $load_errors = 0;
  1934.     
  1935.     for(@modules) {
  1936.     if(defined $LoadedModules{$_}) {
  1937.         if($LoadedModules{$_} == 0) {
  1938.         if($LoadModuleErrors{$category}) {
  1939.             $self->Error("cannot load $_ for $category: $LoadModuleErrors{$category}; $@");
  1940.         } else {
  1941.             $self->Debug("already failed to load $_");
  1942.         }
  1943.         $load_errors++;
  1944.         } 
  1945.         next;
  1946.     }
  1947.  
  1948.     $_ =~ tr///; # untaint
  1949.     eval "use $_";
  1950.     if($@) { 
  1951.         if($LoadModuleErrors{$category}) {
  1952.         $self->Error("cannot load $_ for $category: $LoadModuleErrors{$category}; $@");
  1953.         } else {
  1954.         # don't wan't Log() output for make test when optional modules aren't installed
  1955.         # is not installed, --jc 6/11/2001
  1956.         $self->Debug("cannot load $_ for $category: $@");
  1957.         }
  1958.         $load_errors++;
  1959.         $LoadedModules{$_} = 0;
  1960.     } else {
  1961.         $self->{dbg} && $self->Debug("loaded module $_");
  1962.         $LoadedModules{$_} = 1;
  1963.     }
  1964.     }
  1965.     
  1966.     ! $load_errors;
  1967. }
  1968.  
  1969. sub Loader {
  1970.     # this is enough to load Apache::ASP::Load, we only need to do it
  1971.     # at runtime since the purpose of Loader() is to be run from 
  1972.     # the httpd.conf during parent startup time, so this module will
  1973.     # be cached just fine at that time.
  1974.     #
  1975.     require Apache::ASP::Load;
  1976.     &Apache::ASP::Load::Run(@_);
  1977. }
  1978.  
  1979. sub DSOError {
  1980.     my $r = shift;
  1981.  
  1982.     # this could happen with a bad filtering sequence
  1983.     warn(<<ERROR);
  1984. No valid request object ($r) passed to ASP handler
  1985.  
  1986. If you are getting this error message and are using mod_perl 1.x and Apache 1.x,
  1987. you likely have a broken DSO version of mod_perl which often occurs
  1988. when using RedHat RPMs.  One fix reported is to configure "PerlSendHeader On".
  1989. Another fix is to compile statically the apache + mod_perl build as
  1990. RedHat RPMs have been trouble.
  1991.  
  1992. If you are using a newer mod_perl2 + Apache2, make sure you have
  1993. upgraded to the last Apache::ASP release, and report the issue
  1994. if problems continue to the Apache::ASP mailing list.  As of
  1995. December 2002, mod_perl2 + Apache2 combination is still experimental
  1996. and under development.
  1997.  
  1998. Please check FAQ or mod_perl archives for more information.
  1999.  
  2000. ERROR
  2001.   ;
  2002.  
  2003.     500;
  2004. }
  2005.  
  2006. sub CompileChecksumKeys() { \@CompileChecksumKeys };
  2007.  
  2008. sub get_dir_config {
  2009.     my $rv = shift->get(shift);
  2010.     if(lc($rv) eq 'off') {
  2011.     $rv = 0; # Off always becomes 0
  2012.     }
  2013.     $rv;
  2014. }
  2015.  
  2016. *Config = *config;
  2017. sub config {
  2018.     my($self, $key, $value, $default) = @_;
  2019.     my $dir_config = $self->{dir_config};
  2020.  
  2021.     if(defined $value) {
  2022.     $dir_config->set($key, $value);
  2023.     } elsif(defined $key) {
  2024.     my $rv = $dir_config->get($key);
  2025.     if(defined($rv)) {
  2026.         if(lc($rv) eq 'off') {
  2027.         $rv = 0; # Off always becomes 0
  2028.         }
  2029.     } else {
  2030.         # use default value if none is returned
  2031.         if(defined($default)) {
  2032.         $rv = $default;
  2033.         }
  2034.     }
  2035.     $rv;
  2036.     } else {
  2037.     $dir_config;
  2038.     }
  2039. }
  2040.  
  2041. 1;
  2042.  
  2043. __END__
  2044.  
  2045. =pod
  2046.  
  2047. =head1 NAME
  2048.  
  2049.   Apache::ASP - Active Server Pages for Apache with mod_perl 
  2050.  
  2051. =head1 SYNOPSIS
  2052.  
  2053.   SetHandler  perl-script
  2054.   PerlModule  Apache::ASP
  2055.   PerlHandler Apache::ASP
  2056.   PerlSetVar  Global /tmp/asp
  2057.  
  2058. =head1 DESCRIPTION
  2059.  
  2060. Apache::ASP provides an Active Server Pages port to the 
  2061. Apache Web Server with Perl scripting only, and enables developing 
  2062. of dynamic web applications 
  2063. with session management and embedded Perl code.  There are also 
  2064. many powerful extensions, including XML taglibs, XSLT rendering, 
  2065. and new events not originally part of the ASP API!
  2066.  
  2067. =begin html
  2068.  
  2069. <table class="noescape" border="0"><tr><td>
  2070. <b>Apache::ASP's features include:</b>
  2071. <font face=verdana,helvetica,arial size=-1>
  2072. <ul>
  2073. <li> Scripting SYNTAX is Natural and Powerful 
  2074. <li> Rich OBJECTS Developer API
  2075. <li> Web Application EVENTS Model
  2076. <li> Modular SSI Decomposition, Code Sharing
  2077. <li> User SESSIONS, CIFS & NFS Cluster Ready
  2078. <li> XML/XSLT Rendering & Custom Tag Technology
  2079. <li> CGI Compatibility
  2080. <li> PERLSCRIPT Compatibility
  2081. <li> Great Open Source SUPPORT
  2082. </ul>
  2083. </font>
  2084. </table>
  2085.  
  2086. =end html
  2087.  
  2088. This module works under the Apache Web Server
  2089. with the mod_perl module enabled. See http://www.apache.org and
  2090. http://perl.apache.org for further information.
  2091.  
  2092. This is a portable solution, similar to ActiveState's PerlScript
  2093. for NT/IIS ASP.  Work has been done and will continue to make ports 
  2094. to and from this implementation as smooth as possible.
  2095.  
  2096. For Apache::ASP downloading and installation, please read 
  2097. the INSTALL section.  For installation troubleshooting
  2098. check the FAQ and the SUPPORT sections.
  2099.  
  2100. For database access, ActiveX, scripting languages, and other
  2101. miscellaneous issues please read the FAQ section.
  2102.  
  2103. =head1 WEBSITE
  2104.  
  2105. The Apache::ASP web site is at http://www.apache-asp.org/
  2106. which you can also find in the ./site directory of 
  2107. the source distribution.
  2108.  
  2109. =head1 INSTALL
  2110.  
  2111. The installation process for Apache::ASP is geared towards those
  2112. with experience with Perl, Apache, and unix systems.  For those
  2113. without this experience, please understand that the learning curve 
  2114. can be significant.  But what you have at the end will be a web site
  2115. running on superior open source software.
  2116.  
  2117. If installing onto a Windows operating system, please see the section
  2118. titled Win32 Install.
  2119.  
  2120. =head2 Need Help
  2121.  
  2122. Often, installing the mod_perl part of the Apache server
  2123. can be the hardest part.  If this is the case for you, 
  2124. check out the FAQ and SUPPORT sections for further help,
  2125. as well as the "Build Apache" notes in this section.
  2126.  
  2127. Please also see the mod_perl guide at http://perl.apache.org/guide
  2128. which one ought to give a good read before undertaking
  2129. a mod_perl project.
  2130.  
  2131. =head2 Download and CPAN Install
  2132.  
  2133. You may download the latest Apache::ASP from your nearest CPAN,
  2134. and also:
  2135.  
  2136.   http://cpan.org/modules/by-module/Apache/
  2137.   ftp://ftp.duke.edu/pub/perl/modules/by-module/Apache/
  2138.  
  2139. As a Perl developer, you should make yourself familiar with 
  2140. the CPAN.pm module, and how it may be used to install
  2141. Apache::ASP, and other related modules.  The easiest way
  2142. to install Apache::ASP for the first time from Perl is to 
  2143. fire up the CPAN shell like:
  2144.  
  2145.  shell prompt> perl -MCPAN -e shell
  2146.   ... configure CPAN ...
  2147.   ... then upgrade to latest CPAN ...
  2148.  cpan> install CPAN
  2149.   ...
  2150.  cpan> install Bundle::Apache::ASP
  2151.  
  2152. Installing the Apache::ASP bundle will automatically install
  2153. all the modules Apache::ASP is dependent on as well as
  2154. Apache::ASP itself.  If you have trouble installing the bundle,
  2155. then try installing the necessary modules one at a time:
  2156.  
  2157.  cpan> install MLDBM
  2158.  cpan> install MLDBM::Sync
  2159.  cpan> install Digest::MD5  *** may not be needed for perl 5.8+ ***
  2160.  cpan> install Apache::ASP
  2161.  
  2162. For extra/optional functionality in Apache::ASP 2.31 or greater, like
  2163. support for FormFill, XSLT, or SSI, you can install this bundle via CPAN:
  2164.  
  2165.   cpan> install Bundle::Apache::ASP::Extra
  2166.  
  2167. =head2 Regular Perl Module Install
  2168.  
  2169. If not doing the CPAN install, download Apache::ASP and install it using 
  2170. the make or nmake commands as shown below.  Otherwise, just 
  2171. copy ASP.pm to $PERLLIB/site/Apache
  2172.  
  2173.   > perl Makefile.PL
  2174.   > make 
  2175.   > make test
  2176.   > make install
  2177.  
  2178.   * use nmake for win32
  2179.  
  2180. Please note that you must first have the Apache Web Server
  2181. & mod_perl installed before using this module in a web server
  2182. environment.  The offline mode for building static html at
  2183. ./cgi/asp may be used with just perl.
  2184.  
  2185. =head2 Win32 / Windows Install
  2186.  
  2187. If you are on a Win32 platform, like WinNT or Windows 2000, 
  2188. you can download the win32 binaries linked to from:
  2189.  
  2190.   http://perl.apache.org/distributions.html  
  2191.  
  2192. From here, I would recommend the mod_perl binary installation at:
  2193.  
  2194.   ftp://theoryx5.uwinnipeg.ca/pub/other/
  2195.  
  2196. and install the latest perl-win32-bin-*.exe file.
  2197.  
  2198. Randy Kobes has graciously provided these, which include
  2199. compiled versions perl, mod_perl, apache, mod_ssl,
  2200. as well as all the modules required by Apache::ASP
  2201. and Apache::ASP itself.
  2202.  
  2203. You may also try the more recent Perl-5.8-win32-bin.exe
  2204. distribution which is built on Apache 2.  This should be
  2205. treated as BETA release software until mod_perl 2.x is 
  2206. released as stable. Some notes from Randy Kobes about 
  2207. getting this release to work are here:
  2208.  
  2209.   After installing this distribution, in Apache2\conf\perl.conf
  2210.   (pulled in via Apache2\conf\httpd.conf) there's directives that
  2211.   have Apache::ASP handle files placed under the Apache2\asp\
  2212.   directory. There should be a sample Apache::ASP script there,
  2213.   printenv.html, accessed as http://127.0.0.1/asp/printenv.html
  2214.   which, if working, will print out your environment variables.
  2215.  
  2216. =head2 WinME / 98 / 95 flock() workaround
  2217.  
  2218. For those on desktop Windows operation systems, Apache::ASP v2.25 and
  2219. later needs a special work around for the lack of flock() support
  2220. on these systems.  Please add this to your Apache httpd.conf to
  2221. fix this problem after mod_perl is installed:
  2222.  
  2223.   <Perl>
  2224.    *CORE::GLOBAL::flock = sub { 1 };
  2225.   </Perl>
  2226.   PerlModule  Apache::ASP
  2227.  
  2228. Please be sure to add this configuration before Apache::ASP is loaded
  2229. via PerlModule, or a PerlRequire statement.
  2230.  
  2231. =head2 Linux DSO Distributions
  2232.  
  2233. If you have a linux distribution, like a RedHat Linux server,
  2234. with an RPM style Apache + mod_perl, seriously consider building 
  2235. a static version of the httpd server yourself, not DSO.  
  2236. DSO is marked as experimental for mod_perl, and often does 
  2237. not work, resulting in "no request object" error messages,
  2238. and other oddities, and are terrible to debug, because of
  2239. the strange kinds of things that can go wrong.
  2240.  
  2241. =head2 Build Apache and mod_perl
  2242.  
  2243. For a quick build of apache, there is a script in the distribution at
  2244. ./make_httpd/build_httpds.sh that can compile a statically linked
  2245. Apache with mod_ssl and mod_perl.  Just drop the sources into the 
  2246. make_httpd directory, configure the environments as appropriate,
  2247. and execute the script like this: 
  2248.  
  2249.  make_httpd> ./build_httpds.sh
  2250.  
  2251. You might also find helpful a couple items:
  2252.  
  2253.   Stas's mod_perl guide install section
  2254.   http://perl.apache.org/guide/install.html
  2255.  
  2256.   Apache Toolbox
  2257.   http://www.apachetoolbox.com/
  2258.  
  2259. People have been using Apache Toolbox to automate their 
  2260. complex builds with great success.
  2261.  
  2262. =head2 Quick Start
  2263.  
  2264. Once you have successfully built the Apache Web Server with mod_perl,
  2265. copy the ./site/eg/ directory from the Apache::ASP installation 
  2266. to your Apache document tree and try it out!  You must put "AllowOverride All"
  2267. in your httpd.conf <Directory> config section to let the .htaccess file in the 
  2268. ./site/eg installation directory do its work.  If you want a starter
  2269. config file for Apache::ASP, just look at the .htaccess file in the 
  2270. ./site/eg/ directory.
  2271.  
  2272. So, you might add this to your Apache httpd.conf file just to get 
  2273. the scripts in ./site/eg working, where $DOCUMENT_ROOT represents
  2274. the DocumentRoot config for your apache server:
  2275.  
  2276.   <Directory $DOCUMENT_ROOT/asp/eg >
  2277.     Options FollowSymLinks
  2278.     AllowOverride All
  2279.   </Directory>
  2280.  
  2281. To copy the entire site, including the examples, you might
  2282. do a raw directory copy as in:
  2283.  
  2284.   shell> cp -rpd ./site $DOCUMENT_ROOT/asp
  2285.  
  2286. So you could then reference the Apache::ASP docs at /asp/ at your site,
  2287. and the examples at /asp/eg/ .
  2288.  
  2289. This is not a good production configuration, because it is insecure
  2290. with the FollowSymLinks, and tells Apache to look for .htaccess 
  2291. which is bad for performance but it should be handy for getting 
  2292. started with development.
  2293.  
  2294. You will know that Apache::ASP is working normally if you 
  2295. can run the scripts in ./site/eg/ without any errors.  Common
  2296. problems can be found in the FAQ section.
  2297.  
  2298. =head1 CONFIG
  2299.  
  2300. You may use a <Files ...> directive in your httpd.conf 
  2301. Apache configuration file to make Apache::ASP start ticking.  Configure the
  2302. optional settings if you want, the defaults are fine to get started.  
  2303. The settings are documented below.  
  2304. Make sure Global is set to where your web applications global.asa is 
  2305. if you have one!
  2306.  
  2307.  PerlModule  Apache::ASP
  2308.  <Files ~ (\.asp)>    
  2309.    SetHandler  perl-script
  2310.    PerlHandler Apache::ASP
  2311.    PerlSetVar  Global .
  2312.    PerlSetVar  StateDir /tmp/asp
  2313.  </Files>
  2314.  
  2315. NOTE: do not use this for the examples in ./site/eg.  To get the 
  2316. examples working, check out the Quick Start section of INSTALL
  2317.  
  2318. You may use other Apache configuration tags like <Directory>,
  2319. <Location>, and <VirtualHost>, to separately define ASP
  2320. configurations, but using the <Files> tag is natural for
  2321. ASP application building because it lends itself naturally
  2322. to mixed media per directory.  For building many separate
  2323. ASP sites, you might want to use separate .htaccess files,
  2324. or <Files> tags in <VirtualHost> sections, the latter being
  2325. better for performance.
  2326.  
  2327. =head2 Core
  2328.  
  2329. =item Global
  2330.  
  2331. Global is the nerve center of an Apache::ASP application, in which
  2332. the global.asa may reside defining the web application's 
  2333. event handlers.
  2334.  
  2335. This directory is pushed onto @INC, so you will be able 
  2336. to "use" and "require" files in this directory, and perl modules 
  2337. developed for this application may be dropped into this directory, 
  2338. for easy use.
  2339.  
  2340. Unless StateDir is configured, this directory must be some 
  2341. writeable directory by the web server.  $Session and $Application 
  2342. object state files will be stored in this directory.  If StateDir
  2343. is configured, then ignore this paragraph, as it overrides the 
  2344. Global directory for this purpose.
  2345.  
  2346. Includes, specified with <!--#include file=somefile.inc--> 
  2347. or $Response->Include() syntax, may also be in this directory, 
  2348. please see section on includes for more information.
  2349.  
  2350.   PerlSetVar Global /tmp
  2351.  
  2352. =item GlobalPackage
  2353.  
  2354. Perl package namespace that all scripts, includes, & global.asa
  2355. events are compiled into.  By default, GlobalPackage is some
  2356. obscure name that is uniquely generated from the file path of 
  2357. the Global directory, and global.asa file.  The use of explicitly
  2358. naming the GlobalPackage is to allow scripts access to globals
  2359. and subs defined in a perl module that is included with commands like:
  2360.  
  2361.   in perl script: use Some::Package;
  2362.   in apache conf: PerlModule Some::Package
  2363.  
  2364.   PerlSetVar GlobalPackage Some::Package
  2365.  
  2366. =item UniquePackages
  2367.  
  2368. default 0.  Set to 1 to compile each script into its own perl package,
  2369. so that subroutines defined in one script will not collide with another.
  2370.  
  2371. By default, ASP scripts in a web application are compiled into the 
  2372. *same* perl package, so these scripts, their includes, and the 
  2373. global.asa events all share common globals & subroutines defined by each other.
  2374. The problem for some developers was that they would at times define a 
  2375. subroutine of the same name in 2+ scripts, and one subroutine definition would
  2376. redefine the other one because of the namespace collision.
  2377.  
  2378.   PerlSetVar UniquePackages 0
  2379.  
  2380. =item DynamicIncludes
  2381.  
  2382. default 0.  SSI file includes are normally inlined in the calling 
  2383. script, and the text gets compiled with the script as a whole. 
  2384. With this option set to TRUE, file includes are compiled as a
  2385. separate subroutine and called when the script is run.  
  2386. The advantage of having this turned on is that the code compiled
  2387. from the include can be shared between scripts, which keeps the 
  2388. script sizes smaller in memory, and keeps compile times down.
  2389.  
  2390.   PerlSetVar DynamicIncludes 0
  2391.  
  2392. =item IncludesDir
  2393.  
  2394. no defaults.  If set, this directory will also be used to look
  2395. for includes when compiling scripts.  By default the directory 
  2396. the script is in, and the Global directory are checked for includes.  
  2397.  
  2398. This extension was added so that includes could be easily shared
  2399. between ASP applications, whereas placing includes in the Global
  2400. directory only allows sharing between scripts in an application.
  2401.  
  2402.   PerlSetVar IncludesDir .
  2403.  
  2404. Also, multiple includes directories may be set by creating
  2405. a directory list separated by a semicolon ';' as in
  2406.  
  2407.   PerlSetVar IncludesDir ../shared;/usr/local/asp/shared
  2408.  
  2409. Using IncludesDir in this way creates an includes search
  2410. path that would look like ., Global, ../shared, /usr/local/asp/shared
  2411. The current directory of the executing script is checked first
  2412. whenever an include is specified, then the Global directory
  2413. in which the global.asa resides, and finally the IncludesDir 
  2414. setting.
  2415.  
  2416. =item NoCache
  2417.  
  2418. Default 0, if set to 1 will make it so that neither script nor
  2419. include compilations are cached by the server.  Using this configuration
  2420. will save on memory but will slow down script execution.  Please
  2421. see the TUNING section for other strategies on improving site performance.
  2422.  
  2423.   PerlSetVar NoCache 0
  2424.  
  2425. =head2 State Management
  2426.  
  2427. =item NoState
  2428.  
  2429. default 0, if true, neither the $Application nor $Session objects will
  2430. be created.  Use this for a performance increase.  Please note that 
  2431. this setting takes precedence over the AllowSessionState and
  2432. AllowApplicationState settings.
  2433.  
  2434.   PerlSetVar NoState 0
  2435.  
  2436. =item AllowSessionState
  2437.  
  2438. Set to 0 for no session tracking, 1 by default
  2439. If Session tracking is turned off, performance improves,
  2440. but the $Session object is inaccessible.
  2441.  
  2442.   PerlSetVar AllowSessionState 1    
  2443.  
  2444. Note that if you want to dissallow session creation
  2445. for certain non web browser user agents, like search engine
  2446. spiders, you can use an init handler like:
  2447.  
  2448.   PerlInitHandler "sub { $_[0]->dir_config('AllowSessionState', 0) }"
  2449.  
  2450. =item AllowApplicationState
  2451.  
  2452. Default 1.  If you want to leave $Application undefined, then set this
  2453. to 0, for a performance increase of around 2-3%.  Allowing use of 
  2454. $Application is less expensive than $Session, as there is more
  2455. work for the StateManager associated with $Session garbage collection
  2456. so this parameter should be only used for extreme tuning.
  2457.  
  2458.   PerlSetVar AllowApplicationState 1
  2459.  
  2460. =item StateDir
  2461.  
  2462. default $Global/.state.  State files for ASP application go to 
  2463. this directory.  Where the state files go is the most important
  2464. determinant in what makes a unique ASP application.  Different
  2465. configs pointing to the same StateDir are part of the same
  2466. ASP application.
  2467.  
  2468. The default has not changed since implementing this config directive.
  2469. The reason for this config option is to allow operating systems with caching
  2470. file systems like Solaris to specify a state directory separately
  2471. from the Global directory, which contains more permanent files.
  2472. This way one may point StateDir to /tmp/myaspapp, and make one's ASP
  2473. application scream with speed.
  2474.  
  2475.   PerlSetVar StateDir ./.state
  2476.  
  2477. =item StateManager
  2478.  
  2479. default 10, this number specifies the numbers of times per SessionTimeout
  2480. that timed out sessions are garbage collected.  The bigger the number,
  2481. the slower your system, but the more precise Session_OnEnd's will be 
  2482. run from global.asa, which occur when a timed out session is cleaned up,
  2483. and the better able to withstand Session guessing hacking attempts.
  2484. The lower the number, the faster a normal system will run.  
  2485.  
  2486. The defaults of 20 minutes for SessionTimeout and 10 times for 
  2487. StateManager, has dead Sessions being cleaned up every 2 minutes.
  2488.  
  2489.   PerlSetVar StateManager 10
  2490.  
  2491. =item StateDB
  2492.  
  2493. default SDBM_File, this is the internal database used for state
  2494. objects like $Application and $Session.  Because an SDBM_File %hash 
  2495. has a limit on the size of a record key+value pair, usually 1024 bytes,
  2496. you may want to use another tied database like DB_File or
  2497. MLDBM::Sync::SDBM_File.
  2498.  
  2499. With lightweight $Session and $Application use, you can get 
  2500. away with SDBM_File, but if you load it up with complex data like
  2501.   $Session{key} = { # very large complex object }
  2502. you might max out the 1024 limit.
  2503.  
  2504. Currently StateDB can be: SDBM_File, MLDBM::Sync::SDBM_File,
  2505. DB_File, and GDBM_File.  Please let me know if you would like to
  2506. add any more to this list.
  2507.  
  2508. As of version .18, you may change this setting in a live production
  2509. environment, and new state databases created will be of this format.
  2510. With a prior version if you switch to a new StateDB, you would want to 
  2511. delete the old StateDir, as there will likely be incompatibilities between
  2512. the different database formats, including the way garbage collection
  2513. is handled.
  2514.  
  2515.   PerlSetVar StateDB SDBM_File
  2516.  
  2517. =item StateCache
  2518.  
  2519. Deprecated as of 2.23.  There is no equivalent config for
  2520. the functionality this represented from that version on.
  2521. The 2.23 release represented a significant rewrite
  2522. of the state management, moving to MLDBM::Sync for its
  2523. subsystem.
  2524.  
  2525. =item StateSerializer
  2526.  
  2527. default Data::Dumper, you may set this to Storable for 
  2528. faster serialization and storage of data into state objects.
  2529. This is particularly useful when storing large objects in
  2530. $Session and $Application, as the Storable.pm module has a faster
  2531. implementation of freezing and thawing data from and to
  2532. perl structures.  Note that if you are storing this much
  2533. data in your state databases, you may want to use 
  2534. DB_File since it does not have the default 1024 byte limit 
  2535. that SDBM_File has on key/value lengths.
  2536.  
  2537. This configuration setting may be changed in production
  2538. as the state database's serializer type is stored
  2539. in the internal state manager which will always use 
  2540. Data::Dumper & SDBM_File to store data.
  2541.  
  2542.   PerlSetVar StateSerializer Data::Dumper
  2543.  
  2544. =head2 Sessions
  2545.  
  2546. =item CookiePath
  2547.  
  2548. URL root that client responds to by sending the session cookie.
  2549. If your asp application falls under the server url "/asp", 
  2550. then you would set this variable to /asp.  This then allows
  2551. you to run different applications on the same server, with
  2552. different user sessions for each application.
  2553.  
  2554.   PerlSetVar CookiePath /   
  2555.  
  2556. =item CookieDomain
  2557.  
  2558. Default 0, this NON-PORTABLE configuration will allow sessions to span
  2559. multiple web sites that match the same domain root.  This is useful if
  2560. your web sites are hosted on the same machine and can share the same
  2561. StateDir configuration, and you want to shared the $Session data 
  2562. across web sites.  Whatever this is set to, that will add a 
  2563.  
  2564.   ; domain=$CookieDomain
  2565.  
  2566. part to the Set-Cookie: header set for the session-id cookie.
  2567.  
  2568.   PerlSetVar CookieDomain .your.global.domain
  2569.  
  2570. =item SessionTimeout
  2571.  
  2572. Default 20 minutes, when a user's session has been inactive for this
  2573. period of time, the Session_OnEnd event is run, if defined, for 
  2574. that session, and the contents of that session are destroyed.
  2575.  
  2576.   PerlSetVar SessionTimeout 20 
  2577.  
  2578. =item SecureSession
  2579.  
  2580. default 0.  Sets the secure tag for the session cookie, so that the cookie
  2581. will only be transmitted by the browser under https transmissions.
  2582.  
  2583.   PerlSetVar SecureSession 1
  2584.  
  2585. =item ParanoidSession
  2586.  
  2587. default 0.  When true, stores the user-agent header of the browser 
  2588. that creates the session and validates this against the session cookie presented.
  2589. If this check fails, the session is killed, with the rationale that 
  2590. there is a hacking attempt underway.
  2591.  
  2592. This config option was implemented to be a smooth upgrade, as
  2593. you can turn it off and on, without disrupting current sessions.  
  2594. Sessions must be created with this turned on for the security to take effect.
  2595.  
  2596. This config option is to help prevent a brute force cookie search from 
  2597. being successful. The number of possible cookies is huge, 2^128, thus making such
  2598. a hacking attempt VERY unlikely.  However, on the off chance that such
  2599. an attack is successful, the hacker must also present identical
  2600. browser headers to authenticate the session, or the session will be
  2601. destroyed.  Thus the User-Agent acts as a backup to the real session id.
  2602. The IP address of the browser cannot be used, since because of proxies,
  2603. IP addresses may change between requests during a session.
  2604.  
  2605. There are a few browsers that will not present a User-Agent header.
  2606. These browsers are considered to be browsers of type "Unknown", and 
  2607. this method works the same way for them.
  2608.  
  2609. Most people agree that this level of security is unnecessary, thus
  2610. it is titled paranoid :)
  2611.  
  2612.   PerlSetVar ParanoidSession 0
  2613.  
  2614. =item SessionSerialize
  2615.  
  2616. default 0, if true, locks $Session for duration of script, which
  2617. serializes requests to the $Session object.  Only one script at
  2618. a time may run, per user $Session, with sessions allowed.
  2619.  
  2620. Serialized requests to the session object is the Microsoft ASP way, 
  2621. but is dangerous in a production environment, where there is risk
  2622. of long-running or run-away processes.  If these things happen,
  2623. a session may be locked for an indefinite period of time.  A user
  2624. STOP button should safely quit the session however.
  2625.  
  2626.   PerlSetVar SessionSerialize 0
  2627.  
  2628. =item SessionCount
  2629.  
  2630. default 0, if true enables the $Application->SessionCount API
  2631. which returns how many sessions are currently active in 
  2632. the application.  This config was created 
  2633. because there is a performance hit associated with this
  2634. count tracking, so it is disabled by default.
  2635.  
  2636.   PerlSetVar SessionCount 1
  2637.  
  2638. =head2 Cookieless Sessions
  2639.  
  2640. =item SessionQueryParse
  2641.  
  2642. default 0, if true, will automatically parse the $Session
  2643. session id into the query string of each local URL found in the 
  2644. $Response buffer.  For this setting to work therefore, 
  2645. buffering must be enabled.  This parsing will only occur
  2646. when a session cookie has not been sent by a browser, so the 
  2647. first script of a session enabled site, and scripts viewed by 
  2648. web browsers that have cookies disabled will trigger this behavior.
  2649.  
  2650. Although this runtime parsing method is computationally 
  2651. expensive, this cost should be amortized across most users
  2652. that will not need this URL parsing.  This is a lazy programmer's
  2653. dream.  For something more efficient, look at the SessionQuery
  2654. setting.  For more information about this solution, please 
  2655. read the SESSIONS section.
  2656.  
  2657.   PerlSetVar SessionQueryParse 0
  2658.  
  2659. =item SessionQueryParseMatch
  2660.  
  2661. default 0, set to a regexp pattern that matches all URLs that you 
  2662. want to have SessionQueryParse parse in session ids.  By default
  2663. SessionQueryParse only modifies local URLs, but if you name
  2664. your URLs of your site with absolute URLs like http://localhost
  2665. then you will need to use this setting.  So to match 
  2666. http://localhost URLs, you might set this pattern to 
  2667. ^http://localhost.  Note that by setting this config,
  2668. you are also setting SessionQueryParse.
  2669.  
  2670.   PerlSetVar SessionQueryParseMatch ^https?://localhost
  2671.  
  2672. =item SessionQuery
  2673.  
  2674. default 0, if set, the session id will be initialized from
  2675. the $Request->QueryString if not first found as a cookie.
  2676. You can use this setting coupled with the 
  2677.  
  2678.   $Server->URL($url, \%params) 
  2679.  
  2680. API extension to generate local URLs with session ids in their
  2681. query strings, for efficient cookieless session support.
  2682. Note that if a browser has cookies disabled, every URL
  2683. to any page that needs access to $Session will need to
  2684. be created by this method, unless you are using SessionQueryParse
  2685. which will do this for you automatically.
  2686.  
  2687.   PerlSetVar SessionQuery 0
  2688.  
  2689. =item SessionQueryMatch
  2690.  
  2691. default 0, set to a regexp pattern that will match
  2692. URLs for $Server->URL() to add a session id to.  SessionQuery
  2693. normally allows $Server->URL() to add session ids just to 
  2694. local URLs, so if you use absolute URL references like 
  2695. http://localhost/ for your web site, then just like 
  2696. with SessionQueryParseMatch, you might set this pattern
  2697. to ^http://localhost
  2698.  
  2699. If this is set, then you don't need to set SessionQuery,
  2700. as it will be set automatically.
  2701.  
  2702.   PerlSetVar SessionQueryMatch ^http://localhost
  2703.  
  2704. =item SessionQueryForce
  2705.  
  2706. default 0, set to 1 if you want to disallow the use of cookies
  2707. for session id passing, and only allow session ids to be passed
  2708. on the query string via SessionQuery and SessionQueryParse settings.
  2709.  
  2710.   PerlSetVar SessionQueryForce 1
  2711.  
  2712. =head2 Developer Environment
  2713.  
  2714. =item UseStrict
  2715.  
  2716. default 0, if set to 1, will compile all scripts, global.asa
  2717. and includes with "use strict;" inserted at the head of 
  2718. the file, saving you from the painful process of strictifying
  2719. code that was not strict to begin with.
  2720.  
  2721. Because of how essential "use strict" programming is in
  2722. a mod_perl environment, this default might be set to 1 
  2723. one day, but this will be up for discussion before that
  2724. decision is made.
  2725.  
  2726. Note too that errors triggered by "use strict" are
  2727. now captured as part of the normal Apache::ASP error 
  2728. handling when this configuration is set, otherwise
  2729. "use strict" errors will not be handled properly, so
  2730. using UseStrict is better than your own "use strict"
  2731. statements.
  2732.  
  2733. PerlSetVar UseStrict 1
  2734.  
  2735. =item Debug
  2736.  
  2737. 1 for server log debugging, 2 for extra client html output,
  2738. 3 for microtimes logged. Use 1 for production debugging, 
  2739. use 2 or 3 for development.  Turn off if you are not 
  2740. debugging.  These settings activate $Response->Debug().
  2741.  
  2742.   PerlSetVar Debug 2    
  2743.  
  2744. If Debug 3 is set and Time::HiRes is installed, microtimes
  2745. will show up in the log, and also calculate the time
  2746. between one $Response->Debug() and another, so good for a
  2747. quick benchmark when you glance at the logs.
  2748.  
  2749.   PerlSetVar Debug 3
  2750.  
  2751. If you would like to enable system level debugging, set
  2752. Debug to a negative value.  So for system level debugging,
  2753. but no output to browser:
  2754.  
  2755.   PerlSetVar Debug -1
  2756.  
  2757. =item DebugBufferLength
  2758.  
  2759. Default 100, set this to the number of bytes of the 
  2760. buffered output's tail you want to see when an error occurs
  2761. and Debug 2 or MailErrorsTo is set, and when 
  2762. BufferingOn is enabled.  
  2763.  
  2764. With buffering the script output will not naturally show 
  2765. up when the script errors, as it has been buffered by the 
  2766. $Response object.  It helps to see where in the script
  2767. output an error halted the script, so the last bytes of 
  2768. the buffered output are included with the rest of 
  2769. the debugging information.  
  2770.  
  2771. For a demo of this functionality, try the 
  2772. ./site/eg/syntax_error.htm script, and turn buffering on.
  2773.  
  2774. =item PodComments
  2775.  
  2776. default 1.  With pod comments turned on, perl pod style comments
  2777. and documentation are parsed out of scripts at compile time.
  2778. This make for great documentation and a nice debugging tool,
  2779. and it lets you comment out perl code and html in blocks.  
  2780. Specifically text like this:
  2781.  
  2782.  =pod
  2783.  text or perl code here
  2784.  =cut 
  2785.  
  2786. will get ripped out of the script before compiling.  The =pod and =cut 
  2787. perl directives must be at the beginning of the line, and must
  2788. be followed by the end of the line.
  2789.  
  2790.   PerlSetVar PodComments 1
  2791.  
  2792. =item CollectionItem
  2793.  
  2794. Enables PerlScript syntax like:
  2795.  
  2796.   $Request->Form('var')->Item;
  2797.   $Request->Form('var')->Item(1);
  2798.   $Request->Form('var')->Count;
  2799.  
  2800. Old PerlScript syntax, enabled with
  2801.  
  2802.   use Win32::OLE qw(in valof with OVERLOAD);
  2803.  
  2804. is like native syntax
  2805.  
  2806.   $Request->Form('var');
  2807.  
  2808. Only in Apache::ASP, can the above be written as:
  2809.  
  2810.   $Request->{Form}{var};
  2811.  
  2812. which you would do if you _really_ needed the speed.
  2813.  
  2814. =head2 XML / XSLT
  2815.  
  2816. =item XMLSubsMatch
  2817.  
  2818. default not defined, set to some regexp pattern
  2819. that will match all XML and HTML tags that you want
  2820. to have perl subroutines handle.  The is Apache::ASP's
  2821. custom tag technology, and can be used to create
  2822. powerful extensions to your XML and HTML rendering.
  2823.  
  2824. Please see XML/XSLT section for instructions on its use.
  2825.  
  2826.   PerlSetVar XMLSubsMatch my:[\w\-]+
  2827.  
  2828. =item XMLSubsStrict
  2829.  
  2830. default 0, when set XMLSubs will only take arguments
  2831. that are properly formed XML tag arguments like:
  2832.  
  2833.  <my:sub arg1="value" arg2="value" />
  2834.  
  2835. By default, XMLSubs accept arbitrary perl code as
  2836. argument values:
  2837.  
  2838.  <my:sub arg1=1+1 arg2=&perl_sub()/>
  2839.  
  2840. which is not always wanted or expected.  Set
  2841. XMLSubsStrict to 1 if this is the case.
  2842.  
  2843.   PerlSetVar XMLSubsStrict 1
  2844.  
  2845. =item XMLSubsPerlArgs
  2846.  
  2847. default 1, when set attribute values will be interpreted
  2848. as raw perl code so that these all would execute as one
  2849. would expect:
  2850.  
  2851.  <my:xmlsubs arg='1' arg2="2" arg3=$value arg4="1 $value" />
  2852.  
  2853. With the 2.45 release, 0 may be set for this configuration
  2854. or a more ASP style variable interpolation:
  2855.  
  2856.  <my:xmlsubs arg='1' arg2="2" args3="<%= $value %>" arg4="1 <%= $value %>" />
  2857.  
  2858. This configuration is being introduced experimentally in version 2.45,
  2859. as it will become the eventual default in the 3.0 release.
  2860.  
  2861.   PerlSetVar XMLSubsPerlArgs Off
  2862.  
  2863. =item XSLT
  2864.  
  2865. default not defined, if set to a file, ASP scripts will
  2866. be regarded as XML output and transformed with the given
  2867. XSL file with XML::XSLT.  This XSL file will also be
  2868. executed as an ASP script first, and its output will be
  2869. the XSL data used for the transformation.  This XSL file
  2870. will be executed as a dynamic include, so may be located
  2871. in the current directory, Global, or IncludesDir.
  2872.  
  2873. Please see the XML/XSLT section for an explanation of its
  2874. use.
  2875.  
  2876.   PerlSetVar XSLT template.xsl
  2877.  
  2878. =item XSLTMatch
  2879.  
  2880. default .*, if XSLT is set by default all ASP scripts 
  2881. will be XSL transformed by the specified XSL template.
  2882. This regexp setting will tell XSLT which file names to 
  2883. match with doing XSL transformations, so that regular
  2884. HTML ASP scripts and XML ASP scripts can be configured
  2885. with the same configuration block.  Please see
  2886. ./site/eg/.htaccess for an example of its use.
  2887.  
  2888.   PerlSetVar XSLTMatch \.xml$
  2889.  
  2890. =item XSLTParser
  2891.  
  2892. default XML::XSLT, determines which perl module to use for 
  2893. XSLT parsing.  This is a new config as of 2.11.
  2894. Also supported is XML::Sablotron which does not
  2895. handle XSLT with the exact same output, but is about
  2896. 10 times faster than XML::XSLT.  XML::LibXSLT may
  2897. also be used as of version 2.29, and seems to be
  2898. about twice again as fast as XML::Sablotron,
  2899. and a very complete XSLT implementation.
  2900.  
  2901.   PerlSetVar XSLTParser XML::XSLT
  2902.   PerlSetVar XSLTParser XML::Sablotron
  2903.   PerlSetVar XSLTParser XML::LibXSLT
  2904.  
  2905. =item XSLTCache
  2906.  
  2907. Activate XSLT file based caching through CacheDB, CacheDir,
  2908. and CacheSize settings.  This gives cached XSLT performance
  2909. near AxKit and greater than Cocoon.  XSLT caches transformations
  2910. keyed uniquely by XML & XSLT inputs.
  2911.  
  2912.   PerlSetVar XSLTCache 1
  2913.  
  2914. =item XSLTCacheSize
  2915.  
  2916. as of version 2.11, this config is no longer supported.
  2917.  
  2918. =head2 Caching
  2919.  
  2920. The output caching layer is a file dbm based output cache that runs
  2921. on top of the MLDBM::Sync so inherits its performance characteristics.  
  2922. With CacheDB set to MLDBM::Sync::SDBM_File, the cache layer is 
  2923. very fast at caching entries up to 20K in size, but for greater 
  2924. cached items, you should set CacheDB to another dbm like DB_File 
  2925. or GDBM_File.
  2926.  
  2927. In order for the cache layer
  2928. to function properly, whether for $Response->Include() output
  2929. caching, see OBJECTS, or XSLT caching, see XML/XSLT, then
  2930. Apache::ASP must be loaded in the parent httpd like so:
  2931.  
  2932.   # httpd.conf
  2933.   PerlModule Apache::ASP
  2934.     -- or --
  2935.   <Perl>
  2936.     use Apache::ASP;
  2937.   </Perl>
  2938.  
  2939. The cache layer automatically expires entries upon
  2940. server restart, but for this to work, a $ServerID
  2941. must be computed when the Apache::ASP module gets
  2942. loaded to store in each cached item.  Without the 
  2943. above done, each child httpd process will get its
  2944. own $ServerID, so caching will not work at all.
  2945.  
  2946. This said, output caching will not work in raw CGI mode,
  2947. just running under mod_perl.
  2948.  
  2949. =item CacheDB
  2950.  
  2951. Like StateDB, sets dbm format for caching.  Since SDBM_File
  2952. only support key/values pairs of around 1K max in length,
  2953. the default for this is MLDBM::Sync::SDBM_File, which is very
  2954. fast for < 20K output sizes.  For caching larger data than 20K,
  2955. DB_File or GDBM_File are probably better to use.
  2956.  
  2957.   PerlSetVar CacheDB MLDBM::Sync::SDBM_File
  2958.  
  2959. =begin html
  2960.  
  2961. Here are some benchmarks about the CacheDB when used 
  2962. with caching output from $Response->Include(\%cache)
  2963. running on a Linux 2.2.14 dual PIII-450. 
  2964. The variables are output size being cached & the CacheDB used,
  2965. the default being MLDBM::Sync::SDBM_File. 
  2966.  
  2967. <table class="noescape" border="0">
  2968. <tr><th>CacheDB</th><th>Output Cached</th><th>Operation</th><th>Ops/sec</th></tr>
  2969. <tr><td>MLDBM::Sync::SDBM_File</td>    <td>3200 bytes</td>    <td>read</td>    <td>177</td></tr>
  2970. <tr><td>DB_File</td>            <td>3200 bytes</td>    <td>read</td>    <td>59</td></tr>
  2971. <tr><td>MLDBM::Sync::SDBM_File</td>    <td>32000 bytes</td>    <td>read</td>    <td>42</td></tr>
  2972. <tr><td>DB_File</td>            <td>32000 bytes</td>    <td>read</td>    <td>53</td></tr>
  2973. <tr><td>MLDBM::Sync::SDBM_File</td>    <td>3200 bytes</td>    <td>write</td>    <td>42</td></tr>
  2974. <tr><td>DB_File</td>            <td>3200 bytes</td>    <td>write</td>    <td>39</td></tr>
  2975. </table>
  2976.  
  2977. =end html
  2978.  
  2979. For your own benchmarks to test the relative speeds of the
  2980. various DBMs under MLDBM::Sync, which is used by CacheDB,
  2981. you may run the ./bench/bench_sync.pl script from the 
  2982. MLDBM::Sync distribution on your system.
  2983.  
  2984. =item CacheDir
  2985.  
  2986. By default, the cache directory is at StateDir/cache,
  2987. but CacheDir can be used to set the StateDir value for 
  2988. caching purposes.  One may want the CacheDir separate
  2989. from StateDir for example StateDir might be a centrally
  2990. network mounted file system, while CacheDir might be
  2991. a local file cache.
  2992.  
  2993.   PerlSetVar CacheDir /tmp/asp_demo
  2994.  
  2995. On a system like Solaris where there is a RAM disk 
  2996. mounted on the system like /tmp, I could put the CacheDir
  2997. there.  On a system like Linux where files are cached
  2998. pretty well by default, this is less important.
  2999.  
  3000. =item CacheSize
  3001.  
  3002. By default, this is 10M of data per cache.  When any cache, 
  3003. like the XSLTCache, reaches this limit, the cache will be purged 
  3004. by deleting the cached dbm files entirely.  This is better for 
  3005. long term running of dbms than deleting individual records, 
  3006. because dbm formats will often degrade in performance with 
  3007. lots of insert & deletes.
  3008.  
  3009. Units of M, K, and B are supported for megabytes, kilobytes, and bytes,
  3010. with the default unit being B, so the following configs all mean the
  3011. same thing;
  3012.  
  3013.   PerlSetVar CacheSize 10M
  3014.   PerlSetVar CacheSize 10240K
  3015.   PerlSetVar CacheSize 10485760B
  3016.   PerlSetVar CacheSize 10485760
  3017.  
  3018. There are 2 caches currently, the XSLTCache, and the
  3019. Response cache, the latter which is currently invoked
  3020. for caching output from includes with special syntax.
  3021. See $Response->Include() for more info on the Response cache.
  3022.  
  3023. =head2 Miscellaneous
  3024.  
  3025. =item AuthServerVariables
  3026.  
  3027. default 0. If you are using basic auth and would like 
  3028. $Request->ServerVariables set like AUTH_TYPE, AUTH_USER, 
  3029. AUTH_NAME, REMOTE_USER, & AUTH_PASSWD, then set this and
  3030. Apache::ASP will initialize these values from Apache->*auth* 
  3031. commands.  Use of these environment variables keeps applications
  3032. cross platform compatible as other servers set these too
  3033. when performing basic 401 auth.
  3034.  
  3035.   PerlSetVar AuthServerVariables 0
  3036.  
  3037. =item BufferingOn
  3038.  
  3039. default 1, if true, buffers output through the response object.
  3040. $Response object will only send results to client browser if
  3041. a $Response->Flush() is called, or if the asp script ends.  Lots of 
  3042. output will need to be flushed incrementally.
  3043.  
  3044. If false, 0, the output is immediately written to the client,
  3045. CGI style.  There will be a performance hit server side if output
  3046. is flushed automatically to the client, but is probably small.
  3047.  
  3048. I would leave this on, since error handling is poor, if your asp 
  3049. script errors after sending only some of the output.
  3050.  
  3051.   PerlSetVar BufferingOn 1
  3052.  
  3053. =item InodeNames
  3054.  
  3055. Default 0. Set to 1 to uses a stat() call on scripts and includes to
  3056. derive subroutine namespace based on device and inode numbers. In case of 
  3057. multiple symbolic links pointing to the same script this will result 
  3058. in the script being compiled only once. Use only on unix flavours
  3059. which support the stat() call that know about device and inode 
  3060. numbers.
  3061.  
  3062.   PerlSetVar InodeNames 1
  3063.  
  3064. =item RequestParams
  3065.  
  3066. Default 0, if set creates $Request->Params object with combined 
  3067. contents of $Request->QueryString and $Request->Form.  This
  3068. is for developer convenience simlar to CGI.pm's param() method.
  3069.  
  3070.   PerlSetVar RequestParams 1
  3071.  
  3072. =item RequestBinaryRead
  3073.  
  3074. Default On, if set to Off will not read POST data into $Request->Form().
  3075.  
  3076. One potential reason for configuring this to Off might be to initialize the Apache::ASP
  3077. object in an Apache handler phase earlier than the normal PerlRequestHandler
  3078. phase, so that it does not interfere with normal reading of POST data later
  3079. in the request.
  3080.  
  3081.   PerlSetVar RequestBinaryRead On
  3082.  
  3083. =item StatINC
  3084.  
  3085. default 0, if true, reloads perl libraries that have changed
  3086. on disk automatically for ASP scripts.  If false, the www server
  3087. must be restarted for library changes to take effect.
  3088.  
  3089. A known bug is that any functions that are exported, e.g. confess 
  3090. Carp qw(confess), will not be refreshed by StatINC.  To refresh
  3091. these, you must restart the www server.  
  3092.  
  3093. This setting should be used in development only because it is so slow.
  3094. For a production version of StatINC, see StatINCMatch.
  3095.  
  3096.   PerlSetVar StatINC 1
  3097.  
  3098. =item StatINCMatch
  3099.  
  3100. default undef, if defined, it will be used as a regular expression
  3101. to reload modules that match as in StatINC.  This is useful because
  3102. StatINC has a very high performance penalty in production, so if
  3103. you can narrow the modules that are checked for reloading each
  3104. script execution to a handful, you will only suffer a mild performance 
  3105. penalty.
  3106.  
  3107. The StatINCMatch setting should be a regular expression like: Struct|LWP
  3108. which would match on reloading Class/Struct.pm, and all the LWP/.*
  3109. libraries.
  3110.  
  3111. If you define StatINCMatch, you do not need to define StatINC.
  3112.  
  3113.   PerlSetVar StatINCMatch .*
  3114.  
  3115. =item StatScripts
  3116.  
  3117. default 1, if set to 0, changed scripts, global.asa, and includes
  3118. will not be reloaded.  Coupled with Apache mod_perl startup and restart
  3119. handlers executing Apache::ASP->Loader() for your application
  3120. this allows your application to be frozen, and only reloaded on the 
  3121. next server restart or stop/start.
  3122.  
  3123. There are a few advantages for not reloading scripts and modules
  3124. in production.  First there is a slight performance improvement
  3125. by not having to stat() the script, its includes and the global.asa
  3126. every request.  
  3127.  
  3128. From an application deployment standpoint, you
  3129. also gain the ability to deploy your application as a 
  3130. snapshot taken when the server starts and restarts.
  3131. This provides you with the reassurance that during a
  3132. production server update from development sources, you 
  3133. do not have to worry with sources being used for the 
  3134. wrong libraries and such, while they are all being 
  3135. copied over.
  3136.  
  3137. Finally, though you really should not do this, you can
  3138. work on a live production application, with a test server
  3139. reloading changes, but your production server does see
  3140. the changes until you restart or stop/start it.  This 
  3141. saves your public from syntax errors while you are just
  3142. doing a quick bug fix.
  3143.  
  3144.   PerlSetVar StatScripts 1
  3145.  
  3146. =item SoftRedirect
  3147.  
  3148. default 0, if true, a $Response->Redirect() does not end the 
  3149. script.  Normally, when a Redirect() is called, the script
  3150. is ended automatically.  SoftRedirect 1, is a standard
  3151. way of doing redirects, allowing for html output after the 
  3152. redirect is specified.
  3153.  
  3154.   PerlSetVar SoftRedirect 0
  3155.  
  3156. =item Filter
  3157.  
  3158. On/Off, default Off.  With filtering enabled, you can take advantage of 
  3159. full server side includes (SSI), implemented through Apache::SSI.  
  3160. SSI is implemented through this mechanism by using Apache::Filter.  
  3161. A sample configuration for full SSI with filtering is in the 
  3162. ./site/eg/.htaccess file, with a relevant example script ./site/eg/ssi_filter.ssi.
  3163.  
  3164. You may only use this option with modperl v1.16 or greater installed
  3165. and PERL_STACKED_HANDLERS enabled.  Filtering may be used in 
  3166. conjunction with other handlers that are also "filter aware".
  3167. If in doubt, try building your mod_perl with 
  3168.  
  3169.   perl Makefile.PL EVERYTHING=1
  3170.  
  3171. With filtering through Apache::SSI, you should expect near a
  3172. a 20% performance decrease.
  3173.  
  3174.   PerlSetVar Filter Off
  3175.  
  3176. =item CgiHeaders
  3177.  
  3178. default 0.  When true, script output that looks like HTTP / CGI
  3179. headers, will be added to the HTTP headers of the request.
  3180. So you could add:
  3181.   Set-Cookie: test=message
  3182.  
  3183.   <html>...
  3184. to the top of your script, and all the headers preceding a newline
  3185. will be added as if with a call to $Response->AddHeader().  This
  3186. functionality is here for compatibility with raw cgi scripts,
  3187. and those used to this kind of coding.
  3188.  
  3189. When set to 0, CgiHeaders style headers will not be parsed from the 
  3190. script response.
  3191.  
  3192.   PerlSetVar CgiHeaders 0
  3193.  
  3194. =item Clean
  3195.  
  3196. default 0, may be set between 1 and 9.  This setting determine how much
  3197. text/html output should be compressed.  A setting of 1 strips mostly
  3198. white space saving usually 10% in output size, at a performance cost
  3199. of less than 5%.  A setting of 9 goes much further saving anywhere
  3200. 25% to 50% typically, but with a performance hit of 50%.
  3201.  
  3202. This config option is implemented via HTML::Clean.  Per script
  3203. configuration of this setting is available via the $Response->{Clean}
  3204. property, which may also be set between 0 and 9.
  3205.  
  3206.   PerlSetVar Clean 0
  3207.  
  3208. =item CompressGzip
  3209.  
  3210. default 0, if true will gzip compress HTML output on the
  3211. fly if Compress::Zlib is installed, and the client browser
  3212. supports it.  Depending on the HTML being compressed, 
  3213. the client may see a 50% to 90% reduction in HTML output.
  3214. I have seen 40K of HTML squeezed down to just under 6K.
  3215. This will come at a 5%-20% hit to CPU usage per request
  3216. compressed.
  3217.  
  3218. Note there are some cases when a browser says it will accept
  3219. gzip encoding, but then not render it correctly.  This
  3220. behavior has been seen with IE5 when set to use a proxy but 
  3221. not using a proxy, and the URL does not end with a .html or .htm.
  3222. No work around has yet been found for this case so use at your 
  3223. own risk.
  3224.  
  3225.   PerlSetVar CompressGzip 1
  3226.  
  3227. =item FormFill
  3228.  
  3229. default 0, if true will auto fill HTML forms with values
  3230. from $Request->Form().  This functionality is provided
  3231. by use of HTML::FillInForm.  For more information please
  3232. see "perldoc HTML::FillInForm", and the 
  3233. example ./site/eg/formfill.asp.  
  3234.  
  3235. This feature can be enabled on a per form basis at runtime
  3236. with $Response->{FormFill} = 1
  3237.  
  3238.   PerlSetVar FormFill 1
  3239.  
  3240. =item TimeHiRes
  3241.  
  3242. default 0, if set and Time::HiRes is installed, will do 
  3243. sub second timing of the time it takes Apache::ASP to process
  3244. a request.  This will not include the time spent in the 
  3245. session manager, nor modperl or Apache, and is only a 
  3246. rough approximation at best.
  3247.  
  3248. If Debug is set also, you will get a comment in your
  3249. HTML output that indicates the time it took to process
  3250. that script.
  3251.  
  3252. If system debugging is set with Debug -1 or -2, you will
  3253. also get this time in the Apache error log with the 
  3254. other system messages.
  3255.  
  3256. =head2 Mail Administration
  3257.  
  3258. Apache::ASP has some powerful administrative email
  3259. extensions that let you sleep at night, knowing full well
  3260. that if an error occurs at the web site, you will know
  3261. about it immediately.  With these features already enabled,
  3262. it was also easy to provide the $Server->Mail(\%mail) API 
  3263. extension which you can read up about in the OBJECTS section.
  3264.  
  3265. =item MailHost
  3266.  
  3267. The mail host is the smtp server that the below Mail* config directives
  3268. will use when sending their emails.  By default Net::SMTP uses
  3269. smtp mail hosts configured in Net::Config, which is set up at
  3270. install time, but this setting can be used to override this config.
  3271.  
  3272. The mail hosts specified in the Net::Config file will be used as
  3273. backup smtp servers to the MailHost specified here, should this
  3274. primary server not be working.
  3275.  
  3276.   PerlSetVar MailHost smtp.yourdomain.com.foobar
  3277.  
  3278. =item MailFrom
  3279.  
  3280. Default NONE, set this to specify the default mail address placed 
  3281. in the From: mail header for the $Server->Mail() API extension, 
  3282. as well as MailErrorsTo and MailAlertTo.
  3283.  
  3284.   PerlSetVar MailFrom youremail@yourdomain.com.foobar
  3285.  
  3286. =item MailErrorsTo
  3287.  
  3288. No default, if set, ASP server errors, error code 500, that result
  3289. while compiling or running scripts under Apache::ASP will automatically
  3290. be emailed to the email address set for this config.  This allows
  3291. an administrator to have a rapid response to user generated server
  3292. errors resulting from bugs in production ASP scripts.  Other errors, such 
  3293. as 404 not found will be handled by Apache directly.
  3294.  
  3295. An easy way to see this config in action is to have an ASP script which calls
  3296. a die(), which generates an internal ASP 500 server error.
  3297.  
  3298. The Debug config of value 2 and this setting are mutually exclusive,
  3299. as Debug 2 is a development setting where errors are displayed in the browser,
  3300. and MailErrorsTo is a production setting so that errors are silently logged
  3301. and sent via email to the web admin.
  3302.  
  3303.   PerlSetVar MailErrorsTo youremail@yourdomain.com
  3304.  
  3305. =item MailAlertTo
  3306.  
  3307. The address configured will have an email sent on any ASP server error 500,
  3308. and the message will be short enough to fit on a text based pager.  This
  3309. config setting would be used to give an administrator a heads up that a www
  3310. server error occurred, as opposed to MailErrorsTo would be used for debugging
  3311. that server error.
  3312.  
  3313. This config does not work when Debug 2 is set, as it is a setting for
  3314. use in production only, where Debug 2 is for development use.
  3315.  
  3316.   PerlSetVar MailAlertTo youremail@yourdomain.com
  3317.  
  3318. =item MailAlertPeriod
  3319.  
  3320. Default 20 minutes, this config specifies the time in minutes over 
  3321. which there may be only one alert email generated by MailAlertTo.
  3322. The purpose of MailAlertTo is to give the admin a heads up that there
  3323. is an error at the www server.  MailErrorsTo is for to aid in speedy 
  3324. debugging of the incident.
  3325.  
  3326.   PerlSetVar MailAlertPeriod 20
  3327.  
  3328. =head2 File Uploads
  3329.  
  3330. =item FileUploadMax
  3331.  
  3332. default 0, if set will limit file uploads to this
  3333. size in bytes.  This is currently implemented by 
  3334. setting $CGI::POST_MAX before handling the file
  3335. upload.  Prior to this, a developer would have to
  3336. hardcode a value for $CGI::POST_MAX to get this 
  3337. to work.
  3338.  
  3339.   PerlSetVar 100000
  3340.  
  3341. =item FileUploadTemp
  3342.  
  3343. default 0, if set will leave a temp file on disk during the request, 
  3344. which may be helpful for processing by other programs, but is also
  3345. a security risk in that other users on the operating system could 
  3346. potentially read this file while the script is running. 
  3347.  
  3348. The path to the temp file will be available at
  3349. $Request->{FileUpload}{$form_field}{TempFile}.
  3350. The regular use of file uploads remains the same
  3351. with the <$filehandle> to the upload at 
  3352. $Request->{Form}{$form_field}.  Please see the CGI section
  3353. for more information on file uploads, and the $Request
  3354. section in OBJECTS.
  3355.  
  3356.   PerlSetVar FileUploadTemp 0
  3357.  
  3358. =head1 SYNTAX
  3359.  
  3360. =head2 General
  3361.  
  3362. ASP embedding syntax allows one to embed code in html in 2 simple ways.
  3363. The first is the <% xxx %> tag in which xxx is any valid perl code.
  3364. The second is <%= xxx %> where xxx is some scalar value that will
  3365. be inserted into the html directly.  An easy print.
  3366.  
  3367.   A simple asp page would look like:
  3368.   
  3369.   <!-- sample here -->
  3370.   <html>
  3371.   <body>
  3372.   For loop incrementing font size: <p>
  3373.   <% for(1..5) { %>
  3374.     <!-- iterated html text -->
  3375.     <font size="<%=$_%>" > Size = <%=$_%> </font> <br>
  3376.   <% } %>
  3377.   </body>
  3378.   </html>
  3379.   <!-- end sample here -->
  3380.  
  3381. Notice that your perl code blocks can span any html.  The for loop
  3382. above iterates over the html without any special syntax.
  3383.  
  3384. =head2 XMLSubs
  3385.  
  3386. XMLSubs allows a developer to define custom handlers for
  3387. HTML & XML tags, which can extend the natural syntax
  3388. of the ASP environment.  Configured like:
  3389.  
  3390.   PerlSetVar XMLSubsMatch site:\w+
  3391.  
  3392. A simple tag like:
  3393.  
  3394.   <site:header title="Page Title" />
  3395.  
  3396. can be constructed that could translate into:
  3397.  
  3398.   sub site::header {
  3399.       my $args = shift;
  3400.       print "<html><head><title>$args->{title}</title></head>\n";
  3401.       print "<body bgcolor=white>\n";
  3402.   }
  3403.  
  3404. Better yet, one can use this functionality to trap
  3405. and post process embedded HTML & XML like:
  3406.  
  3407.   <site:page title="Page Title">
  3408.     ... some HTML here ...
  3409.   </site:page>
  3410.  
  3411. and then:
  3412.  
  3413.   sub site::page {
  3414.     my($args, $html) = @_;
  3415.     &site::header($args);
  3416.     $main::Response->Write($html);
  3417.     $main::Response->Write("</body></html>");
  3418.   }
  3419.  
  3420. Though this could be used to fully render XML 
  3421. documents, it was not built for this purpose, but
  3422. to add powerful tag extensions to HTML development
  3423. environments.  For full XML rendering, you ought
  3424. to try an XSLT approach, also supported by Apache::ASP.
  3425.  
  3426. =head2 Editors
  3427.  
  3428. As Apache::ASP supports a mixing of perl and HTML,
  3429. any editor which supports development of one or the 
  3430. other would work well.  The following editors are
  3431. known to work well for developing Apache::ASP web sites:
  3432.  
  3433.  * Emacs, in perl or HTML modes.  For a mmm-mode config
  3434.    that mixes HTML & perl modes in a single buffer, check 
  3435.    out the editors/mmm-asp-perl.el file in distribution.
  3436.  
  3437.  * Microsoft Frontpage
  3438.  
  3439.  * Vim, special syntax support with editors/aasp.vim file in distribution.
  3440.  
  3441.  * UltraEdit32 ( http://www.ultraedit.com/ ) has syntax highlighting, 
  3442.    good macros and a configurable wordlist (so one can have syntax 
  3443.    highlighting both for Perl and HTML).
  3444.  
  3445. Please feel free to suggest your favorite development
  3446. environment for this list.
  3447.  
  3448. =head1 EVENTS
  3449.  
  3450. =head2 Overview
  3451.  
  3452. The ASP platform allows developers to create Web Applications.
  3453. In fulfillment of real software requirements, ASP allows 
  3454. event-triggered actions to be taken, which are defined in
  3455. a global.asa file.  The global.asa file resides in the 
  3456. Global directory, defined as a config option, and may
  3457. define the following actions:
  3458.  
  3459.     Action            Event
  3460.     ------            ------
  3461.         Script_OnStart *    Beginning of Script execution
  3462.         Script_OnEnd *        End of Script execution
  3463.         Script_OnFlush *    Before $Response being flushed to client.
  3464.     Application_OnStart    Beginning of Application
  3465.     Application_OnEnd    End of Application
  3466.     Session_OnStart        Beginning of user Session.
  3467.     Session_OnEnd        End of user Session.
  3468.  
  3469.   * These are API extensions that are not portable, but were
  3470.     added because they are incredibly useful
  3471.  
  3472. These actions must be defined in the $Global/global.asa file
  3473. as subroutines, for example:
  3474.  
  3475.   sub Session_OnStart {
  3476.       $Application->{$Session->SessionID()} = started;
  3477.   }
  3478.  
  3479. Sessions are easy to understand.  When visiting a page in a
  3480. web application, each user has one unique $Session.  This 
  3481. session expires, after which the user will have a new
  3482. $Session upon revisiting.
  3483.  
  3484. A web application starts when the user visits a page in that
  3485. application, and has a new $Session created.  Right before
  3486. the first $Session is created, the $Application is created.
  3487. When the last user $Session expires, that $Application 
  3488. expires also.  For some web applications that are always busy,
  3489. the Application_OnEnd event may never occur.
  3490.  
  3491. =head2 Script_OnStart & Script_OnEnd
  3492.  
  3493. The script events are used to run any code for all scripts
  3494. in an application defined by a global.asa.  Often, you would
  3495. like to run the same code for every script, which you would
  3496. otherwise have to add by hand, or add with a file include,
  3497. but with these events, just add your code to the global.asa,
  3498. and it will be run.  
  3499.  
  3500. There is one caveat.  Code in Script_OnEnd is not guaranteed 
  3501. to be run when $Response->End() is called, since the program
  3502. execution ends immediately at this event.  To always run critical
  3503. code, use the API extension:
  3504.  
  3505.     $Server->RegisterCleanup()
  3506.  
  3507. =head2 Session_OnStart
  3508.  
  3509. Triggered by the beginning of a user's session, Session_OnStart
  3510. gets run before the user's executing script, and if the same
  3511. session recently timed out, after the session's triggered Session_OnEnd.
  3512.  
  3513. The Session_OnStart is particularly useful for caching database data,
  3514. and avoids having the caching handled by clumsy code inserted into
  3515. each script being executed.
  3516.  
  3517. =head2 Session_OnEnd
  3518.  
  3519. Triggered by a user session ending, Session_OnEnd can be useful
  3520. for cleaning up and analyzing user data accumulated during a session.
  3521.  
  3522. Sessions end when the session timeout expires, and the StateManager
  3523. performs session cleanup.  The timing of the Session_OnEnd does not
  3524. occur immediately after the session times out, but when the first 
  3525. script runs after the session expires, and the StateManager allows
  3526. for that session to be cleaned up.  
  3527.  
  3528. So on a busy site with default SessionTimeout (20 minutes) and 
  3529. StateManager (10 times) settings, the Session_OnEnd for a particular 
  3530. session should be run near 22 minutes past the last activity that Session saw.
  3531. A site infrequently visited will only have the Session_OnEnd run
  3532. when a subsequent visit occurs, and theoretically the last session
  3533. of an application ever run will never have its Session_OnEnd run.
  3534.  
  3535. Thus I would not put anything mission-critical in the Session_OnEnd,
  3536. just stuff that would be nice to run whenever it gets run.
  3537.  
  3538. =head2 Script_OnFlush
  3539.  
  3540. API extension. This event will be called prior to flushing
  3541. the $Response buffer to the web client.  At this time,
  3542. the $Response->{BinaryRef} buffer reference may be used to modify 
  3543. the buffered output at runtime to apply global changes to scripts 
  3544. output without having to modify all the scripts.
  3545.  
  3546.  sub Script_OnFlush {
  3547.    my $ref = $Response->{BinaryRef};
  3548.    $$ref =~ s/\s+/ /sg; # to strip extra white space
  3549.  }
  3550.  
  3551. Check out the ./site/eg/global.asa for an example of its use.
  3552.  
  3553. =head2 Application_OnStart
  3554.  
  3555. This event marks the beginning of an ASP application, and 
  3556. is run just before the Session_OnStart of the first Session
  3557. of an application.  This event is useful to load up
  3558. $Application with data that will be used in all user sessions.
  3559.  
  3560. =head2 Application_OnEnd
  3561.  
  3562. The end of the application is marked by this event, which
  3563. is run after the last user session has timed out for a 
  3564. given ASP application.  
  3565.  
  3566. =head2 Server_OnStart ( pseudo-event )
  3567.  
  3568. Some might want something like a Server_OnStart event, where
  3569. some code gets runs when the web server starts.  In mod_perl,
  3570. this is easy to achieve outside of the scope of an ASP
  3571. application, by putting some initialization code into
  3572. a <Perl> section in the httpd.conf file.  Initializations
  3573. that you would like to be shared with the child httpds are
  3574. particularly useful, one such being the Apache::ASP->Loader() 
  3575. routine which you can read more about in the TUNING section -
  3576. Precompile Scripts subsection. It is could be called like:
  3577.  
  3578.   # httpd.conf
  3579.   <Perl>
  3580.      Apache::ASP->Loader($path, $pattern, %config)
  3581.   </Perl>
  3582.  
  3583. So a <Perl> section is your Server_OnStart routine!
  3584.  
  3585. =head2 mod_perl handlers
  3586.  
  3587. If one wants to extend one's environment with mod_perl
  3588. handlers, Apache::ASP does not stop this.  Basic
  3589. use of Apache::ASP in fact only involves the content
  3590. handler phase of mod_perl's PerlHandler, like
  3591.  
  3592.   SetHandler perl-script
  3593.   PerlModule Apache::ASP
  3594.   PerlHandler Apache::ASP 
  3595.  
  3596. But mod_perl allows for direct access to many more
  3597. Apache event stages, for full list try "perldoc mod_perl"
  3598. or buy the mod_perl Eagle book.  Some commonly used ones are:
  3599.  
  3600.   PerlInitHandler
  3601.   PerlTransHandler
  3602.   PerlFixupHandler
  3603.   PerlHandler
  3604.   PerlLogHandler
  3605.   PerlCleanupHandler
  3606.  
  3607. For straight Apache::ASP programming, there are some 
  3608. equivalents, say Script_OnStart event instead of Init/Fixup
  3609. stages, or $Server->RegisterCleanup() for Log/Cleanup stages,
  3610. but you can do things in the mod_perl handlers that you 
  3611. cannot do in Apache::ASP, especially if you want to handle
  3612. all files globally, and not just ASP scripts.
  3613.  
  3614. For many Apache::* modules for use with mod_perl, of which
  3615. Apache::ASP is just one, check out
  3616. http://perl.apache.org/src/apache-modlist.html
  3617.  
  3618. To gain access to the ASP objects like $Session outside
  3619. in a non-PerlHandler mod_perl handler, you may use this API:
  3620.   
  3621.   my $ASP = Apache::ASP->new($r); # $r is Apache->request object
  3622.  
  3623. as in this possible Authen handler:
  3624.  
  3625.   <Perl>
  3626.     use Apache::ASP;
  3627.     sub My::Auth::handler {
  3628.       my $r = shift;
  3629.       my $ASP = Apache::ASP->new($r) 
  3630.       my $Session = $ASP->Session;
  3631.     }
  3632.   </Perl>
  3633.  
  3634. Here are some examples of do-it-yourself mod_perl
  3635. handler programming...
  3636.  
  3637.  === Forbid Bad HSlide User Agent ===
  3638.  
  3639.  # httpd.conf
  3640.  PerlAccessHandler My::Access
  3641.  <Perl>
  3642.    sub My::Access::handler {
  3643.      my $r = shift;
  3644.      if($r->headers_in->{'USER_AGENT'} =~ /HSlide/) {
  3645.      403;
  3646.      } else {
  3647.      200;
  3648.      }
  3649.    }
  3650.  </Perl>
  3651.  
  3652.  === Runtime Path Parsing ===
  3653.  
  3654. This example shows how one might take an arbitrary
  3655. URL path /$path/$file.asp, and turn that into a runtime 
  3656. config for your site, so your scripts get executed
  3657. always in your sites DocumentRoot.
  3658.  
  3659.  INPUT URL /SomeCategory/
  3660.  OUTPUT
  3661.   Script: index.asp
  3662.   $Server->Config('PATH') eq '/SomeCategory'
  3663.  
  3664.  INPUT URL /SomeCategory/index.asp
  3665.  OUTPUT
  3666.   Script: index.asp
  3667.   $Server->Config('PATH') eq '/SomeCategory'
  3668.  
  3669.  INPUT URI /index.asp
  3670.  OUTPUT
  3671.   Script: index.asp
  3672.   $Server->Config('PATH') eq ''
  3673.  
  3674.  # httpd.conf
  3675.  PerlTransHandler My::Init
  3676.  use lib qw( $custom_perllib );
  3677.  
  3678.  # $custom_perllib/My/Init.pm
  3679.  package My::Init;
  3680.  use strict;
  3681.  use Apache::Constants qw(:common);
  3682.  sub handler {
  3683.     my $r = shift;
  3684.  
  3685.     my $uri = $r->uri || '/';
  3686.     unless($uri =~ m|^(.*)(/([^/.]+\.[\w]+)?)$|i) {
  3687.     warn("can't parse uri $uri");
  3688.     return DECLINED;
  3689.     }
  3690.     $uri = $2;
  3691.     my $PATH = $1 || '';
  3692.     $r->dir_config('PATH', $PATH);
  3693.  
  3694.     if($uri eq '/') {
  3695.     $uri = '/index.asp';
  3696.     }
  3697.  
  3698.     $r->uri($uri);
  3699.     $r->filename($r->document_root.$uri);
  3700.  
  3701.     DECLINED;
  3702.  }
  3703.  
  3704.  1;
  3705.  
  3706. =head1 OBJECTS
  3707.  
  3708. The beauty of the ASP Object Model is that it takes the
  3709. burden of CGI and Session Management off the developer, 
  3710. and puts them in objects accessible from any
  3711. ASP script & include.  For the perl programmer, treat these objects
  3712. as globals accessible from anywhere in your ASP application.
  3713.  
  3714. The Apache::ASP object model supports the following:
  3715.  
  3716.   Object         Function
  3717.   ------         --------
  3718.   $Session      - user session state
  3719.   $Response     - output to browser
  3720.   $Request      - input from browser
  3721.   $Application  - application state
  3722.   $Server       - general methods
  3723.  
  3724. These objects, and their methods are further defined in the 
  3725. following sections.
  3726.  
  3727. If you would like to define your own global objects for use 
  3728. in your scripts and includes, you can initialize them in 
  3729. the global.asa Script_OnStart like:
  3730.  
  3731.  use vars qw( $Form $Site ); # declare globals
  3732.  sub Script_OnStart {
  3733.      $Site = My::Site->new;  # init $Site object
  3734.      $Form = $Request->Form; # alias form data
  3735.      $Server->RegisterCleanup(sub { # garbage collection
  3736.                   $Site->DESTROY; 
  3737.                   $Site = $Form = undef; 
  3738.                   });
  3739.  }
  3740.  
  3741. In this way you can create site wide application objects
  3742. and simple aliases for common functions.
  3743.  
  3744. =head2 $Session Object
  3745.  
  3746. The $Session object keeps track of user and web client state, in
  3747. a persistent manner, making it relatively easy to develop web 
  3748. applications.  The $Session state is stored across HTTP connections,
  3749. in database files in the Global or StateDir directories, and will 
  3750. persist across web server restarts. 
  3751.  
  3752. The user session is referenced by a 128 bit / 32 byte MD5 hex hashed cookie, 
  3753. and can be considered secure from session id guessing, or session hijacking.
  3754. When a hacker fails to guess a session, the system times out for a
  3755. second, and with 2**128 (3.4e38) keys to guess, a hacker will not be 
  3756. guessing an id any time soon.  
  3757.  
  3758. If an incoming cookie matches a timed out or non-existent session,
  3759. a new session is created with the incoming id.  If the id matches a
  3760. currently active session, the session is tied to it and returned.
  3761. This is also similar to the Microsoft ASP implementation.
  3762.  
  3763. The $Session reference is a hash ref, and can be used as such to 
  3764. store data as in: 
  3765.  
  3766.     $Session->{count}++;    # increment count by one
  3767.     %{$Session} = ();    # clear $Session data
  3768.  
  3769. The $Session object state is implemented through MLDBM,
  3770. and a user should be aware of the limitations of MLDBM.  
  3771. Basically, you can read complex structures, but not write 
  3772. them, directly:
  3773.  
  3774.   $data = $Session->{complex}{data};     # Read ok.
  3775.   $Session->{complex}{data} = $data;     # Write NOT ok.
  3776.   $Session->{complex} = {data => $data}; # Write ok, all at once.
  3777.  
  3778. Please see MLDBM for more information on this topic.
  3779. $Session can also be used for the following methods and properties:
  3780.  
  3781. =over
  3782.  
  3783. =item $Session->{CodePage}
  3784.  
  3785. Not implemented.  May never be until someone needs it.
  3786.  
  3787. =item $Session->{LCID}
  3788.  
  3789. Not implemented.  May never be until someone needs it.
  3790.  
  3791. =item $Session->{SessionID}
  3792.  
  3793. SessionID property, returns the id for the current session,
  3794. which is exchanged between the client and the server as a cookie.
  3795.  
  3796. =item $Session->{Timeout} [= $minutes]
  3797.  
  3798. Timeout property, if minutes is being assigned, sets this 
  3799. default timeout for the user session, else returns 
  3800. the current session timeout.  
  3801.  
  3802. If a user session is inactive for the full
  3803. timeout, the session is destroyed by the system.
  3804. No one can access the session after it times out, and the system
  3805. garbage collects it eventually.
  3806.  
  3807. =item $Session->Abandon()
  3808.  
  3809. The abandon method times out the session immediately.  All Session
  3810. data is cleared in the process, just as when any session times out.
  3811.  
  3812. =item $Session->Lock()  
  3813.  
  3814. API extension. If you are about to use $Session for many consecutive 
  3815. reads or writes, you can improve performance by explicitly locking 
  3816. $Session, and then unlocking, like:
  3817.  
  3818.   $Session->Lock();
  3819.   $Session->{count}++;
  3820.   $Session->{count}++;
  3821.   $Session->{count}++;
  3822.   $Session->UnLock();  
  3823.  
  3824. This sequence causes $Session to be locked and unlocked only
  3825. 1 time, instead of the 6 times that it would be locked otherwise,
  3826. 2 for each increment with one to read and one to write.
  3827.  
  3828. Because of flushing issues with SDBM_File and DB_File databases,
  3829. each lock actually ties fresh to the database, so the performance
  3830. savings here can be considerable.  
  3831.  
  3832. Note that if you have SessionSerialize set, $Session is
  3833. already locked for each script invocation automatically, as if
  3834. you had called $Session->Lock() in Script_OnStart.  Thus you 
  3835. do not need to worry about $Session locking for performance.
  3836. Please read the section on SessionSerialize for more info.
  3837.  
  3838. =item $Session->UnLock()
  3839.  
  3840. API Extension. Unlocks the $Session explicitly.  If you do not call this,
  3841. $Session will be unlocked automatically at the end of the 
  3842. script.
  3843.  
  3844. =back
  3845.  
  3846. =head2 $Response Object
  3847.  
  3848. This object manages the output from the ASP Application and the 
  3849. client web browser.  It does not store state information like the 
  3850. $Session object but does have a wide array of methods to call.
  3851.  
  3852. =over
  3853.  
  3854. =item $Response->{BinaryRef}
  3855.  
  3856. API extension. This is a perl reference to the buffered output of 
  3857. the $Response object, and can be used in the Script_OnFlush
  3858. global.asa event to modify the buffered output at runtime
  3859. to apply global changes to scripts output without having to 
  3860. modify all the scripts.  These changes take place before 
  3861. content is flushed to the client web browser.
  3862.  
  3863.  sub Script_OnFlush {
  3864.    my $ref = $Response->{BinaryRef};
  3865.    $$ref =~ s/\s+/ /sg; # to strip extra white space
  3866.  }
  3867.  
  3868. Check out the ./site/eg/global.asa for an example of its use.
  3869.  
  3870. =item $Response->{Buffer}
  3871.  
  3872. Default 1, when TRUE sends output from script to client only at
  3873. the end of processing the script.  When 0, response is not buffered,
  3874. and client is sent output as output is generated by the script.
  3875.  
  3876. =item $Response->{CacheControl}
  3877.  
  3878. Default "private", when set to public allows proxy servers to 
  3879. cache the content.  This setting controls the value set
  3880. in the HTTP header Cache-Control
  3881.  
  3882. =item $Response->{Charset}
  3883.  
  3884. This member when set appends itself to the value of the Content-Type
  3885. HTTP header.  If $Response->{Charset} = 'ISO-LATIN-1' is set, the 
  3886. corresponding header would look like:
  3887.  
  3888.   Content-Type: text/html; charset=ISO-LATIN-1
  3889.  
  3890. =item $Response->{Clean} = 0-9;
  3891.  
  3892. API extension. Set the Clean level, default 0, on a per script basis.  
  3893. Clean of 1-9 compresses text/html output.  Please see
  3894. the Clean config option for more information. This setting may
  3895. also be useful even if using compression to obfuscate HTML.
  3896.  
  3897. =item $Response->{ContentType} = "text/html"
  3898.  
  3899. Sets the MIME type for the current response being sent to the client.
  3900. Sent as an HTTP header.
  3901.  
  3902. =item $Response->{Debug} = 1|0
  3903.  
  3904. API extension.  Default set to value of Debug config.  May be
  3905. used to temporarily activate or inactivate $Response->Debug()
  3906. behavior.  Something like:
  3907.  
  3908.  {
  3909.    local $Response->{Debug} = 1;
  3910.    $Response->Debug($values);
  3911.  }
  3912.  
  3913. maybe be used to always log something.  The Debug()
  3914. method can be better than AppendToLog() because it will
  3915. log data in data structures one level deep, whereas
  3916. AppendToLog prints just raw string/scalar values.
  3917.  
  3918. =item $Response->{Expires} = $time
  3919.  
  3920. Sends a response header to the client indicating the $time 
  3921. in SECONDS in which the document should expire.  A time of 0 means
  3922. immediate expiration.  The header generated is a standard
  3923. HTTP date like: "Wed, 09 Feb 1994 22:23:32 GMT".
  3924.  
  3925. =item $Response->{ExpiresAbsolute} = $date
  3926.  
  3927. Sends a response header to the client with $date being an absolute
  3928. time to expire.  Formats accepted are all those accepted by 
  3929. HTTP::Date::str2time(), e.g.
  3930.  
  3931.  "Wed, 09 Feb 1994 22:23:32 GMT"     -- HTTP format
  3932.  "Tuesday, 08-Feb-94 14:15:29 GMT"   -- old rfc850 HTTP format
  3933.  
  3934.  "08-Feb-94"       -- old rfc850 HTTP format    
  3935.  "09 Feb 1994"     -- proposed new HTTP format  
  3936.  
  3937.  "Feb  3  1994"    -- Unix 'ls -l' format
  3938.  "Feb  3 17:03"    -- Unix 'ls -l' format
  3939.  
  3940. =item $Response->{FormFill} = 0|1
  3941.  
  3942. If true, HTML forms generated by the script output will
  3943. be auto filled with data from $Request->Form.  This feature
  3944. requires HTML::FillInForm to be installed.  Please see
  3945. the FormFill CONFIG for more information.
  3946.  
  3947. This setting overrides the FormFill config at runtime
  3948. for the script execution only.
  3949.  
  3950. =item $Response->{IsClientConnected}
  3951.  
  3952. 1 if web client is connected, 0 if not.  This value
  3953. starts set to 1, and will be updated whenever a
  3954. $Response->Flush() is called.  If BufferingOn is
  3955. set, by default $Response->Flush() will only be
  3956. called at the end of the HTML output.  
  3957.  
  3958. As of version 2.23 this value is updated correctly
  3959. before global.asa Script_OnStart is called, so 
  3960. global script termination may be correctly handled
  3961. during that event, which one might want to do 
  3962. with excessive user STOP/RELOADS when the web 
  3963. server is very busy.
  3964.  
  3965. An API extension $Response->IsClientConnected
  3966. may be called for refreshed connection status
  3967. without calling first a $Response->Flush
  3968.  
  3969. =item $Response->{PICS}
  3970.  
  3971. If this property has been set, a PICS-Label HTTP header will be
  3972. sent with its value.  For those that do not know, PICS is a header
  3973. that is useful in rating the internet.  It stands for 
  3974. Platform for Internet Content Selection, and you can find more
  3975. info about it at: http://www.w3.org
  3976.  
  3977. =item $Response->{Status} = $status
  3978.  
  3979. Sets the status code returned by the server.  Can be used to
  3980. set messages like 500, internal server error
  3981.  
  3982. =item $Response->AddHeader($name, $value)
  3983.  
  3984. Adds a custom header to a web page.  Headers are sent only before any
  3985. text from the main page is sent, so if you want to set a header
  3986. after some text on a page, you must turn BufferingOn.
  3987.  
  3988. =item $Response->AppendToLog($message)
  3989.  
  3990. Adds $message to the server log.  Useful for debugging.
  3991.  
  3992. =item $Response->BinaryWrite($data)
  3993.  
  3994. Writes binary data to the client.  The only
  3995. difference from $Response->Write() is that $Response->Flush()
  3996. is called internally first, so the data cannot be parsed 
  3997. as an html header.  Flushing flushes the header if has not
  3998. already been written.
  3999.  
  4000. If you have set the $Response->{ContentType}
  4001. to something other than text/html, cgi header parsing (see CGI
  4002. notes), will be automatically be turned off, so you will not
  4003. necessarily need to use BinaryWrite for writing binary data.
  4004.  
  4005. For an example of BinaryWrite, see the binary_write.htm example 
  4006. in ./site/eg/binary_write.htm
  4007.  
  4008. Please note that if you are on Win32, you will need to 
  4009. call binmode on a file handle before reading, if 
  4010. its data is binary.
  4011.  
  4012. =item $Response->Clear()
  4013.  
  4014. Erases buffered ASP output.
  4015.  
  4016. =item $Response->Cookies($name, [$key,] $value)
  4017.  
  4018. Sets the key or attribute of cookie with name $name to the value $value.
  4019. If $key is not defined, the Value of the cookie is set.
  4020. ASP CookiePath is assumed to be / in these examples.
  4021.  
  4022.  $Response->Cookies('name', 'value'); 
  4023.   --> Set-Cookie: name=value; path=/
  4024.  
  4025.  $Response->Cookies("Test", "data1", "test value");     
  4026.  $Response->Cookies("Test", "data2", "more test");      
  4027.  $Response->Cookies(
  4028.     "Test", "Expires", 
  4029.     &HTTP::Date::time2str(time+86400)
  4030.     ); 
  4031.  $Response->Cookies("Test", "Secure", 1);               
  4032.  $Response->Cookies("Test", "Path", "/");
  4033.  $Response->Cookies("Test", "Domain", "host.com");
  4034.   -->    Set-Cookie:Test=data1=test%20value&data2=more%20test;    \
  4035.          expires=Fri, 23 Apr 1999 07:19:52 GMT;        \
  4036.          path=/; domain=host.com; secure
  4037.  
  4038. The latter use of $key in the cookies not only sets cookie attributes
  4039. such as Expires, but also treats the cookie as a hash of key value pairs
  4040. which can later be accesses by
  4041.  
  4042.  $Request->Cookies('Test', 'data1');
  4043.  $Request->Cookies('Test', 'data2');
  4044.  
  4045. Because this is perl, you can (NOT PORTABLE) reference the cookies
  4046. directly through hash notation.  The same 5 commands above could be compressed to:
  4047.  
  4048.  $Response->{Cookies}{Test} = 
  4049.     { 
  4050.         Secure    => 1, 
  4051.         Value    =>    
  4052.             {
  4053.                 data1 => 'test value', 
  4054.                 data2 => 'more test'
  4055.             },
  4056.         Expires    => 86400, # not portable, see above
  4057.         Domain    => 'host.com',
  4058.         Path    => '/'
  4059.     };
  4060.  
  4061. and the first command would be:
  4062.  
  4063.  # you don't need to use hash notation when you are only setting 
  4064.  # a simple value
  4065.  $Response->{Cookies}{'Test Name'} = 'Test Value'; 
  4066.  
  4067. I prefer the hash notation for cookies, as this looks nice, and is 
  4068. quite perlish.  It is here to stay.  The Cookie() routine is 
  4069. very complex and does its best to allow access to the 
  4070. underlying hash structure of the data.  This is the best emulation 
  4071. I could write trying to match the Collections functionality of 
  4072. cookies in IIS ASP.
  4073.  
  4074. For more information on Cookies, please go to the source at
  4075. http://home.netscape.com/newsref/std/cookie_spec.html
  4076.  
  4077. =item $Response->Debug(@args)
  4078.  
  4079. API Extension. If the Debug config option is set greater than 0, 
  4080. this routine will write @args out to server error log.  refs in @args 
  4081. will be expanded one level deep, so data in simple data structures
  4082. like one-level hash refs and array refs will be displayed.  CODE
  4083. refs like
  4084.  
  4085.  $Response->Debug(sub { "some value" });
  4086.  
  4087. will be executed and their output added to the debug output.
  4088. This extension allows the user to tie directly into the
  4089. debugging capabilities of this module.
  4090.  
  4091. While developing an app on a production server, it is often 
  4092. useful to have a separate error log for the application
  4093. to catch debugging output separately.  One way of implementing 
  4094. this is to use the Apache ErrorLog configuration directive to 
  4095. create a separate error log for a virtual host. 
  4096.  
  4097. If you want further debugging support, like stack traces
  4098. in your code, consider doing things like:
  4099.  
  4100.  $Response->Debug( sub { Carp::longmess('debug trace') };
  4101.  $SIG{__WARN__} = \&Carp::cluck; # then warn() will stack trace
  4102.  
  4103. The only way at present to see exactly where in your script
  4104. an error occurred is to set the Debug config directive to 2,
  4105. and match the error line number to perl script generated
  4106. from your ASP script.  
  4107.  
  4108. However, as of version 0.10, the perl script generated from the 
  4109. asp script should match almost exactly line by line, except in 
  4110. cases of inlined includes, which add to the text of the original script, 
  4111. pod comments which are entirely yanked out, and <% # comment %> style
  4112. comments which have a \n added to them so they still work.
  4113.  
  4114. If you would like to see the HTML preceding an error 
  4115. while developing, consider setting the BufferingOn 
  4116. config directive to 0.
  4117.  
  4118. =item $Response->End()
  4119.  
  4120. Sends result to client, and immediately exits script.
  4121. Automatically called at end of script, if not already called.
  4122.  
  4123. =item $Response->ErrorDocument($code, $uri)
  4124.  
  4125. API extension that allows for the modification the Apache
  4126. ErrorDocument at runtime.  $uri may be a on site document,
  4127. off site URL, or string containing the error message.  
  4128.  
  4129. This extension is useful if you want to have scripts
  4130. set error codes with $Response->{Status} like 401
  4131. for authentication failure, and to then control from
  4132. the script what the error message looks like.
  4133.  
  4134. For more information on the Apache ErrorDocument mechanism,
  4135. please see ErrorDocument in the CORE Apache settings,
  4136. and the Apache->custom_response() API, for which this method
  4137. is a wrapper.
  4138.  
  4139. =item $Response->Flush()
  4140.  
  4141. Sends buffered output to client and clears buffer.
  4142.  
  4143. =item $Response->Include($filename, @args)
  4144.  
  4145. This API extension calls the routine compiled from asp script
  4146. in $filename with the args @args.  This is a direct translation
  4147. of the SSI tag 
  4148.  
  4149.   <!--#include file=$filename args=@args-->
  4150.  
  4151. Please see the SSI section for more on SSI in general.
  4152.  
  4153. This API extension was created to allow greater modularization
  4154. of code by allowing includes to be called with runtime 
  4155. arguments.  Files included are compiled once, and the 
  4156. anonymous code ref from that compilation is cached, thus
  4157. including a file in this manner is just like calling a 
  4158. perl subroutine.  The @args can be found in @_ in the
  4159. includes like:
  4160.  
  4161.   # include.inc
  4162.   <% my @args = @_; %>
  4163.  
  4164. As of 2.23, multiple return values can be returned from
  4165. an include like:
  4166.  
  4167.  my @rv = $Response->Include($filename, @args);
  4168.  
  4169. =item $Response->Include(\%cache_args, @sub_args) *CACHE API*
  4170.  
  4171. As of version 2.23, output from an include may be
  4172. cached with this API and the CONFIG settings CacheDir & CacheDB.  This
  4173. can be used to execute expensive includes only rarely
  4174. where applicable, drastically increasing performance in 
  4175. some cases.
  4176.  
  4177. This API extension applies to the entire include family:
  4178.  
  4179.   my @rv = $Response->Include(\%cache_args, @include_args)
  4180.   my $html_ref = $Response->TrapInclude(\%cache_args, @include_args)
  4181.   $Server->Execute(\%cache_args, @include_args)
  4182.  
  4183. For this output cache to work, you must load Apache::ASP
  4184. in the Apache parent httpd like so:
  4185.  
  4186.   # httpd.conf
  4187.   PerlModule Apache::ASP
  4188.  
  4189. The cache arguments are shown here
  4190.  
  4191.   $Response->Include({
  4192.     File => 'file.inc',
  4193.     Cache => 1, # to activate cache layer
  4194.     Expires => 3600, # to expire in one hour
  4195.     LastModified => time() - 600, # to expire if cached before 10 minutes ago
  4196.     Key => $Request->Form, # to cache based on checksum of serialized form data,
  4197.     Clear => 1, # always executes include & cache output
  4198.   }, @include_args);
  4199.  
  4200.   File - include file to execute, can be file name or \$script 
  4201.     script data passed in as a string reference.
  4202.  
  4203.   Cache - activate caching, will run like normal include without this
  4204.  
  4205.   Expires - only cache for this long in seconds
  4206.  
  4207.   LastModified - if cached before this time(), expire
  4208.  
  4209.   Key - The cache item identity.  Can be $data, \$data, \%data, \@data, 
  4210.     this data is serialized and combined with the filename & @include_args 
  4211.     to create a MD5 checksum to fetch from the cache with. If you wanted
  4212.     to cache the results of a search page from form data POSTed, 
  4213.     then this key could be 
  4214.  
  4215.       { Key => $Request->Form }
  4216.  
  4217.   Clear - If set to 1, or boolean true, will always execute the include 
  4218.     and update the cache entry for it.
  4219.  
  4220. Motivation: If an include takes 1 second to execute
  4221. because of complex SQL to a database, and you can
  4222. cache the output of this include because it is not realtime data,
  4223. and the cache layer runs at .01 seconds, then you have a 
  4224. 100 fold savings on that part of the script.  Site scalability
  4225. can be dramatically increased in this way by intelligently
  4226. caching bottlenecks in the web application.
  4227.  
  4228. Use Sparingly: If you have a fast include, then it may execute faster
  4229. than the cache layer runs, in which case you may actually
  4230. slow your site down by using this feature.  Therefore
  4231. try to use this sparingly, and only when sure you really
  4232. need it.  Apache::ASP scripts generally execute very
  4233. quickly, so most developers will not need to use this feature
  4234. at all.
  4235.  
  4236. =item $Response->Include(\$script_text, @args)
  4237.  
  4238. Added in Apache::ASP 2.11, this method allows for executing ASP scripts
  4239. that are generated dynamically by passing in a reference to the script
  4240. data instead of the file name.  This works just like the normal
  4241. $Response->Include() API, except a string reference is passed in
  4242. instead of a filename.  For example:
  4243.  
  4244.   <%
  4245.     my $script = "<\% print 'TEST'; %\>";
  4246.     $Response->Include(\$script);
  4247.   %>
  4248.  
  4249. This include would output TEST.  Note that tokens like
  4250. <% and %> must be escaped so Apache::ASP does not try
  4251. to compile those code blocks directly when compiling
  4252. the original script.  If the $script data were fetched
  4253. directly from some external resource like a database,
  4254. then these tokens would not need to be escaped at all as in:
  4255.  
  4256.   <%
  4257.     my $script = $dbh->selectrow_array(
  4258.        "select script_text from scripts where script_id = ?",
  4259.        undef, $script_id
  4260.        );
  4261.     $Response->Include(\$script);
  4262.   %>
  4263.  
  4264. This method could also be used to render other types of dynamic scripts,
  4265. like XML docs using XMLSubs for example, though for complex
  4266. runtime XML rendering, one should use something better suited like XSLT.
  4267. See the $Server->XSLT API for more on this topic.
  4268.  
  4269. =item $Response->IsClientConnected()
  4270.  
  4271. API Extension.  1 for web client still connected, 0 if 
  4272. disconnected which might happen if the user hits the stop button.
  4273. The original API for this $Response->{IsClientConnected}
  4274. is only updated after a $Response->Flush is called,
  4275. so this method may be called for a refreshed status.
  4276.  
  4277. Note $Response->Flush calls $Response->IsClientConnected
  4278. to update $Response->{IsClientConnected} so to use this
  4279. you are going straight to the source!  But if you are doing
  4280. a loop like:
  4281.  
  4282.   while(@data) {
  4283.     $Response->End if ! $Response->{IsClientConnected};
  4284.     my $row = shift @data;
  4285.     %> <%= $row %> <%
  4286.     $Response->Flush;
  4287.   }
  4288.  
  4289. Then its more efficient to use the member instead of 
  4290. the method since $Response->Flush() has already updated
  4291. that value for you.
  4292.  
  4293. =item $Response->Redirect($url)
  4294.  
  4295. Sends the client a command to go to a different url $url.  
  4296. Script immediately ends.
  4297.  
  4298. =item $Response->TrapInclude($file, @args)
  4299.  
  4300. Calls $Response->Include() with same arguments as
  4301. passed to it, but instead traps the include output buffer
  4302. and returns it as as a perl string reference.  This allows
  4303. one to postprocess the output buffer before sending
  4304. to the client.
  4305.  
  4306.   my $string_ref = $Response->TrapInclude('file.inc');
  4307.   $$string_ref =~ s/\s+/ /sg; # squash whitespace like Clean 1
  4308.   print $$string_ref;
  4309.  
  4310. The data is returned as a referenece to save on what
  4311. might be a large string copy.  You may dereference the data
  4312. with the $$string_ref notation.
  4313.  
  4314. =item $Response->Write($data)
  4315.  
  4316. Write output to the HTML page.  <%=$data%> syntax is shorthand for
  4317. a $Response->Write($data).  All final output to the client must at
  4318. some point go through this method.
  4319.  
  4320. =back
  4321.  
  4322. =head2 $Request Object
  4323.  
  4324. The request object manages the input from the client browser, like
  4325. posts, query strings, cookies, etc.  Normal return results are values
  4326. if an index is specified, or a collection / perl hash ref if no index 
  4327. is specified.  WARNING, the latter property is not supported in 
  4328. ActiveState PerlScript, so if you use the hashes returned by such
  4329. a technique, it will not be portable.
  4330.  
  4331. A normal use of this feature would be to iterate through the 
  4332. form variables in the form hash...
  4333.  
  4334.  $form = $Request->Form();
  4335.  for(keys %{$form}) {
  4336.     $Response->Write("$_: $form->{$_}<br>\n");
  4337.  }
  4338.  
  4339. Please see the ./site/eg/server_variables.htm asp file for this 
  4340. method in action.
  4341.  
  4342. Note that if a form POST or query string contains duplicate
  4343. values for a key, those values will be returned through
  4344. normal use of the $Request object:
  4345.  
  4346.   @values = $Request->Form('key');
  4347.  
  4348. but you can also access the internal storage, which is
  4349. an array reference like so:
  4350.  
  4351.   $array_ref = $Request->{Form}{'key'};
  4352.   @values = @{$array_ref};
  4353.  
  4354. Please read the PERLSCRIPT section for more information 
  4355. on how things like $Request->QueryString() & $Request->Form()
  4356. behave as collections.
  4357.  
  4358. =over
  4359.  
  4360. =item $Request->{Method}
  4361.  
  4362. API extension.  Returns the client HTTP request method, as in
  4363. GET or POST.  Added in version 2.31.
  4364.  
  4365. =item $Request->{TotalBytes}
  4366.  
  4367. The amount of data sent by the client in the body of the 
  4368. request, usually the length of the form data.  This is
  4369. the same value as $Request->ServerVariables('CONTENT_LENGTH')
  4370.  
  4371. =item $Request->BinaryRead($length)
  4372.  
  4373. Returns a string whose contents are the first $length bytes
  4374. of the form data, or body, sent by the client request.
  4375. This data is the raw data sent by the client, without any
  4376. parsing done on it by Apache::ASP.
  4377.  
  4378. Note that BinaryRead will not return any data for file uploads.
  4379. Please see the $Request->FileUpload() interface for access
  4380. to this data.  $Request->Form() data will also be available
  4381. as normal.
  4382.  
  4383. =item $Request->ClientCertificate()
  4384.  
  4385. Not implemented.
  4386.  
  4387. =item $Request->Cookies($name [,$key])
  4388.  
  4389. Returns the value of the Cookie with name $name.  If a $key is
  4390. specified, then a lookup will be done on the cookie as if it were
  4391. a query string.  So, a cookie set by:
  4392.  
  4393.  Set-Cookie: test=data1=1&data2=2
  4394.  
  4395. would have a value of 2 returned by $Request->Cookies('test','data2').
  4396.  
  4397. If no name is specified, a hash will be returned of cookie names 
  4398. as keys and cookie values as values.  If the cookie value is a query string, 
  4399. it will automatically be parsed, and the value will be a hash reference to 
  4400. these values.
  4401.  
  4402. When in doubt, try it out.  Remember that unless you set the Expires
  4403. attribute of a cookie with $Response->Cookies('cookie', 'Expires', $xyz),
  4404. the cookies that you set will only last until you close your browser, 
  4405. so you may find your self opening & closing your browser a lot when 
  4406. debugging cookies.
  4407.  
  4408. For more information on cookies in ASP, please read $Response->Cookies()
  4409.  
  4410. =item $Request->FileUpload($form_field, $key)
  4411.  
  4412. API extension.  The FileUpload interface to file upload data is
  4413. stabilized.  The internal representation of the file uploads
  4414. is a hash of hashes, one hash per file upload found in 
  4415. the $Request->Form() collection.  This collection of collections
  4416. may be queried through the normal interface like so:
  4417.  
  4418.   $Request->FileUpload('upload_file', 'ContentType');
  4419.   $Request->FileUpload('upload_file', 'FileHandle');
  4420.   $Request->FileUpload('upload_file', 'BrowserFile');
  4421.   $Request->FileUpload('upload_file', 'Mime-Header');
  4422.   $Request->FileUpload('upload_file', 'TempFile');
  4423.  
  4424.   * note that TempFile must be use with the UploadTempFile 
  4425.     configuration setting.
  4426.  
  4427. The above represents the old slow collection interface, 
  4428. but like all collections in Apache::ASP, you can reference
  4429. the internal hash representation more easily.
  4430.  
  4431.   my $fileup = $Request->{FileUpload}{upload_file};
  4432.   $fileup->{ContentType};
  4433.   $fileup->{BrowserFile};
  4434.   $fileup->{FileHandle};
  4435.   $fileup->{Mime-Header};
  4436.   $fileup->{TempFile};
  4437.  
  4438. =item $Request->Form($name)
  4439.  
  4440. Returns the value of the input of name $name used in a form
  4441. with POST method.  If $name is not specified, returns a ref to 
  4442. a hash of all the form data.  One can use this hash to 
  4443. create a nice alias to the form data like:
  4444.  
  4445.  # in global.asa
  4446.  use vars qw( $Form );
  4447.  sub Script_OnStart {
  4448.    $Form = $Request->Form;
  4449.  }
  4450.  # then in ASP scripts
  4451.  <%= $Form->{var} %>
  4452.  
  4453. File upload data will be loaded into $Request->Form('file_field'), 
  4454. where the value is the actual file name of the file uploaded, and 
  4455. the contents of the file can be found by reading from the file
  4456. name as a file handle as in:
  4457.  
  4458.  while(read($Request->Form('file_field_name'), $data, 1024)) {};
  4459.  
  4460. For more information, please see the CGI / File Upload section,
  4461. as file uploads are implemented via the CGI.pm module.  An
  4462. example can be found in the installation 
  4463. samples ./site/eg/file_upload.asp
  4464.  
  4465. =item $Request->Params($name)
  4466.  
  4467. API extension. If RequestParams CONFIG is set, the $Request->Params 
  4468. object is created with combined contents of $Request->QueryString 
  4469. and $Request->Form.  This is for developer convenience simlar 
  4470. to CGI.pm's param() method.  Just like for $Response->Form, 
  4471. one could create a nice alias like:
  4472.  
  4473.  # in global.asa
  4474.  use vars qw( $Params );
  4475.  sub Script_OnStart {
  4476.    $Params = $Request->Params;
  4477.  }
  4478.  
  4479. =item $Request->QueryString($name)
  4480.  
  4481. Returns the value of the input of name $name used in a form
  4482. with GET method, or passed by appending a query string to the end of
  4483. a url as in http://localhost/?data=value.  
  4484. If $name is not specified, returns a ref to a hash of all the query 
  4485. string data.
  4486.  
  4487. =item $Request->ServerVariables($name)
  4488.  
  4489. Returns the value of the server variable / environment variable
  4490. with name $name.  If $name is not specified, returns a ref to 
  4491. a hash of all the server / environment variables data.  The following
  4492. would be a common use of this method:
  4493.  
  4494.  $env = $Request->ServerVariables();
  4495.  # %{$env} here would be equivalent to the cgi %ENV in perl.
  4496.  
  4497. =back
  4498.  
  4499. =head2 $Application Object
  4500.  
  4501. Like the $Session object, you may use the $Application object to 
  4502. store data across the entire life of the application.  Every
  4503. page in the ASP application always has access to this object.
  4504. So if you wanted to keep track of how many visitors there where
  4505. to the application during its lifetime, you might have a line
  4506. like this:
  4507.  
  4508.  $Application->{num_users}++
  4509.  
  4510. The Lock and Unlock methods are used to prevent simultaneous 
  4511. access to the $Application object.
  4512.  
  4513. =over
  4514.  
  4515. =item $Application->Lock()
  4516.  
  4517. Locks the Application object for the life of the script, or until
  4518. UnLock() unlocks it, whichever comes first.  When $Application
  4519. is locked, this guarantees that data being read and written to it 
  4520. will not suddenly change on you between the reads and the writes.
  4521.  
  4522. This and the $Session object both lock automatically upon
  4523. every read and every write to ensure data integrity.  This 
  4524. lock is useful for concurrent access control purposes.
  4525.  
  4526. Be careful to not be too liberal with this, as you can quickly 
  4527. create application bottlenecks with its improper use.
  4528.  
  4529. =item $Application->UnLock()
  4530.  
  4531. Unlocks the $Application object.  If already unlocked, does nothing.
  4532.  
  4533. =item $Application->GetSession($sess_id)
  4534.  
  4535. This NON-PORTABLE API extension returns a user $Session given
  4536. a session id.  This allows one to easily write a session manager if
  4537. session ids are stored in $Application during Session_OnStart, with 
  4538. full access to these sessions for administrative purposes.  
  4539.  
  4540. Be careful not to expose full session ids over the net, as they
  4541. could be used by a hacker to impersonate another user.  So when 
  4542. creating a session manager, for example, you could create
  4543. some other id to reference the SessionID internally, which 
  4544. would allow you to control the sessions.  This kind of application
  4545. would best be served under a secure web server.
  4546.  
  4547. The ./site/eg/global_asa_demo.asp script makes use of this routine 
  4548. to display all the data in current user sessions.
  4549.  
  4550. =item $Application->SessionCount()
  4551.  
  4552. This NON-PORTABLE method returns the current number of active sessions
  4553. in the application, and is enabled by the SessionCount configuration setting.
  4554. This method is not implemented as part of the original ASP
  4555. object model, but is implemented here because it is useful.  In particular,
  4556. when accessing databases with license requirements, one can monitor usage
  4557. effectively through accessing this value.
  4558.  
  4559. =back
  4560.  
  4561. =head2 $Server Object
  4562.  
  4563. The server object is that object that handles everything the other
  4564. objects do not.  The best part of the server object for Win32 users is 
  4565. the CreateObject method which allows developers to create instances of
  4566. ActiveX components, like the ADO component.
  4567.  
  4568. =over
  4569.  
  4570. =item $Server->{ScriptTimeout} = $seconds
  4571.  
  4572. Not implemented. May never be.  Please see the 
  4573. Apache Timeout configuration option, normally in httpd.conf.  
  4574.  
  4575. =item $Server->Config($setting)
  4576.  
  4577. API extension.  Allows a developer to read the CONFIG
  4578. settings, like Global, GlobalPackage, StateDir, etc.
  4579. Currently implemented as a wrapper around 
  4580.  
  4581.   Apache->dir_config($setting)
  4582.  
  4583. May also be invoked as $Server->Config(), which will
  4584. return a hash ref of all the PerlSetVar settings. 
  4585.  
  4586. =item $Server->CreateObject($program_id)
  4587.  
  4588. Allows use of ActiveX objects on Win32.  This routine returns
  4589. a reference to an Win32::OLE object upon success, and nothing upon
  4590. failure.  It is through this mechanism that a developer can 
  4591. utilize ADO.  The equivalent syntax in VBScript is 
  4592.  
  4593.  Set object = Server.CreateObject(program_id)
  4594.  
  4595. For further information, try 'perldoc Win32::OLE' from your
  4596. favorite command line.
  4597.  
  4598. =item $Server->Execute($file, @args)
  4599.  
  4600. New method from ASP 3.0, this does the same thing as
  4601.  
  4602.   $Response->Include($file, @args)
  4603.  
  4604. and internally is just a wrapper for such.  Seems like we
  4605. had this important functionality before the IIS/ASP camp!
  4606.  
  4607. =item $Server->File()
  4608.  
  4609. Returns the absolute file path to current executing script.
  4610. Same as Apache->request->filename when running under mod_perl.
  4611.  
  4612. ASP API extension.
  4613.  
  4614. =item $Server->GetLastError()
  4615.  
  4616. Not implemented, will likely not ever be because this is dependent
  4617. on how IIS handles errors and is not relevant in Apache.
  4618.  
  4619. =item $Server->HTMLEncode( $string || \$string )
  4620.  
  4621. Returns an HTML escapes version of $string. &, ", >, <, are each
  4622. escapes with their HTML equivalents.  Strings encoded in this nature
  4623. should be raw text displayed to an end user, as HTML tags become 
  4624. escaped with this method.
  4625.  
  4626. As of version 2.23, $Server->HTMLEncode() may take a string reference
  4627. for an optmization when encoding a large buffer as an API extension.
  4628. Here is how one might use one over the other:
  4629.  
  4630.   my $buffer = '&' x 100000;
  4631.   $buffer = $Server->HTMLEncode($buffer);
  4632.   print $buffer;
  4633.     - or -
  4634.   my $buffer = '&' x 100000;
  4635.   $Server->HTMLEncode(\$buffer);
  4636.   print $buffer;
  4637.  
  4638. Using the reference passing method in benchmarks on 100K of
  4639. data was 5% more efficient, but maybe useful for some.
  4640. It saves on copying the 100K buffer twice.
  4641.  
  4642. =item $Server->MapInclude($include)
  4643.  
  4644. API extension.  Given the include $include, as an absolute or relative file name to the current
  4645. executing script, this method returns the file path that the include would
  4646. be found from the include search path.  The include search path is the 
  4647. current script directory, Global, and IncludesDir directories.
  4648.  
  4649. If the include is not found in the includes search path, then undef, or bool false,
  4650. is returned. So one may do something like this:
  4651.  
  4652.   if($Server->MapInclude('include.inc')) {
  4653.     $Response->Include('include.inc');
  4654.   }
  4655.  
  4656. This code demonstrates how one might only try to execute an include if
  4657. it exists, which is useful since a script will error if it tries to execute an include
  4658. that does not exist.
  4659.  
  4660. =item $Server->MapPath($url);
  4661.  
  4662. Given the url $url, absolute, or relative to the current executing script,
  4663. this method returns the equivalent filename that the server would 
  4664. translate the request to, regardless or whether the request would be valid.
  4665.  
  4666. Only a $url that is relative to the host is valid.  Urls like "." and 
  4667. "/" are fine arguments to MapPath, but http://localhost would not be.
  4668.  
  4669. To see this method call in action, check out the sample ./site/eg/server.htm
  4670. script.
  4671.  
  4672. =item $Server->Mail(\%mail, %smtp_args);
  4673.  
  4674. With the Net::SMTP and Net::Config modules installed, which are part of the 
  4675. perl libnet package, you may use this API extension to send email.  The 
  4676. \%mail hash reference that you pass in must have values for at least
  4677. the To, From, and Subject headers, and the Body of the mail message.
  4678.  
  4679. The return value of this routine is 1 for success, 0 for failure.  If the MailHost
  4680. SMTP server is not available, this will have a return value of 0.
  4681.  
  4682. You could send an email like so:
  4683.  
  4684.  $Server->Mail({
  4685.         To => 'somebody@yourdomain.com.foobar',
  4686.         From => 'youremail@yourdomain.com.foobar',
  4687.         Subject => 'Subject of Email',
  4688.         Body => 
  4689.          'Body of message. '.
  4690.          'You might have a lot to say here!',
  4691.         Organization => 'Your Organization',
  4692.                 CC => 'youremailcc@yourdomain.com.foobar',
  4693.                 BCC => 'youremailbcc@yourdomain.com.foobar',
  4694.         Debug => 0 || 1,
  4695.            });
  4696.  
  4697. Any extra fields specified for the email will be interpreted
  4698. as headers for the email, so to send an HTML email, you 
  4699. could set 'Content-Type' => 'text/html' in the above example.
  4700.  
  4701. If you have MailFrom configured, this will be the default
  4702. for the From header in your email.  For more configuration
  4703. options like the MailHost setting, check out the CONFIG section.
  4704.  
  4705. The return value of this method call will be boolean for
  4706. success of the mail being sent.
  4707.  
  4708. If you would like to specially configure the Net::SMTP 
  4709. object used internally, you may set %smtp_args and they
  4710. will be passed on when that object is initialized.
  4711. "perldoc Net::SMTP" for more into on this topic.
  4712.  
  4713. If you would like to include the output of an ASP page as the
  4714. body of the mail message, you might do something like:
  4715.  
  4716.   my $mail_body = $Response->TrapInclude('mail_body.inc');
  4717.   $Server->Mail({ %mail, Body => $$mail_body });
  4718.  
  4719. =item $Server->RegisterCleanup($sub) 
  4720.  
  4721.  non-portable extension
  4722.  
  4723. Sets a subroutine reference to be executed after the script ends,
  4724. whether normally or abnormally, the latter occurring 
  4725. possibly by the user hitting the STOP button, or the web server
  4726. being killed.  This subroutine must be a code reference 
  4727. created like:
  4728.  
  4729.  $Server->RegisterCleanup(sub { $main::Session->{served}++; });
  4730.    or
  4731.  sub served { $main::Session->{served}++; }
  4732.  $Server->RegisterCleanup(\&served);
  4733.  
  4734. The reference to the subroutine passed in will be executed.
  4735. Though the subroutine will be executed in anonymous context, 
  4736. instead of the script, all objects will still be defined 
  4737. in main::*, that you would reference normally in your script.  
  4738. Output written to $main::Response will have no affect at 
  4739. this stage, as the request to the www client has already completed.
  4740.  
  4741. Check out the ./site/eg/register_cleanup.asp script for an example
  4742. of this routine in action.
  4743.  
  4744. =item $Server->Transfer($file, @args)
  4745.  
  4746. New method from ASP 3.0.  Transfers control to another script.  
  4747. The Response buffer will not be cleared automatically, so if you 
  4748. want this to serve as a faster $Response->Redirect(), you will need to 
  4749. call $Response->Clear() before calling this method.  
  4750.  
  4751. This new script will take over current execution and 
  4752. the current script will not continue to be executed
  4753. afterwards.  It differs from Execute() because the 
  4754. original script will not pick up where it left off.
  4755.  
  4756. As of Apache::ASP 2.31, this method now accepts optional
  4757. arguments like $Response->Include & $Server->Execute.  
  4758. $Server->Transfer is now just a wrapper for:
  4759.  
  4760.   $Response->Include($file, @args);
  4761.   $Response->End;
  4762.  
  4763. =item $Server->URLEncode($string)
  4764.  
  4765. Returns the URL-escaped version of the string $string. +'s are substituted in
  4766. for spaces and special characters are escaped to the ascii equivalents.
  4767. Strings encoded in this manner are safe to put in urls... they are especially
  4768. useful for encoding data used in a query string as in:
  4769.  
  4770.  $data = $Server->URLEncode("test data");
  4771.  $url = "http://localhost?data=$data";
  4772.  
  4773.  $url evaluates to http://localhost?data=test+data, and is a 
  4774.  valid URL for use in anchor <a> tags and redirects, etc.
  4775.  
  4776. =item $Server->URL($url, \%params) 
  4777.  
  4778. Will return a URL with %params serialized into a query 
  4779. string like:
  4780.  
  4781.   $url = $Server->URL('test.asp', { test => value });
  4782.  
  4783. which would give you a URL of test.asp?test=value
  4784.  
  4785. Used in conjunction with the SessionQuery* settings, the returned
  4786. URL will also have the session id inserted into the query string, 
  4787. making this a critical part of that method of implementing 
  4788. cookieless sessions.  For more information on that topic 
  4789. please read on the setting
  4790. in the CONFIG section, and the SESSIONS section too.
  4791.  
  4792. =item $Server->XSLT(\$xsl_data, \$xml_data)
  4793.  
  4794.  * NON-PORTABLE API EXTENSION *
  4795.  
  4796. This method takes string references for XSL and XML data
  4797. and returns the XSLT output as a string reference like:
  4798.  
  4799.   my $xslt_data_ref = $Server->XSLT(\$xsl_data, \$xml_data)
  4800.   print $$xslt_data_ref;
  4801.  
  4802. The XSLT parser defaults to XML::XSLT, and is configured with the 
  4803. XSLTParser setting, which can also use XML::Sablotron ( support added in 2.11 ), 
  4804. and XML::LibXSLT ( support added in 2.29 ). 
  4805. Please see the CONFIG section for more information on the 
  4806. XSLT* settings that drive this API.  The XSLT setting itself 
  4807. uses this API internally to do its rendering.
  4808.  
  4809. This API was created to allow developers easy XSLT component
  4810. rendering without having to render the entire ASP scripts
  4811. via XSLT.  This will make an easy plugin architecture for
  4812. those looking to integrate XML into their existing ASP
  4813. application frameworks.
  4814.  
  4815. At some point, the API will likely take files as arguments,
  4816. but not as of the 2.11 release.
  4817.  
  4818. =back
  4819.  
  4820. =head1 SSI
  4821.  
  4822. SSI is great!  One of the main features of SSI is to include
  4823. other files in the script being requested.  In Apache::ASP, this
  4824. is implemented in a couple ways, the most crucial of which
  4825. is implemented in the file include.  Formatted as
  4826.  
  4827.  <!--#include file=filename.inc-->
  4828.  
  4829. ,the .inc being merely a convention, text from the included 
  4830. file will be inserted directly into the script being executed
  4831. and the script will be compiled as a whole.  Whenever the 
  4832. script or any of its includes change, the script will be 
  4833. recompiled.
  4834.  
  4835. Includes go a great length to promote good decomposition
  4836. and code sharing in ASP scripts, but they are still 
  4837. fairly static.  As of version .09, includes may have dynamic
  4838. runtime execution, as subroutines compiled into the global.asa
  4839. namespace.  The first way to invoke includes dynamically is
  4840.  
  4841.  <!--#include file=filename.inc args=@args-->
  4842.  
  4843. If @args is specified, Apache::ASP knows to execute the 
  4844. include at runtime instead of inlining it directly into 
  4845. the compiled code of the script.  It does this by
  4846. compiling the script at runtime as a subroutine, and 
  4847. caching it for future invocations.  Then the compiled
  4848. subroutine is executed and has @args passed into its
  4849. as arguments.
  4850.  
  4851. This is still might be too static for some, as @args
  4852. is still hardcoded into the ASP script, so finally,
  4853. one may execute an include at runtime by utilizing
  4854. this API extension
  4855.  
  4856.    $Response->Include("filename.inc", @args);
  4857.  
  4858. which is a direct translation of the dynamic include above.
  4859.  
  4860. Although inline includes should be a little faster,
  4861. runtime dynamic includes represent great potential
  4862. savings in httpd memory, as includes are shared
  4863. between scripts keeping the size of each script
  4864. to a minimum.  This can often be significant saving
  4865. if much of the formatting occurs in an included 
  4866. header of a www page.
  4867.  
  4868. By default, all includes will be inlined unless
  4869. called with an args parameter.  However, if you
  4870. want all your includes to be compiled as subs and 
  4871. dynamically executed at runtime, turn the DynamicIncludes
  4872. config option on as documented above.
  4873.  
  4874. That is not all!  SSI is full featured.  One of the 
  4875. things missing above is the 
  4876.  
  4877.  <!--#include virtual=filename.cgi-->
  4878.  
  4879. tag.  This and many other SSI code extensions are available
  4880. by filtering Apache::ASP output through Apache::SSI via
  4881. the Apache::Filter and the Filter config options.  For
  4882. more information on how to wire Apache::ASP and Apache::SSI
  4883. together, please see the Filter config option documented
  4884. above.  Also please see Apache::SSI for further information
  4885. on the capabilities it offers.
  4886.  
  4887. =head1 EXAMPLES
  4888.  
  4889. Use with Apache.  Copy the ./site/eg directory from the ASP installation 
  4890. to your Apache document tree and try it out!  You have to put 
  4891. "AllowOverride All" in your <Directory> config section to let the 
  4892. .htaccess file in the ./site/eg installation directory do its work.  
  4893.  
  4894. IMPORTANT (FAQ): Make sure that the web server has write access to 
  4895. that directory.  Usually a 
  4896.  
  4897.  chmod -R 0777 eg
  4898.  
  4899. will do the trick :)
  4900.  
  4901. =head1 SESSIONS
  4902.  
  4903. Cookies are used by default for user $Session support ( see OBJECTS ).  
  4904. In order to track a web user and associate server side data 
  4905. with that client, the web server sets, and the web client returns 
  4906. a 32 byte session id identifier cookie.  This implementation 
  4907. is very secure and  may be used in secure HTTPS transactions, 
  4908. and made stronger with SecureSession and ParanoidSession 
  4909. settings (see CONFIG ).
  4910.  
  4911. However good cookies are for this kind of persistent
  4912. state management between HTTP requests, they have long 
  4913. been under fire for security risks associated with
  4914. JavaScript security exploits and privacy abuse by 
  4915. large data tracking companies. 
  4916.  
  4917. Because of these reasons, web users will sometimes turn off
  4918. their cookies, rendering normal ASP session implementations
  4919. powerless, resulting in a new $Session generated every request.
  4920. This is not good for ASP style sessions.
  4921.  
  4922. =head2 Cookieless Sessions
  4923.  
  4924.  *** See WARNING Below ***
  4925.  
  4926. So we now have more ways to track sessions with the 
  4927. SessionQuery* CONFIG settings, that allow a web developer 
  4928. to embed the session id in URL query strings when use 
  4929. of cookies is denied.  The implementations work such that
  4930. if a user has cookies turned on, then cookies will be 
  4931. used, but for those users with cookies turned off,
  4932. the session ids will be parsed into document URLs.
  4933.  
  4934. The first and easiest method that a web developer may use 
  4935. to implement cookieless sessions are with SessionQueryParse*
  4936. directives which enable Apache::ASP to the parse the session id
  4937. into document URLs on the fly.  Because this is resource
  4938. inefficient, there is also the SessionQuery* directives
  4939. that may be used with the $Server->URL($url,\%params) method to 
  4940. generate custom URLs with the session id in its query string.
  4941.  
  4942. To see an example of these cookieless sessions in action, 
  4943. check out the ./site/eg/session_query_parse.asp example.
  4944.  
  4945.  *** WARNING ***
  4946.  
  4947. If you do use these methods, then be VERY CAREFUL
  4948. of linking offsite from a page that was accessed with a 
  4949. session id in a query string.  This is because this session
  4950. id will show up in the HTTP_REFERER logs of the linked to 
  4951. site, and a malicious hacker could use this information to
  4952. compromise the security of your site's $Sessions, even if 
  4953. these are run under a secure web server.  
  4954.  
  4955. In order to shake a session id off an HTTP_REFERER for a link 
  4956. taking a user offsite, you must point that link to a redirect 
  4957. page that will redirect a user, like so:
  4958.  
  4959.  <% 
  4960.     # "cross site scripting bug" prevention
  4961.     my $sanitized_url = 
  4962.     $Server->HTMLEncode($Response->QueryString('OffSiteUrl'));
  4963.  %>
  4964.  <html>
  4965.  <head>
  4966.  <meta http-equiv=refresh content='0;URL=<%=$sanitized_url%>'>
  4967.  </head>
  4968.  <body>    
  4969.     Redirecting you offsite to 
  4970.     <a href=<%=$sanitized_url%> >here</a>...
  4971.  </body>
  4972.  </html>
  4973.  
  4974. Because the web browser visits a real page before being redirected
  4975. with the <meta> tag, the HTTP_REFERER will be set to this page.
  4976. Just be sure to not link to this page with a session id in its
  4977. query string.  
  4978.  
  4979. Unfortunately a simple $Response->Redirect() will not work here,
  4980. because the web browser will keep the HTTP_REFERER of the 
  4981. original web page if only a normal redirect is used.
  4982.  
  4983. =head1 XML/XSLT
  4984.  
  4985. =head2 Custom Tags with XMLSubsMatch
  4986.  
  4987. Before XML, there was the need to make HTML markup smarter.
  4988. Apache::ASP gives you the ability to have a perl
  4989. subroutine handle the execution of any predefined tag,
  4990. taking the tag descriptors, and the text contained between,
  4991. as arguments of the subroutine.  This custom tag
  4992. technology can be used to extend a web developer's abilities
  4993. to add dynamic pieces without having to visibly use 
  4994. <% %> style code entries.
  4995.  
  4996. So, lets say that you have a table that 
  4997. you want to insert for an employee with contact 
  4998. info and the like, you could set up a tag like:
  4999.  
  5000.  <my:new-employee name="Jane" last="Doe" phone="555-2222">
  5001.    Jane Doe has been here since 1998.
  5002.  </my:new-employee>
  5003.  
  5004. To render it with a custom tag, you would tell 
  5005. the Apache::ASP parser to render the tag with a 
  5006. subroutine:
  5007.  
  5008.   PerlSetVar XMLSubsMatch my:new-employee
  5009.  
  5010. Any colons, ':', in the XML custom tag will turn
  5011. into '::', a perl package separator, so the my:employee
  5012. tag would translate to the my::employee subroutine, or the 
  5013. employee subroutine in the my package.  Any dash "-" will 
  5014. also be translated to an underscore "_", as dash is not valid
  5015. in the names of perl subroutines.
  5016.  
  5017. Then you would create the my::employee subroutine in the my 
  5018. perl package or whereever like so:
  5019.  
  5020.   package my;
  5021.   sub new_employee {
  5022.     my($attributes, $body) = @_;
  5023.     $main::Response->Include('new_employee.inc', $attributes, $body);
  5024.   }
  5025.   1;
  5026.  
  5027.   <!-- # new_employee.inc file somewhere else, maybe in Global directory -->
  5028.   <% my($attributes, $body) = @_; %>
  5029.   <table>
  5030.   <% for('name', 'last', 'phone') { %>
  5031.     <tr>
  5032.       <td><b><%=ucfirst $_ %></b>:</td>
  5033.       <td><%= $attributes->{$_} %></td>
  5034.     </tr>
  5035.   <% } %>
  5036.   <tr><td colspan=2><%= $body %></td></tr>
  5037.   </table>
  5038.   <!-- # end new_employee.inc file -->
  5039.  
  5040. The $main::Response->Include() would then delegate the rendering
  5041. of the new-employee to the new_employee.inc ASP script include.
  5042.  
  5043. Though XML purists would not like this custom tag technology
  5044. to be related to XML, the reality is that a careful
  5045. site engineer could render full XML documents with this
  5046. technology, applying all the correct styles that one might
  5047. otherwise do with XSLT. 
  5048.  
  5049. Custom tags defined in this way can be used as XML tags
  5050. are defined with both a body and without as it
  5051.  
  5052.   <my:new-employee>...</my:new-employee>
  5053.  
  5054. and just
  5055.  
  5056.   <my:new-employee />
  5057.  
  5058. These tags are very powerful in that they can also
  5059. enclose normal ASP logic, like:
  5060.  
  5061.   <my:new-employee>
  5062.     <!-- normal ASP logic -->
  5063.     <% my $birthday = &HTTP::Date::time2str(time - 25 * 86400 * 365); %>
  5064.  
  5065.     <!-- ASP inserts -->
  5066.     This employee has been online for <%= int(rand()*600)+1 %>
  5067.     seconds, and was born near <%= $birthday %>.
  5068.   </my:new-employee>   
  5069.  
  5070. For an example of this custom XML tagging in action, please check 
  5071. out the ./site/eg/xml_subs.asp script.  
  5072.  
  5073. =head2 XSLT Tranformations
  5074.  
  5075. XML is good stuff, but what can you use it for? The principle is
  5076. that by having data and style separated in XML and XSL files, you
  5077. can reformat your data more easily in the future, and you 
  5078. can render your data in multiple formats, just as easily 
  5079. as for your web site, so you might render your site to
  5080. a PDA, or a cell phone just as easily as to a browser, and all
  5081. you have to do is set up the right XSL stylesheets to do the
  5082. transformation (XSLT).
  5083.  
  5084. With native XML/XSLT support, Apache::ASP scripts may be the
  5085. source of XML data that the XSL file transforms, and the XSL file
  5086. itself will be first executed as an ASP script also.  The XSLT 
  5087. transformation is handled by XML::XSLT or XML::Sablotron and you can
  5088. see an example of it in action at the ./site/eg/xslt.xml XML script.  
  5089.  
  5090. To specify a XSL stylesheet, use the setting:
  5091.  
  5092.   PerlSetVar XSLT template.xsl
  5093.  
  5094. where template.xsl could be any file.  By default this will
  5095. XSLT transform all ASP scripts so configured, but you can separate xml
  5096. scripts from the rest with the setting:
  5097.  
  5098.   PerlSetVar XSLTMatch xml$
  5099.  
  5100. where all files with the ending xml would undergo a XSLT transformation.
  5101.  
  5102. Note that XSLT depends on the installation of XML::XSLT,
  5103. which in turn depends on XML::DOM, and XML::Parser.
  5104. As of version 2.11, XML::Sablotron may also be used by
  5105. setting:
  5106.  
  5107.   PerlSetVar XSLTParser XML::Sablotron
  5108.  
  5109. and XML::LibXSLT may be used, as of 2.29, by setting
  5110.  
  5111.   PerlSetVar XSLTParser XML::LibXSLT
  5112.  
  5113. If you would like to install XML::Sablotron or XML::LibXSLT,
  5114. you will first have to install the libraries that these perl
  5115. modules use, which you can get at:
  5116.  
  5117.   libxslt - The XSLT C Library for Gnome
  5118.   http://xmlsoft.org/XSLT/
  5119.  
  5120.   Sablotron - Ginger Alliance
  5121.   http://www.gingerall.com
  5122.  
  5123. For more on XML::XSLT, the default XSLT engine that Apache::ASP
  5124. will use, please see:
  5125.  
  5126.   XML::XSLT
  5127.   http://xmlxslt.sourceforge.net/
  5128.  
  5129. XML:XSLT was the first supported XSLT engine as has the benefit
  5130. of being written in pure perl so that though while it is slower
  5131. than the other solutions, it is easier to port.
  5132.  
  5133. If you would like to cache XSLT tranformations, which
  5134. is highly recommended, just set:
  5135.  
  5136.   PerlSetVar XSLTCache 1
  5137.  
  5138. Please see the Cache settings in the CONFIG section for
  5139. more about how to configure the XSLTCache.
  5140.  
  5141. =head2 References
  5142.  
  5143. For more information about XSLT, please see the standard at:
  5144.  
  5145.   http://www.w3.org/TR/xslt
  5146.  
  5147. For their huge ground breaking XML efforts, these other XML OSS
  5148. projects need mention:
  5149.  
  5150.   Cocoon - XML-based web publishing, in Java 
  5151.   http://xml.apache.org/cocoon/
  5152.  
  5153.   AxKit - XML web publishing with Apache & mod_perl
  5154.   http://www.axkit.org/
  5155.  
  5156. =head1 CGI
  5157.  
  5158. CGI has been the standard way of deploying web applications long before
  5159. ASP came along.  In the CGI gateway world, CGI.pm has been a widely
  5160. used module in building CGI applications, and Apache::ASP is compatible
  5161. with scripts written with CGI.pm.  Also, as of version 2.19, Apache::ASP
  5162. can run in standalone CGI mode for the Apache web server without
  5163. mod_perl being available.  See "Standalone CGI Mode" section below.
  5164.  
  5165. Following are some special notes with respect to compatibility with CGI
  5166. and CGI.pm.  Use of CGI.pm in any of these ways was made possible through 
  5167. a great amount of work, and is not guaranteed to be portable with other perl 
  5168. ASP implementations, as other ASP implementations will likely be more limited.
  5169.  
  5170. =over
  5171.  
  5172. =item Standalone CGI Mode, without mod_perl
  5173.  
  5174. As of version 2.19, Apache::ASP scripts may be run as standalone
  5175. CGI scripts without mod_perl being loaded into Apache.  Work
  5176. to date has only been done with mod_cgi scripts under Apache on a
  5177. Unix platform, and it is unlikely to work under other web servers 
  5178. or Win32 operating systems without further development.
  5179.  
  5180. To run the ./site/eg scripts as CGI scripts, you copy the 
  5181. ./site directory to some location accessible by your web
  5182. server, in this example its /usr/local/apache/htdocs/aspcgi, 
  5183. then in your httpd.conf activate Apache::ASP cgi
  5184. scripts like so:
  5185.  
  5186.  Alias /aspcgi/ /usr/local/apache/htdocs/aspcgi/
  5187.  <Directory /usr/local/apache/htdocs/aspcgi/eg/ >
  5188.    AddType application/x-httpd-cgi .htm
  5189.    AddType application/x-httpd-cgi .html
  5190.    AddType application/x-httpd-cgi .asp
  5191.    AddType application/x-httpd-cgi .xml
  5192.    AddType application/x-httpd-cgi .ssi
  5193.    AllowOverride None
  5194.    Options +ExecCGI +Indexes
  5195.  </Directory>
  5196.  
  5197. Then install the asp-perl script from the distribution 
  5198. into /usr/bin, or some other directory.  This is 
  5199. so the CGI execution line at the top of those scripts
  5200. will invoke the asp-perl wrapper like so:
  5201.  
  5202.  #!/usr/bin/perl /usr/bin/asp-perl
  5203.  
  5204. The asp-perl script is a cgi wrapper that sets up the 
  5205. Apache::ASP environment in lieu of the normal mod_perl
  5206. handler request.  Because there is no Apache->dir_config()
  5207. data available under mod_cgi, the asp-perl script will load
  5208. a asp.conf file that may define a hash %Config of
  5209. data for populating the dir_config() data.  An example
  5210. of a complex asp.conf file is at ./site/eg/asp.conf
  5211.  
  5212. So, a trivial asp.conf file might look like:
  5213.  
  5214.  # asp.conf
  5215.  %Config = (
  5216.    'Global' => '.',
  5217.    'StateDir' => '/tmp/aspstate',
  5218.    'NoState' => 0,
  5219.    'Debug' => 3,
  5220.  );
  5221.  
  5222. The default for NoState is 1 in CGI mode, so one must
  5223. set NoState to 0 for objects like $Session & $Application
  5224. to be defined.
  5225.  
  5226. =item CGI.pm
  5227.  
  5228. CGI.pm is a very useful module that aids developers in 
  5229. the building of these applications, and Apache::ASP has been made to 
  5230. be compatible with function calls in CGI.pm.  Please see cgi.htm in the 
  5231. ./site/eg directory for a sample ASP script written almost entirely in CGI.
  5232.  
  5233. As of version 0.09, use of CGI.pm for both input and output is seamless
  5234. when working under Apache::ASP.  Thus if you would like to port existing
  5235. cgi scripts over to Apache::ASP, all you need to do is wrap <% %> around
  5236. the script to get going.  This functionality has been implemented so that
  5237. developers may have the best of both worlds when building their 
  5238. web applications.
  5239.  
  5240. =item Query Object Initialization
  5241.  
  5242. You may create a CGI.pm $query object like so:
  5243.  
  5244.     use CGI;
  5245.     my $query = new CGI;
  5246.  
  5247. As of Apache::ASP version 0.09, form input may be read in 
  5248. by CGI.pm upon initialization.  Before, Apache::ASP would 
  5249. consume the form input when reading into $Request->Form(), 
  5250. but now form input is cached, and may be used by CGI.pm input
  5251. routines.
  5252.  
  5253. =item CGI headers
  5254.  
  5255. Not only can you use the CGI.pm $query->header() method
  5256. to put out headers, but with the CgiHeaders config option
  5257. set to true, you can also print "Header: value\n", and add 
  5258. similar lines to the top of your script, like:
  5259.  
  5260.  Some-Header: Value
  5261.  Some-Other: OtherValue
  5262.  
  5263.  <html><body> Script body starts here.
  5264.  
  5265. Once there are no longer any cgi style headers, or the 
  5266. there is a newline, the body of the script begins. So
  5267. if you just had an asp script like:
  5268.  
  5269.     print join(":", %{$Request->QueryString});
  5270.  
  5271. You would likely end up with no output, as that line is
  5272. interpreted as a header because of the semicolon.  When doing
  5273. basic debugging, as long as you start the page with <html>
  5274. you will avoid this problem.
  5275.  
  5276. =item print()ing CGI
  5277.  
  5278. CGI is notorious for its print() statements, and the functions in CGI.pm 
  5279. usually return strings to print().  You can do this under Apache::ASP,
  5280. since print just aliases to $Response->Write().  Note that $| has no
  5281. affect.
  5282.  
  5283.     print $query->header();
  5284.     print $query->start_form();
  5285.  
  5286. =item File Upload
  5287.  
  5288. CGI.pm is used for implementing reading the input from file upload.  You
  5289. may create the file upload form however you wish, and then the 
  5290. data may be recovered from the file upload by using $Request->Form().
  5291. Data from a file upload gets written to a file handle, that may in
  5292. turn be read from.  The original file name that was uploaded is the 
  5293. name of the file handle.
  5294.  
  5295.     my $filehandle = $Request->Form('file_upload_field_name');
  5296.     print $filehandle; # will get you the file name
  5297.     my $data;
  5298.     while(read($filehandle, $data, 1024)) {
  5299.         # data from the uploaded file read into $data
  5300.     };
  5301.  
  5302. Please see the docs on CGI.pm (try perldoc CGI) for more information
  5303. on this topic, and ./site/eg/file_upload.asp for an example of its use.
  5304.  
  5305. There is a $Request->FileUpload() API extension that you can use to get 
  5306. more data about a file upload, so that the following properties are
  5307. available for querying:
  5308.  
  5309.   my $file_upload = $Request->{FileUpload}{upload_field};
  5310.   $file_upload->{BrowserFile}
  5311.   $file_upload->{FileHandle}
  5312.   $file_upload->{ContentType}
  5313.  
  5314.   # only if FileUploadTemp is set
  5315.   $file_upload->{TempFile}    
  5316.  
  5317.   # whatever mime headers are sent with the file upload
  5318.   # just "keys %$file_upload" to find out
  5319.   $file_upload->{?Mime-Header?}
  5320.  
  5321. Please see the $Request section in OBJECTS for more information.
  5322.  
  5323. =back
  5324.  
  5325. =head1 PERLSCRIPT
  5326.  
  5327. Much work has been done to bring compatibility with ASP applications
  5328. written in PerlScript under IIS.  Most of that work revolved around
  5329. bringing a Win32::OLE Collection interface to many of the objects
  5330. in Apache::ASP, which are natively written as perl hashes.
  5331.  
  5332. New as of version 2.05 is new functionality enabled with the 
  5333. CollectionItem setting, to giver better support to more recent PerlScript syntax.
  5334. This seems helpful when porting from an IIS/PerlScript code base.
  5335. Please see the CONFIG section for more info.
  5336.  
  5337. The following objects in Apache::ASP respond as Collections:
  5338.  
  5339.         $Application
  5340.     $Session
  5341.     $Request->FileUpload *
  5342.     $Request->FileUpload('upload_file') *
  5343.     $Request->Form
  5344.     $Request->QueryString
  5345.     $Request->Cookies
  5346.     $Response->Cookies
  5347.     $Response->Cookies('some_cookie')    
  5348.  
  5349.   * FileUpload API Extensions
  5350.  
  5351. And as such may be used with the following syntax, as compared
  5352. with the Apache::ASP native calls.  Please note the native Apache::ASP
  5353. interface is compatible with the deprecated PerlScript interface.
  5354.  
  5355.  C = PerlScript Compatibility    N = Native Apache::ASP 
  5356.   
  5357.  ## Collection->Contents($name) 
  5358.  [C] $Application->Contents('XYZ')        
  5359.  [N] $Application->{XYZ}
  5360.  
  5361.  ## Collection->SetProperty($property, $name, $value)
  5362.  [C] $Application->Contents->SetProperty('Item', 'XYZ', "Fred");
  5363.  [N] $Application->{XYZ} = "Fred"
  5364.     
  5365.  ## Collection->GetProperty($property, $name)
  5366.  [C] $Application->Contents->GetProperty('Item', 'XYZ')        
  5367.  [N] $Application->{XYZ}
  5368.  
  5369.  ## Collection->Item($name)
  5370.  [C] print $Request->QueryString->Item('message'), "<br>\n\n";
  5371.  [N] print $Request->{QueryString}{'message'}, "<br>\n\n";        
  5372.  
  5373.  ## Working with Cookies
  5374.  [C] $Response->SetProperty('Cookies', 'Testing', 'Extra');
  5375.  [C] $Response->SetProperty('Cookies', 'Testing', {'Path' => '/'});
  5376.  [C] print $Request->Cookies(Testing) . "<br>\n";
  5377.  [N] $Response->{Cookies}{Testing} = {Value => Extra, Path => '/'};
  5378.  [N] print $Request->{Cookies}{Testing} . "<br>\n";
  5379.  
  5380. Several incompatibilities exist between PerlScript and Apache::ASP:
  5381.  
  5382.  > Collection->{Count} property has not been implemented.
  5383.  > VBScript dates may not be used for Expires property of cookies.
  5384.  > Win32::OLE::in may not be used.  Use keys() to iterate over.
  5385.  > The ->{Item} property does not work, use the ->Item() method.
  5386.  
  5387. =head1 STYLE GUIDE
  5388.  
  5389. Here are some general style guidelines.  Treat these as tips for
  5390. best practices on Apache::ASP development if you will.
  5391.  
  5392. =head2 UseStrict
  5393.  
  5394. One of perl's blessings is also its bane, variables do not need to be
  5395. declared, and are by default globally scoped.  The problem with this in 
  5396. mod_perl is that global variables persist from one request to another
  5397. even if a different web browser is viewing a page.  
  5398.  
  5399. To avoid this problem, perl programmers have often been advised to
  5400. add to the top of their perl scripts:
  5401.  
  5402.   use strict;
  5403.  
  5404. In Apache::ASP, you can do this better by setting:
  5405.  
  5406.   PerlSetVar UseStrict 1
  5407.  
  5408. which will cover both script & global.asa compilation and will catch 
  5409. "use strict" errors correctly.  For perl modules, please continue to
  5410. add "use strict" to the top of them.
  5411.  
  5412. Because its so essential in catching hard to find errors, this 
  5413. configuration will likely become the default in some future release.
  5414. For now, keep setting it.
  5415.  
  5416. =head2 Do not define subroutines in scripts.
  5417.  
  5418. DO NOT add subroutine declarations in scripts.  Apache::ASP is optimized
  5419. by compiling a script into a subroutine for faster future invocation.
  5420. Adding a subroutine definition to a script then looks like this to 
  5421. the compiler:
  5422.  
  5423.   sub page_script_sub {
  5424.     ...
  5425.     ... some HTML ...
  5426.     ...
  5427.     sub your_sub {
  5428.       ...
  5429.     }
  5430.     ...
  5431.   }
  5432.  
  5433. The biggest problem with subroutines defined in subroutines is the 
  5434. side effect of creating closures, which will not behave as usually
  5435. desired in a mod_perl environment.  To understand more about closures,
  5436. please read up on them & "Nested Subroutines" at:
  5437.  
  5438.   http://perl.apache.org/docs/general/perl_reference/perl_reference.html
  5439.  
  5440. Instead of defining subroutines in scripts, you may add them to your sites
  5441. global.asa, or you may create a perl package or module to share
  5442. with your scripts.  For more on perl objects & modules, please see:
  5443.  
  5444.   http://www.perldoc.com/perl5.8.0/pod/perlobj.html
  5445.  
  5446. =head2 Use global.asa's Script_On* Events
  5447.  
  5448. Chances are that you will find yourself doing the same thing repeatedly
  5449. in each of your web application's scripts.  You can use Script_OnStart
  5450. and Script_OnEnd to automate these routine tasks.  These events are
  5451. called before and after each script request.
  5452.  
  5453. For example, let's say you have a header & footer you would like to 
  5454. include in the output of every page, then you might:
  5455.  
  5456.  # global.asa
  5457.  sub Script_OnStart {
  5458.    $Response->Include('header.inc');
  5459.  }
  5460.  sub Script_OnEnd {
  5461.    $Response->Include('footer.inc');
  5462.  }
  5463.  
  5464. Or let's say you want to initialize a global database connection
  5465. for use in your scripts:
  5466.  
  5467.  # global.asa
  5468.  use Apache::DBI;   # automatic persistent database connections
  5469.  use DBI;
  5470.  
  5471.  use vars qw($dbh); # declare global $dbh
  5472.  
  5473.  sub Script_OnStart {
  5474.    # initialize $dbh
  5475.    $dbh = DBI->connect(...);
  5476.  
  5477.    # force you to explicitly commit when you want to save data
  5478.    $Server->RegisterCleanup(sub { $dbh->rollback; });
  5479.  }
  5480.  
  5481.  sub Script_OnEnd {
  5482.    # not really necessary when using persistent connections, but
  5483.    # will free this one object reference at least
  5484.    $dbh = undef;
  5485.  }
  5486.  
  5487. =head1 FAQ
  5488.  
  5489. The following are some frequently asked questions
  5490. about Apache::ASP.
  5491.  
  5492. =head2 Installation
  5493.  
  5494. =item Examples don't work, I see the ASP script in the browser?
  5495.  
  5496. This is most likely that Apache is not configured to execute
  5497. the Apache::ASP scripts properly.  Check the INSTALL QuickStart
  5498. section for more info on how to quickly set up Apache to 
  5499. execute your ASP scripts.
  5500.  
  5501. =item Apache Expat vs. XML perl parsing causing segfaults, what do I do?
  5502.  
  5503. Make sure to compile apache with expat disabled.  The
  5504. ./make_httpd/build_httpds.sh in the distribution will do 
  5505. this for you, with the --disable-rule=EXPAT in particular:
  5506.  
  5507.  cd ../$APACHE
  5508.  echo "Building apache =============================="
  5509.  ./configure \
  5510.     --prefix=/usr/local/apache \
  5511.     --activate-module=src/modules/perl/libperl.a \
  5512.     --enable-module=ssl \
  5513.     --enable-module=proxy \
  5514.     --enable-module=so \
  5515.     --disable-rule=EXPAT
  5516.  
  5517.                    ^^^^^
  5518.  
  5519. keywords: segmentation fault, segfault seg fault
  5520.  
  5521. =item Why do variables retain their values between requests?
  5522.  
  5523. Unless scoped by my() or local(), perl variables in mod_perl
  5524. are treated as globals, and values set may persist from one 
  5525. request to another. This can be seen in as simple a script
  5526. as this:
  5527.  
  5528.   <HTML><BODY>
  5529.     $counter++;
  5530.     $Response->Write("<BR>Counter: $counter");
  5531.   </BODY></HTML>
  5532.  
  5533. The value for $counter++ will remain between requests.
  5534. Generally use of globals in this way is a BAD IDEA,
  5535. and you can spare yourself many headaches if do 
  5536. "use strict" perl programming which forces you to 
  5537. explicity declare globals like:
  5538.  
  5539.   use vars qw($counter);
  5540.  
  5541. You can make all your Apache::ASP scripts strict by
  5542. default by setting:
  5543.  
  5544.   PerlSetVar UseStrict 1
  5545.  
  5546. =item Apache errors on the PerlHandler or PerlModule directives ?
  5547.  
  5548. You get an error message like this:
  5549.  
  5550.  Invalid command 'PerlModule', perhaps mis-spelled or defined by a 
  5551.  module not included in the server configuration.
  5552.  
  5553. You do not have mod_perl correctly installed for Apache.  The PerlHandler
  5554. and PerlModule directives in Apache *.conf files are extensions enabled by mod_perl
  5555. and will not work if mod_perl is not correctly installed.
  5556.  
  5557. Common user errors are not doing a 'make install' for mod_perl, which 
  5558. installs the perl side of mod_perl, and not starting the right httpd
  5559. after building it.  The latter often occurs when you have an old apache
  5560. server without mod_perl, and you have built a new one without copying
  5561. over to its proper location.
  5562.  
  5563. To get mod_perl, go to http://perl.apache.org
  5564.  
  5565. =item Error: no request object (Apache=SCALAR(0x???????):)
  5566.  
  5567. Your Apache + mod_perl build is not working properly, 
  5568. and is likely a RedHat Linux RPM DSO build.  Make sure
  5569. you statically build your Apache + mod_perl httpd,
  5570. recompiled fresh from the sources.
  5571.  
  5572. =item I am getting a tie or MLDBM / state error message, what do I do?
  5573.  
  5574. Make sure the web server or you have write access to the eg directory,
  5575. or to the directory specified as Global in the config you are using.
  5576. Default for Global is the directory the script is in (e.g. '.'), but should
  5577. be set to some directory not under the www server document root,
  5578. for security reasons, on a production site.
  5579.  
  5580. Usually a 
  5581.  
  5582.  chmod -R -0777 eg
  5583.  
  5584. will take care of the write access issue for initial testing purposes.
  5585.  
  5586. Failing write access being the problem, try upgrading your version
  5587. of Data::Dumper and MLDBM, which are the modules used to write the 
  5588. state files.
  5589.  
  5590. =head2 Sessions
  5591.  
  5592. =item How can I use $Session to store complex data structures.
  5593.  
  5594. Very carefully.  Please read the $Session documentation in 
  5595. the OBJECTS section.  You can store very complex objects
  5596. in $Session, but you have to understand the limits, and 
  5597. the syntax that must be used to make this happen.
  5598.  
  5599. In particular, stay away from statements that that have 
  5600. more than one level of indirection on the left side of
  5601. an assignment like:
  5602.  
  5603.   $Session->{complex}{object} = $data;
  5604.  
  5605. =item How can I keep search engine spiders from killing the session manager?
  5606.  
  5607. If you want to disallow session creation for certain non web 
  5608. browser user agents, like search engine spiders, you can use a mod_perl
  5609. PerlInitHandler like this to set configuration variables at runtime:
  5610.  
  5611.  # put the following code into httpd.conf and stop/start apache server
  5612.  PerlInitHandler My::InitHandler
  5613.  
  5614.  <Perl>
  5615.  
  5616.   package My::InitHandler;
  5617.   use Apache;
  5618.  
  5619.   sub handler {
  5620.     my $r = shift; # get the Apache request object
  5621.  
  5622.     # if not a Mozilla User Agent, then disable sessions explicitly
  5623.     unless($r->headers_in('User-Agent') =~ /^Mozilla/) {
  5624.        $r->dir_config('AllowSessionState', 'Off');
  5625.     }
  5626.  
  5627.     return 200; # return OK mod_perl status code
  5628.   }
  5629.  
  5630.   1;
  5631.  
  5632.  </Perl>
  5633.  
  5634. This will configure your environment before Apache::ASP executes
  5635. and sees the configuration settings.  You can use the mod_perl
  5636. API in this way to configure Apache::ASP at runtime.
  5637.  
  5638. Note that the Session Manager is very robust on its own, and denial
  5639. of service attacks of the types that spiders and other web bots 
  5640. normally execute are not likely to affect the Session Manager significantly.
  5641.  
  5642. =item How can I use $Session to store a $dbh database handle ?
  5643.  
  5644. You cannot use $Session to store a $dbh handle.  This can 
  5645. be awkward for those coming from the IIS/NT world, where
  5646. you could store just about anything in $Session, but this
  5647. boils down to a difference between threads vs. processes.
  5648.  
  5649. Database handles often have per process file handles open,
  5650. which cannot be shared between requests, so though you 
  5651. have stored the $dbh data in $Session, all the other 
  5652. initializations are not relevant in another httpd process.
  5653.  
  5654. All is not lost! Apache::DBI can be used to cache 
  5655. database connections on a per process basis, and will
  5656. work for most cases.
  5657.  
  5658. =head2 Development
  5659.  
  5660. =item VBScript or JScript supported?
  5661.  
  5662. Yes, but not with this Perl module.  For ASP with other scripting
  5663. languages besides Perl, you will need to go with a commercial vendor
  5664. in the UNIX world.  Sun and Stryon have such solutions.
  5665. Of course on Windows NT and Windows 2000, you get VBScript for free with IIS.
  5666.  
  5667.   Sun ONE Active Server Pages (formerly Sun Chili!Soft ASP)
  5668.   http://www.chilisoft.com
  5669.  
  5670.   Instant ASP from Stryon (formerly Halcyon Software)
  5671.   http://www.stryon.com
  5672.  
  5673. =item How is database connectivity handled?
  5674.  
  5675. Database connectivity is handled through perl's DBI & DBD interfaces.
  5676. In the UNIX world, it seems most databases have cross platform support in perl.
  5677. You can find the book on DBI programming at http://www.oreilly.com/catalog/perldbi/
  5678.  
  5679. DBD::ODBC is often your ticket on Win32.  On UNIX, commercial vendors
  5680. like OpenLink Software (http://www.openlinksw.com/) provide the nuts and 
  5681. bolts for ODBC.
  5682.  
  5683. Database connections can be cached per process with Apache::DBI.
  5684.  
  5685. =item What is the best way to debug an ASP application ?
  5686.  
  5687. There are lots of perl-ish tricks to make your life developing
  5688. and debugging an ASP application easier.  For starters,
  5689. you will find some helpful hints by reading the 
  5690. $Response->Debug() API extension, and the Debug
  5691. configuration directive.
  5692.  
  5693. =item How are file uploads handled?
  5694.  
  5695. Please see the CGI section.  File uploads are implemented
  5696. through CGI.pm which is loaded at runtime only for this purpose.
  5697. This is the only time that CGI.pm will be loaded by Apache::ASP,
  5698. which implements all other cgi-ish functionality natively.  The
  5699. rationale for not implementing file uploads natively is that 
  5700. the extra 100K in memory for CGI.pm shouldn't be a big deal if you 
  5701. are working with bulky file uploads.
  5702.  
  5703. =item How do I access the ASP Objects in general?
  5704.  
  5705. All the ASP objects can be referenced through the main package with
  5706. the following notation:
  5707.  
  5708.  $main::Response->Write("html output");
  5709.  
  5710. This notation can be used from anywhere in perl, including routines
  5711. registered with $Server->RegisterCleanup().  
  5712.  
  5713. You use the normal notation in your scripts, includes, and global.asa:
  5714.  
  5715.  $Response->Write("html output");
  5716.  
  5717. =item Can I print() in ASP?
  5718.  
  5719. Yes.  You can print() from anywhere in an ASP script as it aliases
  5720. to the $Response->Write() method.  Using print() is portable with
  5721. PerlScript when using Win32::ASP in that environment.
  5722.  
  5723. =item Do I have access to ActiveX objects?
  5724.  
  5725. Only under Win32 will developers have access to ActiveX objects through
  5726. the perl Win32::OLE interface.  This will remain true until there
  5727. are free COM ports to the UNIX world.  At this time, there is no ActiveX
  5728. for the UNIX world.
  5729.  
  5730. =head2 Support and Production
  5731.  
  5732. =item How do I get things I want done?!
  5733.  
  5734. If you find a problem with the module, or would like a feature added,
  5735. please mail support, as listed in the SUPPORT section, and your 
  5736. needs will be promptly and seriously considered, then implemented.
  5737.  
  5738. =item What is the state of Apache::ASP?  Can I publish a web site on it?
  5739.  
  5740. Apache::ASP has been production ready since v.02.  Work being done
  5741. on the module is on a per need basis, with the goal being to eventually
  5742. have the ASP API completed, with full portability to ActiveState PerlScript
  5743. and MKS PScript.  If you can suggest any changes to facilitate these
  5744. goals, your comments are welcome.
  5745.  
  5746. =head1 TUNING
  5747.  
  5748. A little tuning can go a long way, and can make the difference between
  5749. a web site that gets by, and a site that screams with speed.  With
  5750. Apache::ASP, you can easily take a poorly tuned site running at
  5751. 10 hits/second to 50+ hits/second just with the right configuration.
  5752.  
  5753. Documented below are some simple things you can do to make the 
  5754. most of your site.
  5755.  
  5756. =head2 Online Resources
  5757.  
  5758. For more tips & tricks on tuning Apache and mod_perl, please see the tuning
  5759. documents at:
  5760.  
  5761.   Stas Bekman's mod_perl guide
  5762.   http://perl.apache.org/guide/
  5763.  
  5764. Written in late 1999 this article provides an early look at 
  5765. how to tune your Apache::ASP web site.  It has since been
  5766. updated to remain current with Apache::ASP v2.29+
  5767.  
  5768.   Apache::ASP Site Tuning
  5769.   http://www.chamas.com/asp/articles/perlmonth3_tune.html
  5770.  
  5771. =head2 Tuning & Benchmarking
  5772.  
  5773. When performance tuning, it is important to have a tool to
  5774. measure the impact of your tuning change by change.
  5775. The program ab, or Apache Bench, provides this functionality
  5776. well, and is freely included in the apache distribution.
  5777.  
  5778. Because performance tuning can be a neverending affair,
  5779. it is a good idea to establish a threshold where performance
  5780. is "good enough", that once reached, tuning stops.
  5781.  
  5782. =head2 $Application & $Session State
  5783.  
  5784. Use NoState 1 setting if you don't need the $Application or $Session
  5785. objects. State objects such as these tie to files on disk and will incur a
  5786. performance penalty.
  5787.  
  5788. If you need the state objects $Application and $Session, and if 
  5789. running an OS that caches files in memory, set your "StateDir" 
  5790. directory to a cached file system.  On WinNT, all files 
  5791. may be cached, and you have no control of this.  On Solaris, /tmp is
  5792. a RAM disk and would be a good place to set the "StateDir" config 
  5793. setting to.  When cached file systems are used there is little 
  5794. performance penalty for using state files.  Linux tends to do a good job 
  5795. caching its file systems, so pick a StateDir for ease of system 
  5796. administration.
  5797.  
  5798. On Win32 systems, where mod_perl requests are serialized, you 
  5799. can freely use SessionSerialize to make your $Session requests
  5800. faster, and you can achieve similar performance benefits for
  5801. $Application if you call $Application->Lock() in your 
  5802. global.asa's Script_OnStart.
  5803.  
  5804. =head2 Low MaxClients
  5805.  
  5806. Set your MaxClients low, such that if you have that
  5807. many httpd servers running, which will happen on busy site,
  5808. your system will not start swapping to disk because of 
  5809. excessive RAM usage.  Typical settings are less than 100
  5810. even with 1 gig RAM!  To handle more client connections,
  5811. look into a dual server, mod_proxy front end.
  5812.  
  5813. =head2 High MaxRequestsPerChild
  5814.  
  5815. Set your max requests per child thread or process (in httpd.conf) high, 
  5816. so that ASP scripts have a better chance being cached, which happens after 
  5817. they are first compiled.  You will also avoid the process fork penalty on 
  5818. UNIX systems.  Somewhere between 50 - 500 is probably pretty good.
  5819. You do not want to set this too high though or you will risk having
  5820. your web processes use too much RAM.  One may use Apache::SizeLimit
  5821. or Apache::GTopLimit to optimally tune MaxRequestsPerChild at runtime.
  5822.  
  5823. =head2 Precompile Modules
  5824.  
  5825. For those modules that your Apache::ASP application uses,
  5826. make sure that they are loaded in your sites startup.pl
  5827. file, or loaded with PerlModule in your httpd.conf, so 
  5828. that your modules are compiled pre-fork in the parent httpd.
  5829.  
  5830. =head2 Precompile Scripts
  5831.  
  5832. Precompile your scripts by using the Apache::ASP->Loader() routine
  5833. documented below.  This will at least save the first user hitting 
  5834. a script from suffering compile time lag.  On UNIX, precompiling scripts
  5835. upon server startup allows this code to be shared with forked child
  5836. www servers, so you reduce overall memory usage, and use less CPU 
  5837. compiling scripts for each separate www server process.  These 
  5838. savings could be significant.  On a PII300 Solaris x86, it takes a couple seconds
  5839. to compile 28 scripts upon server startup, with an average of 50K RAM
  5840. per compiled script, and this savings is passed on to the ALL child httpd 
  5841. servers, so total savings would be 50Kx28x20(MaxClients)=28M!
  5842.  
  5843. Apache::ASP->Loader() can be called to precompile scripts and
  5844. even entire ASP applications at server startup.  Note 
  5845. also that in modperl, you can precompile modules with the 
  5846. PerlModule config directive, which is highly recommended.
  5847.  
  5848.  Apache::ASP->Loader($path, $pattern, %config)
  5849.  
  5850. This routine takes a file or directory as its first argument.  If
  5851. a file, that file will be compiled.  If a directory, that directory
  5852. will be recursed, and all files in it whose file name matches $pattern
  5853. will be compiled.  $pattern defaults to .*, which says that all scripts
  5854. in a directory will be compiled by default.  
  5855.  
  5856. The %config args, are the config options that you want set that affect 
  5857. compilation.  These options include Debug, Global, GlobalPackage, 
  5858. DynamicIncludes, StatINC, StatINCMatch, XMLSubsMatch, and XMLSubsStrict.  
  5859. If your scripts are later run with different config options, your 
  5860. scripts may have to be recompiled.
  5861.  
  5862. Here is an example of use in a *.conf file:
  5863.  
  5864.  <Perl> 
  5865.  Apache::ASP->Loader(
  5866.     '/usr/local/proj/site', "(asp|htm)\$", 
  5867.     'Global' => '/proj/perllib',
  5868.     'Debug' => -3, # see system output when starting apache
  5869.  
  5870.     # OPTIONAL configs if you use them in your apache configuration
  5871.     # these settings affect how the scripts are compiled and loaded
  5872.     'GlobalPackage' => 'SomePackageName',
  5873.     'DynamicIncludes' => 1,    
  5874.     'StatINC' => 1,        
  5875.         'StatINCMatch' => 'My',
  5876.         'UseStrict' => 1,
  5877.         'XMLSubsMatch' => 'my:\w+',
  5878.         'XMLSubsStrict' => 0 || 1,
  5879.     );
  5880.  </Perl>
  5881.  
  5882. This config section tells the server to compile all scripts
  5883. in c:/proj/site that end in asp or htm, and print debugging
  5884. output so you can see it work.  It also sets the Global directory
  5885. to be /proj/perllib, which needs to be the same as your real config
  5886. since scripts are cached uniquely by their Global directory.  You will 
  5887. probably want to use this on a production server, unless you cannot 
  5888. afford the extra startup time.
  5889.  
  5890. To see precompiling in action, set Debug to 1 for the Loader() and
  5891. for your application in general and watch your error_log for 
  5892. messages indicating scripts being cached.
  5893.  
  5894. =head2 No .htaccess or StatINC
  5895.  
  5896. Don't use .htaccess files or the StatINC setting in a production system
  5897. as there are many more files touched per request using these features.  I've
  5898. seen performance slow down by half because of using these.  For eliminating
  5899. the .htaccess file, move settings into *.conf Apache files.
  5900.  
  5901. Instead of StatINC, try using the StatINCMatch config, which 
  5902. will check a small subset of perl libraries for changes.  This
  5903. config is fine for a production environment, and if used well
  5904. might only incur a 10-20% performance penalty, depending on the
  5905. number of modules your system loads in all, as each module
  5906. needs to be checked for changes on a per request basis.
  5907.  
  5908. =head2 Turn off Debugging
  5909.  
  5910. Turn off system debugging by setting Debug to 0-3.  Having the system 
  5911. debug config option on slows things down immensely, but can be useful
  5912. when troubleshooting your application.  System level debugging is 
  5913. settings -3 through -1, where user level debugging is 1 to 3.  User level
  5914. debugging is much more light weight depending on how many $Reponse->Debug()
  5915. statements you use in your program, and you may want to leave it on.
  5916.  
  5917. =head2 Memory Sparing, NoCache
  5918.  
  5919. If you have a lot (1000's+) of scripts, and limited memory, set NoCache to 1,
  5920. so that compiled scripts are not cached in memory.  You lose about
  5921. 10-15% in speed for small scripts, but save at least 10K RAM per cached
  5922. script.  These numbers are very rough and will largely depend on the size
  5923. of your scripts and includes.
  5924.  
  5925. =head2 Resource Limits
  5926.  
  5927. Make sure your web processes do not use too many resources
  5928. like CPU or RAM with the handy Apache::Resource module.
  5929. Such a config might look like:
  5930.  
  5931.  PerlModule Apache::Resource
  5932.  PerlSetEnv PERL_RLIMIT_CPU  1000
  5933.  PerlSetEnv PERL_RLIMIT_DATA 60:60
  5934.  
  5935. If ever a web process should begin to take more than 60M ram
  5936. or use more than 1000 CPU seconds, it will be killed by 
  5937. the OS this way.  You only want to use this configuration
  5938. to protect against runaway processes and web program errors,
  5939. not for terminating a normally functioning system, so set
  5940. these limits HIGH!
  5941.  
  5942. =head1 SEE ALSO
  5943.  
  5944. perl(1), mod_perl(3), Apache(3), MLDBM(3), HTTP::Date(3), CGI(3),
  5945. Win32::OLE(3)
  5946.  
  5947. =head1 NOTES
  5948.  
  5949. Many thanks to those who helped me make this module a reality.
  5950. With Apache + ASP + Perl, web development could not be better!
  5951.  
  5952. Special thanks go to Kevin Chamas & Karolina Lund for their 
  5953. love and support through it all, and without whom none of it
  5954. would have been possible.
  5955.  
  5956. Other honorable mentions include:
  5957.  
  5958.  !! Doug MacEachern, for moral support and of course mod_perl
  5959.  :) Francesco Pasqualini, for bug fixes with stand alone CGI mode on Win32
  5960.  :) Szymon Juraszczyk, for better ContentType handling for settings like Clean.
  5961.  :) Oleg Kobyakovskiy, for identifying the double Session_OnEnd cleanup bug.
  5962.  :) Peter Galbavy, for reporting numerous bugs and maintaining the OpenBSD port.
  5963.  :) Richard Curtis, for reporting and working through interesting module 
  5964.     loading issues under mod_perl2 & apache2, and pushing on the file upload API.
  5965.  :) Rune Henssel, for catching a major bug shortly after 2.47 release,
  5966.     and going to great lengths to get me reproducing the bug quickly.
  5967.  :) Broc, for keeping things filter aware, which broke in 2.45,
  5968.     & much help on the list.
  5969.  :) Manabu Higashida, for fixes to work under perl 5.8.0
  5970.  :) Slaven Rezic, for suggestions on smoother CPAN installation
  5971.  :) Mitsunobu Ozato, for working on a japanese translation of the site & docs.
  5972.  :) Eamon Daly for persistence in resolving a MailErrors bug.
  5973.  :) Gert, for help on the mailing list, and pushing the limits of use on Win32 
  5974.     in addition to XSLT.
  5975.  :) Maurice Aubrey, for one of the early fixes to the long file name problem.
  5976.  :) Tom Lancaster, for pushing the $Server->Mail API and general API discussion.
  5977.  :) Ross Thomas, for pushing into areas so far unexplored.
  5978.  :) Harald Kreuzer, for bug discovery & subsequent testing in the 2.25 era.
  5979.  :) Michael Buschauer for his extreme work with XSLT.
  5980.  :) Dariusz Pietrzak for a nice parser optimization.
  5981.  :) Ime Smits, for his inode patch facilitating cross site code reuse, and
  5982.     some nice performance enhancements adding another 1-2% speed.
  5983.  :) Michael Davis, for easier CPAN installation.
  5984.  :) Brian Wheeler, for keeping up with the Apache::Filter times,
  5985.     and pulling off filtering ASP->AxKit.
  5986.  :) Ged Haywood, for his great help on the list & professionally.
  5987.  :) Vee McMillen, for OSS patience & understanding.
  5988.  :) Craig Samuel, at LRN, for his faith in open source for his LCEC.
  5989.  :) Geert Josten, for his wonderful work on XML::XSLT
  5990.  :) Gerald Richter, for his Embperl, collaboration and competition!
  5991.  :) Stas Bekman, for his beloved guide, and keeping us all worldly.
  5992.  :) Matt Sergeant, again, for ever the excellent XML critique.
  5993.  :) Remi Fasol + Serge Sozonoff who inspired cookieless sessions.
  5994.  :) Matt Arnold, for the excellent graphics !
  5995.  :) Adi, who thought to have full admin control over sessions
  5996.  :) Dmitry Beransky, for sharable web application includes, ASP on the big.
  5997.  :) Russell Weiss again, for finding the internal session garbage collection 
  5998.     behaving badly with DB_File sensitive i/o flushing requirements.
  5999.  :) Tony Merc Mobily, inspiring tweaks to compile scripts 10 times faster
  6000.  :) Paul Linder, who is Mr. Clean... not just the code, its faster too !
  6001.     Boy was that just the beginning.  Work with him later facilitated better
  6002.     session management and XMLSubsMatch custom tag technology.
  6003.  :) Russell Weiss, for being every so "strict" about his code.
  6004.  :) Bill McKinnon, who understands the finer points of running a web site.
  6005.  :) Richard Rossi, for his need for speed & boldly testing dynamic includes.
  6006.  :) Greg Stark, for endless enthusiasm, pushing the module to its limits.
  6007.  :) Marc Spencer, who brainstormed dynamic includes.
  6008.  :) Doug Silver, for finding most of the bugs.
  6009.  :) Darren Gibbons, the biggest cookie-monster I have ever known.
  6010.  :) Ken Williams, for great teamwork bringing full SSI to the table
  6011.  :) Matt Sergeant, for his great tutorial on PerlScript and love of ASP
  6012.  :) Jeff Groves, who put a STOP to user stop button woes
  6013.  :) Alan Sparks, for knowing when size is more important than speed
  6014.  :) Lincoln Stein, for his blessed CGI.pm module
  6015.  :) Michael Rothwell, for his love of Session hacking
  6016.  :) Francesco Pasqualini, for bringing ASP to CGI
  6017.  :) Bryan Murphy, for being a PerlScript wiz
  6018.  :) Lupe Christoph, for his immaculate and stubborn testing skills
  6019.  :) Ryan Whelan, for boldly testing on Unix in the early infancy of ASP
  6020.  
  6021. =head1 SUPPORT
  6022.  
  6023. =head2 COMMUNITY
  6024.  
  6025. =item Mailing List Archives
  6026.  
  6027. Try the Apache::ASP mailing list archive first when working
  6028. through an issue as others may have had the same question
  6029. as you, then try the mod_perl list archives since often
  6030. problems working with Apache::ASP are really mod_perl ones.
  6031.  
  6032. The Apache::ASP mailing list archives are located at:
  6033.  
  6034.  http://groups.yahoo.com/group/apache-asp/
  6035.  http://www.mail-archive.com/asp%40perl.apache.org/
  6036.  
  6037. The mod_perl mailing list archives are located at:
  6038.  
  6039.  http://forum.swarthmore.edu/epigone/modperl
  6040.  http://www.geocrawler.com/lists/3/web/182/0/
  6041.  http://www.egroups.com/group/modperl/
  6042.  
  6043. =item Mailing List
  6044.  
  6045. Please subscribe to the Apache::ASP mailing list
  6046. by sending an email to asp-subscribe@perl.apache.org
  6047. and send your questions or comments to the list
  6048. after your subscription is confirmed.
  6049.  
  6050. To unsubscribe from the Apache::ASP mailing list,
  6051. just send an email to asp-unsubscribe@perl.apache.org
  6052.  
  6053. If you think this is a mod_perl specific issue, you can
  6054. send your question to modperl@apache.org
  6055.  
  6056. =item Donations
  6057.  
  6058. Apache::ASP is freely distributed under the terms of the GPL license 
  6059. ( see the LICENSE section ).  However development time is expensive, 
  6060. and is fueled in part by donations from the user community in the 
  6061. form of patches, debugging, and money.  For monetary contributions, 
  6062. please go to:
  6063.  
  6064.   http://www.chamas.com/open_source.htm
  6065.  
  6066. and contribute via the PayPal button, or you may send a check to
  6067. the address listed at:
  6068.  
  6069.   http://www.chamas.com/contact.htm
  6070.  
  6071. =head2 COMMERCIAL
  6072.  
  6073. If you would like commercial support for Apache::ASP, please
  6074. check out any of the following listed companies.  Note that 
  6075. this is not an endorsement, and if you would like your company
  6076. listed here, please email asp@chamas.com with your information.
  6077.  
  6078. =item Chamas Enterprises Inc.
  6079.  
  6080. We created Apache::ASP, and we can bring you top notch software
  6081. engineering solutions!  We are experts with open source web
  6082. and database systems.  We offer:
  6083.  
  6084.  * Installation support & configuration
  6085.  * System optimization & tuning
  6086.  * Custom development
  6087.  * Apache::ASP core extensions
  6088.  * Advanced support for mod_perl, MySQL, Apache, Perl, & UNIX 
  6089.  
  6090. For more information please see:
  6091.  
  6092.  http://www.chamas.com/consulting.htm
  6093.  http://www.chamas.com/open_source.htm
  6094.  
  6095. =item AlterCom
  6096.  
  6097. We use, host and support mod_perl. We would love to be able to help 
  6098. anyone with their mod_perl Apache::ASP needs.  Our mod_perl hosting is $24.95 mo.
  6099.  
  6100.   http://altercom.com/home.html
  6101.  
  6102. =item The Cyberchute Connection
  6103.  
  6104. Our hosting services support Apache:ASP along with Mod_Perl, PHP and MySQL.
  6105.  
  6106.   http://www.Cyberchute.com
  6107.  
  6108. =item OmniTI
  6109.  
  6110. OmniTI supports Apache and mod_perl (including Apache::ASP) and offers competitive pricing for both hourly and project-based jobs. OmniTI has extensive experience managing and maintaining both large and small projects. Our services range from short-term consulting to project-based development, and include ongoing maintenance and hosting.
  6111.  
  6112.   http://www.omniti.com
  6113.  
  6114. =item TUX IT AG
  6115.  
  6116. Main business is implementing and maintaining infrastructure for big
  6117. websites and portals, as well as developing web applications for our
  6118. customers (Apache, Apache::ASP, PHP, Perl, MySQL, etc.)
  6119.  
  6120. The prices for our service are about 900 EUR per day which is negotiable
  6121. (for longer projects, etc.).
  6122.  
  6123.   http://www.tuxit.de
  6124.  
  6125. =head1 SITES USING
  6126.  
  6127. What follows is a list of public sites that are using 
  6128. Apache::ASP.  If you use the software for your site, and 
  6129. would like to show your support of the software by being listed, 
  6130. please send your link to asp@chamas.com
  6131.  
  6132. For a list of testimonials of those using Apache::ASP, please see the TESTIMONIALS section.
  6133.  
  6134.         FreeLotto
  6135.         http://www.freelotto.com
  6136.  
  6137.         Hungarian TOP1000
  6138.         http://www.hungariantop1000.com
  6139.  
  6140.         Hungarian Registry
  6141.         http://www.hunreg.com
  6142.  
  6143.         Kepeslap.com
  6144.         http://www.kepeslap.com
  6145.  
  6146.         yourpostcardsite.com
  6147.         http://www.yourpostcardsite.com
  6148.  
  6149.         WebTime
  6150.         http://webtime-project.net
  6151.  
  6152.         Meet-O-Matic
  6153.         http://meetomatic.com/about.asp
  6154.  
  6155.         Apache Hello World Benchmarks
  6156.         http://chamas.com/bench/
  6157.  
  6158.         AlterCom, Advanced Web Hosting
  6159.         http://altercom.com/
  6160.  
  6161.         AmericanGamers.com
  6162.         http://www.AmericanGamers.com/
  6163.  
  6164.         SEAWA, Software Engineering Australia
  6165.         http://www.seawa.org.au/
  6166.  
  6167.         ESSTECwebservices
  6168.         http://www.esstec.be/
  6169.  
  6170.         SQLRef
  6171.         http://comclub.dyndns.org:8081/sqlref/
  6172.  
  6173.         Bouygues Telecom Enterprises
  6174.         http://www.b2bouygtel.com
  6175.  
  6176.         Alumni.NET
  6177.     http://www.alumni.net
  6178.  
  6179.         Anime Wallpapers dot com
  6180.         http://www.animewallpapers.com/
  6181.  
  6182.     Chamas Enterprises Inc.        
  6183.     http://www.chamas.com
  6184.  
  6185.     Cine.gr
  6186.     http://www.cine.gr
  6187.  
  6188.     Condo-Mart Web Service
  6189.     http://www.condo-mart.com 
  6190.  
  6191.         Direct.it
  6192.         http://www.direct.it/
  6193.  
  6194.         Discountclick.com
  6195.         http://www.discountclick.com/
  6196.  
  6197.     HCST
  6198.     http://www.hcst.net
  6199.  
  6200.     International Telecommunication Union
  6201.     http://www.itu.int
  6202.  
  6203.     Integra
  6204.     http://www.integra.ru/
  6205.  
  6206.     Internetowa Gielda Samochodowa        
  6207.     http://www.gielda.szczecin.pl
  6208.  
  6209.         Money FM
  6210.         http://www.moneyfm.gr
  6211.  
  6212.     Motorsport.com
  6213.     http://www.motorsport.com
  6214.  
  6215.     MLS of Greater Cincinnati
  6216.     http://www.cincymls.com
  6217.  
  6218.     NodeWorks Link Checker
  6219.     http://www.nodeworks.com
  6220.  
  6221.     OnTheWeb Services
  6222.     http://www.ontheweb.nu
  6223.  
  6224.     Prices for Antiques
  6225.     http://www.p4a.com
  6226.  
  6227.     redhat.com | support
  6228.     http://www.redhat.com/apps/support/
  6229.  
  6230.     Samara.RU
  6231.     http://portal.samara.ru/
  6232.  
  6233.     Spotlight
  6234.     http://www.spotlight.com.au
  6235.  
  6236.     USCD Electrical & Computer Engineering
  6237.     http://ece-local.ucsd.edu
  6238.  
  6239. =head1 TESTIMONIALS
  6240.  
  6241. Here are testimonials from those using Apache::ASP.
  6242. If you use this software and would like to show your 
  6243. support please send your testimonial to asp@chamas.com
  6244.  
  6245. For a list of sites using Apache::ASP, please see the SITES USING section.
  6246.  
  6247. =item Red Hat
  6248.  
  6249. =begin html
  6250.  
  6251. <a href=http://www.redhat.com><img src=redhat_logo.gif border=0></a>
  6252.  
  6253. =end html
  6254.  
  6255. We're using Apache::ASP on www.redhat.com. We find Apache::ASP very
  6256. easy to use, and it's quick for new developers to get up to speed with
  6257. it, given that many people have already been exposed to the ASP object
  6258. model that Apache::ASP is based on. 
  6259.  
  6260. The documentation is comprehensive and easy to understand, and the
  6261. community and maintainer have been very helpful whenever we've had
  6262. questions.
  6263.  
  6264.   -- Tom Lancaster, Red Hat
  6265.  
  6266. =item HOSTING 321, LLC.
  6267.  
  6268. After discontinuing Windows-based hosting due to the high cost of software, 
  6269. our clients are thrilled with Apache::ASP and they swear ASP it's faster 
  6270. than before. Installation was a snap on our 25-server web farm with a small 
  6271. shell script and everything is running perfectly! The documentation is 
  6272. very comprehensive and everyone has been very helpful during this migration.
  6273.  
  6274. Thank you!
  6275.  
  6276.  -- Richard Ward, HOSTING 321, LLC.
  6277.  
  6278. =item Concept Online Ltd.
  6279.  
  6280. =begin html
  6281.  
  6282. <a href=http://www.conceptonline.com><img src=concept_online.gif border=0></a>
  6283.  
  6284. =end html
  6285.  
  6286. I would like to say that your ASP module rocks :-) We have practically stopped developing in anything else about half a year ago, and are now using Apache::ASP extensively. I just love Perl, and whereever we are not "forced" to use JSP, we chose ASP. It is fast, reliable, versatile, documented in a way that is the best for professionals - so thank you for writting and maintaining it!
  6287.  
  6288.   -- Csongor Fagyal, Concept Online Ltd.
  6289.  
  6290. =item WebTime
  6291.  
  6292. =begin html
  6293.  
  6294. <a href="http://webtime-project.net"><img border=0 src="webtimelogo.jpg"></a>
  6295.  
  6296. =end html
  6297.  
  6298. As we have seen with WebTime, Apache::ASP is not only good  for the
  6299. development of website, but also for the development of webtools. Since
  6300. I first discoverd it, I made it a must-have in my society by taking
  6301. traditional PHP users to the world of perl afficionados.
  6302.  
  6303. Having the possibility to use Apache::ASP with mod_perl or mod_cgi make
  6304. it constraintless to use because of CGI's universality and perl's
  6305. portability.
  6306.  
  6307.   -- GrΘgoire Lejeune
  6308.  
  6309. =item David Kulp
  6310.  
  6311. First, I just want to say that I am very very impressed with Apache::ASP.  I
  6312. just want to gush with praise after looking at many other implementations of
  6313. perl embedded code and being very underwhelmed.  This is so damn slick and
  6314. clean.  Kudos! ...
  6315.  
  6316. ... I'm very pleased how quickly I've been able to mock
  6317. up the application.  I've been writing Perl CGI off and on since 1993(!)
  6318. and I can tell you that Apache::ASP is a pleasure.  (Last year I tried
  6319. Zope and just about threw my computer out the window.)
  6320.  
  6321.   -- David Kulp
  6322.  
  6323. =item MFM Commmunication Software, Inc.
  6324.  
  6325. =begin html
  6326.  
  6327. <table border=0><tr><td>
  6328. <a href="http://www.mfm.com"><img src="communication_software.gif" border=0></a>
  6329. <p>
  6330. <a href=http://www.huff.com/>HUFF Realty</a>
  6331. <br>
  6332. <a href=http://www.starone.com/>Star One Realtors</a>
  6333. <br>
  6334. <a href=http://www.comey.com/>Comey & Shepherd Realtors</a>
  6335. <br>
  6336. <a href=http://www.unlimitedrealestate.net/>RE/MAX Unlimited Realtors</a>
  6337. <br>
  6338. <a href=http://www.cincinnatibuilders.com/>Cincinnati Builders</a>
  6339. <br>
  6340. <a href=http://www.airportdays.com/>Blue Ash Airport Days Airshow</a>
  6341. </td></tr></table>
  6342.  
  6343. =end html
  6344.  
  6345. Working in a team environment where you have HTML coders and perl
  6346. coders, Apache::ASP makes it easy for the HTML folks to change the look
  6347. of the page without knowing perl. Using Apache::ASP (instead of another
  6348. embedded perl solution) allows the HTML jockeys to use a variety of HTML
  6349. tools that understand ASP, which reduces the amount of code they break
  6350. when editing the HTML.  Using Apache::ASP instead of M$ ASP allows us to
  6351. use perl (far superior to VBScript) and Apache (far superior to IIS).
  6352.  
  6353. We've been very pleased with Apache::ASP and its support.
  6354.  
  6355. =item Planet of Music
  6356.  
  6357. Apache::ASP has been a great tool.  Just a little
  6358. background.... the whole site had been in cgi flat files when I started
  6359. here.  I was looking for a technology that would allow me to write the
  6360. objects and NEVER invoke CGI.pm... I found it and hopefuly I will be able to
  6361. implement this every site I go to.
  6362.  
  6363. When I got here there was a huge argument about needing a game engine
  6364. and I belive this has been the key... Games are approx. 10 time faster than
  6365. before. The games don't break anylonger. All in all a great tool for
  6366. advancement.
  6367.  
  6368.   -- JC Fant IV
  6369.  
  6370. =item Cine.gr
  6371.  
  6372. =begin html
  6373.  
  6374. <a href="http://www.cine.gr"><img src="cine.gr.gif" border=0></a>
  6375.  
  6376. =end html
  6377.  
  6378. ...we ported our biggest yet ASP site from IIS (well, actually rewrote),
  6379. Cine.gr and it is a killer site.  In some cases, the whole thing got almost 25 (no typo) times faster...
  6380. None of this would ever be possible without Apache::ASP (I do not ever want to write ``print "<HTML>\n";''
  6381. again).
  6382.  
  6383. =head1 RESOURCES
  6384.  
  6385. Here are some important resources listed related to 
  6386. the use of Apache::ASP for publishing web applications.
  6387. If you have any more to suggest, please email the Apache::ASP list
  6388. at asp@perl.apache.org
  6389.  
  6390. =head2 Articles
  6391.  
  6392.        Apache::ASP Introduction ( #1 in 3 part series )
  6393.        http://www.apache-asp.org/articles/perlmonth1_intro.html
  6394.  
  6395.        Apache::ASP Site Building ( #2 in 3 part series )
  6396.        http://www.apache-asp.org/articles/perlmonth2_build.html
  6397.  
  6398.        Apache::ASP Site Tuning ( #3 in 3 part series )
  6399.        http://www.apache-asp.org/articles/perlmonth3_tune.html
  6400.  
  6401.        Embedded Perl ( part of a series on Perl )
  6402.        http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/index15.html
  6403.  
  6404. =head2 Benchmarking
  6405.  
  6406.        Apache Hello World Benchmarks
  6407.        http://chamas.com/bench/
  6408.  
  6409. =head2 Books
  6410.  
  6411.        mod_perl "Eagle" Book
  6412.        http://www.modperl.com
  6413.  
  6414.        mod_perl Developer's Cookbook
  6415.        http://www.modperlcookbook.org
  6416.  
  6417.        Programming the Perl DBI
  6418.        http://www.oreilly.com/catalog/perldbi/
  6419.  
  6420. =head2 Presentations
  6421.  
  6422.        Apache::ASP Tutorial, 2000 Open Source Convention ( PowerPoint )
  6423.        http://www.chamas.com/asp/OSS_convention_2000.pps
  6424.  
  6425.        Advanced Apache::ASP Tutorial, 2001 Open Source Convention ( Zipped PDF )
  6426.        http://www.chamas.com/asp/OSS_convention_2001.zip
  6427.  
  6428.        Advanced Apache::ASP Tutorial, 2001 Open Source Convention ( PDF )
  6429.        http://www.chamas.com/asp/OSS_convention_2001.pdf
  6430.  
  6431. =head2 Reference Cards
  6432.  
  6433.         Apache & mod_perl Reference Cards
  6434.         http://www.refcards.com/
  6435.  
  6436. =head2 Web Sites
  6437.  
  6438.     mod_perl Apache web module
  6439.     http://perl.apache.org
  6440.  
  6441.     mod_perl Guide
  6442.     http://perl.apache.org/guide/
  6443.  
  6444.     Perl Programming Language
  6445.     http://www.perl.com
  6446.  
  6447.     Apache Web Server
  6448.     http://www.apache.org
  6449.  
  6450. =head1 TODO
  6451.  
  6452. There is no specific time frame in which these things will be 
  6453. implemented.  Please let me know if any of these is of particular
  6454. interest to you, and I will give it higher priority.
  6455.  
  6456. =head2 WILL BE DONE 
  6457.  
  6458.  + Database storage of $Session & $Application, so web clusters 
  6459.    may scale better than the current NFS/CIFS StateDir implementation
  6460.    allows, maybe via Apache::Session.
  6461.  + Sample Apache::ASP applications beyond ./site/eg
  6462.  + More caching options like $Server->Cache for user cache
  6463.    and $Response->Cache for page caching
  6464.  + Caching guide
  6465.  
  6466. =head2 MAY BE DONE
  6467.  
  6468.  + VBScript, ECMAScript or JavaScript interpreters
  6469.  + Dumping state of Apache::ASP during an error, and being
  6470.    able to go through it with the perl debugger.
  6471.  
  6472. =head1 CHANGES
  6473.  
  6474. Apache::ASP has been in development since 1998, and 
  6475. was production ready since its .02 release.  Releases
  6476. are always used in a production setting before being
  6477. made publically available.
  6478.  
  6479. In July 2000, the version numbers of releases went 
  6480. from .19 to 1.9 which is more relevant to software development
  6481. outside the perl community.  Where a .10 perl module usually
  6482. means first production ready release, this would be the
  6483. equivalent of a 1.0 release for other kinds of software.
  6484.  
  6485.  + = improvement   - = bug fix    (d) = documentations
  6486.  
  6487. =item $VERSION = 2.53; $DATE="04/10/2003"
  6488.  
  6489.  + XMLSubs tags with "-" in them will have "-" replaced with "_" or underscore, so a
  6490.    tag like <my:render-table /> will be translated to &my::render_table() ... tags with
  6491.    - in them are common in extended XML syntaxes, but perl subs cannot have - in them only.
  6492.  
  6493.  + Clean setting now works on output when $Response->{ContentType} begins with text/html;
  6494.    like "text/html; charset=iso-8859-2" ... before Clean would only work on output marked
  6495.    with ContentType text/html.  Thanks to Szymon Juraszczyk for recommending fix.
  6496.  
  6497.  --Fixed a bug which would cause Session_OnEnd to be called twice on sessions in a certain case,
  6498.    particularly when an old expired session gets reused by and web browser... this bug was
  6499.    a result of a incomplete session cleanup method in this case.  Thanks to Oleg Kobyakovskiy 
  6500.    for reporting this bug.  Added test in t/session_events.t to cover this problem going forward.
  6501.  
  6502.  - Compile errors from Apache::ASP->Loader() were not being reported.  They will
  6503.    be reported again now.  Thanks to Thanos Chatziathanassiou for discovering and
  6504.    documenting this bug.  Added test in t/load.t to cover this problem going forward.
  6505.  
  6506.  + use of chr(hex($1)) to decode URI encoded parameters instead of pack("c",hex($1))
  6507.    faster & more correct, thanks to Nikolay Melekhin for pointing out this need.
  6508.  
  6509.  (d) Added old perlmonth.com articles to ./site/articles in distribution
  6510.    and linked to them from the docs RESOURCES section
  6511.  
  6512.  (d) Updated documention for the $Application->SessionCount API
  6513.  
  6514.  + Scripts with named subroutines, which is warned against in the style guide,
  6515.    will not be cached to help prevent my closure problems that often
  6516.    hurt new developers working in mod_perl environments.  The downside
  6517.    is that these script will have a performance penalty having to be
  6518.    recompiled each invocation, but this will kill many closure caching 
  6519.    bugs that are hard to detect.
  6520.  
  6521.  - $Request->FileUpload('upload_file', 'BrowserFile') would return
  6522.    a glob before that would be the file name in scalar form.  However
  6523.    this would be interpreted as a reference incorrectly.  The fix
  6524.    is to make sure this is always a scalar by stringifying 
  6525.    this data internally.  Thanks to Richard Curtis for pointing
  6526.    out this bug.
  6527.  
  6528. =item $VERSION = 2.51; $DATE="02/10/2003"
  6529.  
  6530.  + added t/session_query_parse.t test to cover use of SessionQueryParse
  6531.    and $Server->URL APIs
  6532.  
  6533.  - Fixed duplicate "&" bug associated with using $Server->URL 
  6534.    and SessionQueryParse together
  6535.  
  6536.  + Patch to allow $Server->URL() to be called multiple times on the same URL
  6537.    as in $Server->URL($Server->URL($url, \%params), \%more_params)
  6538.  
  6539.  (d) Added new testimonials & sites & created a separate testimonials page.
  6540.  
  6541.  - SessionQueryParse will now add to & to the query strings
  6542.    embedded in the HTML, instead of & for proper HTML generation.
  6543.    Thanks to Peter Galbavy for pointing out and Thanos Chatziathanassiou
  6544.    for suggesting the fix.
  6545.  
  6546.  - $Response->{ContentType} set to text/html for developer error reporting,
  6547.    in case this was set to something else before the error occured.
  6548.    Thanks to Philip Mak for reporting.
  6549.  
  6550.  - Couple of minor bug fixes under PerlWarn use, thanks Peter Galbavy
  6551.    for reporting.
  6552.  
  6553.  + Added automatic load of "use Apache2" for compat with mod_perl2 
  6554.    request objects when Apache::ASP is loaded via "PerlModule Apache::ASP"
  6555.    Thanks to Richard Curtis for reporting bug & subsequent testing.
  6556.  
  6557.  - When GlobalPackage config changes, but global.asa has not, global.asa
  6558.    will be recompiled anyway to update the GlobalPackage correctly.
  6559.    Changing GlobalPackage before would cause errors if global.asa was
  6560.    already compiled.
  6561.  
  6562.  ++ For ANY PerlSetVar type config, OFF/Off/off will be assumed 
  6563.     to have value of 0 for that setting.  Before, only a couple settings
  6564.     had this semantics, but they all do now for consistency.
  6565.  
  6566.  - Fix for InodeNames config on OpenBSD, or any OS that might have
  6567.    a device # of 0 for the file being stat()'d, thanks to Peter Galbavy
  6568.    for bug report.
  6569.  
  6570.  ++ Total XSLT speedups, 5-10% on large XSLT, 10-15% on small XSLT
  6571.  
  6572.  + bypass meta data check like expires for XSLT Cache() API use
  6573.    because XSLT tranformations don't expire, saves hit to cache dbm
  6574.    for meta data
  6575.  
  6576.  + use of direct Apache::ASP::State methods like FETCH/STORE
  6577.    in Cache() layer so we don't have to go through slower tied interface.
  6578.    This will speed up XSLT & and include output caching mostly.
  6579.  
  6580.  + minor optimizations for speed & memory usage
  6581.  
  6582. =item $VERSION = 2.49; $DATE="11/10/2002"
  6583.  
  6584.  -- bug introduced in 2.47 cached script compilations for executing
  6585.     scripts ( not includes ) of the same name in different directories
  6586.     for the same Global/GlobalPackage config for an application.
  6587.     Fix was to remove optimization that caused problem, and
  6588.     created test case t/same_name.t to cover bug.
  6589.  
  6590. =item $VERSION = 2.47; $DATE="11/06/2002"
  6591.  
  6592.  ++ Runtime speed enhancements for 15-20% improvement including:
  6593.    + INTERNAL API ReadFile() now returns scalar ref as memory optimization
  6594.    + cache InodeNames config setting in ASP object now for common lookups
  6595.    + removed CompileChecksum() INTERNAL API, since it was an unnecesary
  6596.      method decomposition along a common code path
  6597.    + removed IsChanged() INTERNAL API since compiling of scripts
  6598.      is now handled by CompileInclude() which does this functionality already
  6599.    + removed unnecessary decomp of IncludesChanged() INTERNAL API, which was along
  6600.      critical code path
  6601.    + do not call INTERNAL SearchDirs() API when compiling base script
  6602.      since we have already validated its path earlier
  6603.    + Use stat(_) type shortcut for stat() & -X calls where possible
  6604.    + Moved @INC initilization up to handler() & consolidated with $INCDir lib
  6605.    + removed useless Apache::ASP::Collection::DESTROY
  6606.    + removed useless Apache::ASP::Server::DESTROY
  6607.    + removed useless Apache::ASP::GlobalASA::DESTROY
  6608.    + removed useless Apache::ASP::Response::DESTROY
  6609.  
  6610.  - Default path for $Response->{Cookies} was from CookiePath
  6611.    config, but this was incorrect as CookiePath config is only
  6612.    for $Session cookie, so now path for $Response->{Cookies}
  6613.    defaults to /
  6614.  
  6615.  - Fixed bug where global.asa events would get undefined with
  6616.    StatINC and GlobalPackage set when the GlobalPackage library
  6617.    changed & get reloaded.
  6618.  
  6619.  (d) Documented long time config NoCache.
  6620.  
  6621.  -- Fixed use with Apache::Filter, capable as both source
  6622.     and destination filter.  Added ./site/eg/filter.filter example
  6623.     to demonstrate these abilities.
  6624.  
  6625.  + Use $r->err_headers_out->add Apache::Table API for cookies 
  6626.    now instead of $r->cgi_header_out.  Added t/cookies.t test to 
  6627.    cover new code path as well as general $Response->Cookies API.
  6628.    Also make cookies headers sorted by cookie and dictionary key 
  6629.    while building headers for repeatable behavior, this latter was 
  6630.    to facilitate testing.
  6631.  
  6632.  - fixed $Server->Mail error_log output when failing to connect
  6633.    to SMTP server.
  6634.  
  6635.  + added tests to cover UniquePackages & NoCache configs since this
  6636.    config logic was updated
  6637.  
  6638.  + made deprecated warnings for use of certain $Response->Member
  6639.    calls more loudly write to error_log, so I can remove the AUTOLOAD
  6640.    for Response one day
  6641.  
  6642.  - Probably fixed behavior in CgiHeaders, at least under perl 5.8.0, and
  6643.    added t/cgi_headers.t to cover this config.
  6644.  
  6645.  + removed $Apache::ASP::CompressGzip setting ability, used to possibly
  6646.    set CompressGzip in the module before, not documented anyway
  6647.  
  6648.  + removed $Apache::ASP::Filter setting ability to set Filter globally, 
  6649.    not documented anyway
  6650.  
  6651.  + removed old work around for setting ServerStarting to 0
  6652.    at runtime, which was bad for Apache::DBI on win32 a long
  6653.    time ago:
  6654.  
  6655.     $Apache::ServerStarting and $Apache::ServerStarting = 0;
  6656.  
  6657.    If this code is still needed in Apache::ASP->handler() let
  6658.    me know.
  6659.  
  6660.  + check to make sure data in internal database is a HASH ref
  6661.    before using it for session garbage collection.  This is to
  6662.    help prevent against internal database corruption in a 
  6663.    network share that does not support flock() file locking.
  6664.  
  6665.  + For new XMLSubs ASP type <%= %> argument interpolation
  6666.    activated with XMLSubsPerlArgs 0, data references can now
  6667.    be passed in addition to SCALAR/string references, so one
  6668.    can pass an object reference like so:
  6669.  
  6670.      <my:tag value="<%= $Object %>" />
  6671.  
  6672.    This will only work as long as the variable interpolation <%= %>
  6673.    are flushed against the containing " " or ' ', or else the object
  6674.    reference will be stringified when it is concatenated with 
  6675.    the rest of the data.
  6676.  
  6677.    Testing for this feature was added to ./t/xmlsubs_aspargs.t
  6678.  
  6679.    This feature is still experimental, and its interface may change.
  6680.    However it is slated for the 3.0 release as default method,
  6681.    so feedback is appreciated.
  6682.  
  6683.  + For new XMLSubs ASP type <%= %> argument interpolation
  6684.    activated with XMLSubsPerlArgs 0, <% %> will no longer work,
  6685.    just <%= %>, as in 
  6686.  
  6687.      <my:tag value="some value <%= $value %> more data" />
  6688.  
  6689.    This feature is still experimental, and its interface may change.
  6690.    However it is slated for the 3.0 release as default method,
  6691.    so feedback is appreciated.
  6692.  
  6693. =item $VERSION = 2.45; $DATE="10/13/2002"
  6694.  
  6695.  ++New XMLSubsPerlArgs config, default 1, indicates how 
  6696.   XMLSubs arguments have always been parsed.  If set to 0,
  6697.   will enable new XMLSubs args that are more ASP like with
  6698.   <%= %> for dynamic interpolation, such as:
  6699.  
  6700.     <my:xmlsub arg="<%= $data %>" arg2="text <%= $data2 %>" />
  6701.  
  6702.   Settings XMLSubsPerlArgs to 0 is experimental for now, but
  6703.   will become the default by Apache::ASP version 3.0
  6704.  
  6705.  ++Optimization for static HTML/XML files that are served up 
  6706.   via Apache::ASP so that they are not compiled into perl subroutines
  6707.   first.  This makes especially native XSLT both faster & take
  6708.   less memory to serve, before XSL & XML files being transformed
  6709.   by XSLT would both be compiled as normal ASP script first, so 
  6710.   now this will happen if they really are ASP scripts with embedded
  6711.   <% %> code blocks & XMLSubs being executed.
  6712.  
  6713.  +Consolidate some config data for Apache::ASP->Loader to use
  6714.   globals in @Apache::ASP::CompileChecksumKeys to know which 
  6715.   config data is important for precompiling ASP scripts.
  6716.  
  6717.  +Further streamlined code compilation.  Now both base
  6718.   scripts and includes use the internal CompileInclude() API
  6719.   to generate code.
  6720.  
  6721.  -Fixed runtime HTML error output when Debug is set to -2/2,
  6722.   so that script correctly again gets rendered in final perl form.
  6723.   Added compile time error output to ./site/eg/syntax_error.htm
  6724.   when a special link is clicked for a quick visual test.
  6725.  
  6726.  -Cleaned up some bad coding practices in ./site/eg/global.asa
  6727.   associated changes in other example files.  Comment example
  6728.   global.asa some for the first time reader
  6729.  
  6730.  -DemoASP.pm examples module needed "use strict" fix, thanks
  6731.   to Allan Vest for bug report
  6732.  
  6733.  --$rv = $Response->Include({ File => ..., Cache => 1});
  6734.   now works to get the first returned value fetched from
  6735.   the cache.  Before, because a list was always returned,
  6736.   $rv would have been equal to the number of items returned,
  6737.   even if the return value list has just one element.
  6738.  
  6739.  (d) added site/robots.txt file with just a comment for
  6740.      search engine indexing
  6741.  
  6742.  -fixed ./site/eg/binary_write.htm to not use 
  6743.   $Response->{ContentLength} because it does not exist.
  6744.   Fixed it to use $Response->AddHeader now instead  
  6745.  
  6746. =item $VERSION = 2.41; $DATE="09/29/2002"
  6747.  
  6748.  -Removed CVS Revision tag from Apache::ASP::Date, which 
  6749.   was causing bad revision numbers in CPAN after CVS integration
  6750.   of Apache::ASP
  6751.  
  6752.  +removed cgi/asp link to ../asp-perl from distribution.  This
  6753.   link was for the deprecated asp script which is now asp-perl
  6754.  
  6755. =item $VERSION = 2.39; $DATE="09/10/2002"
  6756.  
  6757.  -Turn off $^W explicitly before reloading global.asa.  Reloading
  6758.   global.asa when $^W is set will trigger subroutine redefinition
  6759.   warnings.  Reloading global.asa should occur without any problems
  6760.   under normal usage of the system, thus this work around.
  6761.  
  6762.   This fix is important to UseStrict functionality because warnings
  6763.   automatically become thrown as die() errors with UseStrict enabled,
  6764.   so we have to disable normal soft warnings here.
  6765.  
  6766.  -$Response->Include() runtime errors now throw a die() that
  6767.   can be trapped.  This was old functionality that has been restored.
  6768.   Other compile time errors should still trigger a hard error
  6769.   like script compilation, global.asa, or $Response->Include()
  6770.   without an eval()
  6771.  
  6772.  +Some better error handling with Debug 3 or -3 set, cleaned
  6773.   up developer errors messages somewhat.
  6774.  
  6775. =item $VERSION = 2.37; $DATE="07/03/2002"
  6776.  
  6777.  -Fixed the testing directory structures for t/long_names.t
  6778.   so that tar software like Archive::Tar & Solaris tar that
  6779.   have problems with long file names will still be able 
  6780.   to untar distribution successfully.  Now t/long_names.t
  6781.   generates its testing directory structures at runtime.
  6782.  
  6783.  -Fixes for "make test" to work under perl 5.8.0 RC2, 
  6784.   courtesy of Manabu Higashida
  6785.  
  6786.  +SessionQueryForce setting created for disabling use of cookies
  6787.   for $Session session-id passing, rather requiring use of SessionQuery*
  6788.   functionality for session-id passing via URL query string.
  6789.  
  6790.   By default, even when SessionQuery* options are used, cookies will
  6791.   be used if available with SessionQuery* functionality acting only
  6792.   as a backup, so this makes it so that cookies will never be used.
  6793.  
  6794.  +Escape ' with HTMLEncode() to '
  6795.  
  6796.  -Trying to fix t/server_mail.t to work better for platforms
  6797.   that it should skip testing on.  Updated t/server.t test case.
  6798.  
  6799.  +Remove exit() from Makefile.PL so CPAN.pm's automatic
  6800.   follow prereq mechanism works correctly.  Thanks to Slaven Rezic
  6801.   for pointing this out.
  6802.  
  6803.  +Added Apache::compat loading in mod_perl environment for better
  6804.   mod_perl 2.0 support.
  6805.  
  6806. =item $VERSION = 2.35; $DATE="05/30/2002"
  6807.  
  6808.  +Destroy better $Server & $Response objects so that my 
  6809.   closure references to these to not attempt to work in the future 
  6810.   against invalid internal data. There was enough data left in these 
  6811.   old objects to make debugging the my closure problem confusing, where 
  6812.   it looked like the ASP object state became invalid.
  6813.  
  6814.  +Added system debug diagnostics to inspect StateManager group cleanup
  6815.  
  6816.  (d) Documentation update about flock() work around for 
  6817.   Win95/Win98/WinMe systems, confirmed by Rex Arul
  6818.  
  6819.  (d) Documentation/site build bug found by Mitsunobu Ozato, 
  6820.   where <% %> not being escaped correctly with $Server->HTMLEncode().
  6821.   New japanese documentation project started by him 
  6822.   at http://sourceforge.jp/projects/apache-asp-jp/ 
  6823.  
  6824.  -InitPackageGlobals() called after new Apache::ASP object created so 
  6825.   core system templates can be compiled even when there was a runtime
  6826.   compilation error of user templates.  Bug fix needed pointed out by
  6827.   Eamon Daly
  6828.  
  6829. =item $VERSION = 2.33; $DATE="04/29/2002"
  6830.  
  6831.  - fixed up t/server_mail.t test to skip if a sendmail server
  6832.    is not available on localhost.  We only want the test to run
  6833.    if there is a server to test against.
  6834.  
  6835.  + removed cgi/asp script, just a symlink now to the ./asp-perl script
  6836.    which in this way deprecates it.  I had it hard linked, but the 
  6837.    distribution did not untar very well on win32 platform.
  6838.  
  6839.  + Reordered the modules in Bundle::Apache::ASP for a cleaner install.
  6840.  
  6841.  - Fixed bug where XMLSubs where removing <?xml version ... ?> tag
  6842.    when it was needed in XSLT mode.
  6843.  
  6844.  + $Server->Mail({ CC => '...', BCC => '...' }), now works to send
  6845.    CC & BCC headers/recipients.
  6846.  
  6847.  + Removed $Apache::ASP::Register definition which defined the current
  6848.    executing Apache::ASP object.  Only one part of the application was
  6849.    using it, and this has been fixed.  This would have been an unsafe
  6850.    use of globals for a threaded environment.
  6851.  
  6852.  + Decreased latency when doing Application_OnStart, used to sleep(1) 
  6853.    for CleanupMaster sync, but this is not necessary for Application_OnStart 
  6854.    scenario
  6855.  
  6856.  + Restructure code / core templates for MailErrorsTo funcationality.  
  6857.    Wrote test mail_error.t to cover this.  $ENV{REMOTE_USER} will now 
  6858.    be displayed in the MailErrorsTo message when defined from 401 basic auth.
  6859.  
  6860.  + $Server->RegisterCleanup should be thread safe now, as it no longer relies
  6861.    on access to @Apache::ASP::Cleanup for storing the CODE ref stack.
  6862.  
  6863.  + test t/inode_names.t for InodeNames and other file tests covering case
  6864.    of long file names.
  6865.  
  6866.  - Fixed long file name sub identifier bug.  Added test t/long_names.t.
  6867.  
  6868.  + CacheDir may now be set independently of StateDir.  It used to default
  6869.    to StateDir if it was set.
  6870.  
  6871.  ++ Decomposition of modules like Apache::ASP::Session & Apache::ASP::Application
  6872.    out of ASP.pm file.  This should make the source more developer friendly.  
  6873.  
  6874.    This selective code compilation also speeds up CGI requests that do not 
  6875.    need to load unneeded modules like Apache::ASP::Session, by about 50%,
  6876.    so where CGI mode ran at about 2.1 hits/sec before, now for 
  6877.    light requests that do not load $Session & $Application, requests
  6878.    run at 3.4 hits/sec, this is on a dual PIII-450 linux 2.4.x
  6879.  
  6880.  - Caching like for XSLTCache now works in CGI mode.  
  6881.    This was a bug that it did not before.
  6882.  
  6883.  + $Server->File() API added, acts as a wrapper around 
  6884.    Apache->request->filename Added test in t/server.t
  6885.  
  6886.  ++  *** EXPERIMENTAL / ALPHA FEATURE NOTE BEGIN ***
  6887.  
  6888.    New $PERLLIB/Apache/ASP/Share/ directory created to 
  6889.    hold system & user contributed components, which will be found
  6890.    on the $Server->MapInclude() path, which helps $Response->Include
  6891.    search '.',Global,IncludesDir, and now Apache::ASP::Share for
  6892.    includes to load at runtime.  
  6893.  
  6894.    The syntax for loading a shared include is to prefix the file
  6895.    name with Share:: as in:
  6896.  
  6897.     $Response->TrapInclude('Share::CORE/MailError.inc');
  6898.  
  6899.    New test to cover this at t/share.t
  6900.  
  6901.    This feature is experimental.  The naming convention may change
  6902.    and the feature may disappear altogether, so only use if you
  6903.    are interesting in experimenting with this feature & will
  6904.    provide feedback about how it works.
  6905.  
  6906.    *** EXPERIMENTAL / ALPHA FEATURE NOTE END ***
  6907.  
  6908.  + asp-perl script now uses ./asp.conf instead of ./asp.config
  6909.    for runtime configuration via %Config defined there.  Update docs
  6910.    for running in standalone CGI mode
  6911.  
  6912.  + Make use of MANFEST.SKIP to not publish the dev/* files anymore.
  6913.  
  6914.  - Script_OnEnd guaranteed to run after $Response->End, but 
  6915.    it will not run if there was an error earlier in the request.
  6916.  
  6917.  + lots of new test cases covering behaviour of $Response->End
  6918.    and $Response->Redirect under various conditions like XMLSubs
  6919.    and SoftRedirect and global.asa Script_OnStart
  6920.  
  6921.  + asp-perl will be installed into the bin executables when
  6922.    Apache::ASP is installed.  asp-perl is the command line version
  6923.    of Apache::ASP that can also be used to run script in CGI mode.
  6924.    Test case covering asp-perl functionality.
  6925.  
  6926.  + asp CGI/command line script now called asp-perl.  I picked this 
  6927.    name because Apache::ASP often has the name asp-perl in distributions
  6928.    of the module.
  6929.  
  6930.  + Apache::ASP::CGI::Test class now subclass of Apache::ASP::CGI.  To facilitate
  6931.    this Apache::ASP::CGI::init() now called OO like Apache::ASP::CGI->init()
  6932.    Fixed up places where the old style was called.  New Test class allows
  6933.    a dummy Apache request object to be built which caches header & body output
  6934.    for later inspection instead of writing it to STDOUT.
  6935.  
  6936.  - $Response->Redirect() under SoftRedirect 1 will not first Clear() buffer
  6937.  
  6938.  - $Response->Redirect() in an XMLSubs will work now ... behavior
  6939.    of $Response->Flush() being turned off in an XMLSubs was interfering with this.
  6940.  
  6941.  + srand() init tracking done better, thanks for patch from Ime Smits
  6942.  
  6943.  + Added file/directory being used for precompilation in 
  6944.    Apache::ASP->Loader($file, ...) to output like:
  6945.  
  6946.     [Mon Feb 04 20:19:22 2002] [error] [asp] 4215 (re)compiled 22 scripts 
  6947.       of 22 loaded for $file
  6948.  
  6949.    This is so that when precompiling multiple web sites
  6950.    each with different directories, one can easier see the 
  6951.    compile output relevant to the Loader() command being run.
  6952.  
  6953.  + better decomp of Apache::ASP site build files at ./build/* files,
  6954.    which is good should anyone look at it for ideas.
  6955.  
  6956.  + improved test suite to error when unintended output results from
  6957.    t/*.t test scripts.
  6958.  
  6959.  - () now supported in XMLSubsMatch config, added xmlsubsmatch.t test...
  6960.    specifically a config like 
  6961.  
  6962.      PerlSetVar (aaa|bbb):\w+ 
  6963.  
  6964.    should now work.  Thanks for bug report from David Kulp.
  6965.  
  6966.  + Added an early srand() for better $ServerID creation
  6967.  
  6968.  + Work around for DSO problems where $r is not always correctly 
  6969.    defined in Apache::ASP::handler().  Thanks to Tom Lear for patch.
  6970.  
  6971. =item $VERSION = 2.31; $DATE="01/22/2002";
  6972.  
  6973.  + $Server->MapInclude() API extension created to wrap up Apache::ASP::SearchDirs 
  6974.    functionality so one may do an conditional check for an include existence befor 
  6975.    executing $Response->Include().  Added API test to server.t
  6976.  
  6977.  + $Server->Transfer() now allows arguments like $Response->Include(), and now acts just
  6978.    as a wrapper for:
  6979.  
  6980.      $Response->Include($file, @args);
  6981.      $Response->End();
  6982.  
  6983.    added test case at t/server_transfer.t
  6984.  
  6985.  + Removed dependency of StatINC functionality on Apache::Symbol.  Apache::Symbol 
  6986.    is no longer required.  Added test of t/stat_inc.t for correct StatINC initialization
  6987.    for platforms where Devel::Symdump is present.
  6988.  
  6989.  + Better error message when $Request->Params has not been defined with RequestParams
  6990.    config & it gets used in script.  Added test case as t/request_params_none.t
  6991.  
  6992.  + Directories cannot now be included as scripts via $Response->Include(), added
  6993.    test case to t/include.t
  6994.  
  6995.  - No longer make $Response->Flush dependent on $Response->IsClientConnected() to 
  6996.    be true to write output to client.  There have been spurious errors reported
  6997.    about the new ( >= 2.25 ) IsClientConnected code, and this will limit the impact 
  6998.    of that functionality possibly not working still to those users explicitly using 
  6999.    that API.
  7000.  
  7001.  + $Response->AddHeader($header_name, $value) now will set $Response members
  7002.    for these headers: Content-Type, Cache-Control, Expires.  This is to avoid
  7003.    both the application & Apache::ASP sending out duplicate headers.  Added
  7004.    test cases for this to t/response.t
  7005.  
  7006.  + split up Bundle::Apache::ASP into that, and Bundle::Apache::ASP::Extra
  7007.    the former with just the required modules to run, and the latter 
  7008.    for extra functionality in Apache::ASP
  7009.  
  7010.  + new $Request->{Method} member to return $r->method of GET or POST that 
  7011.    client browser is requesting, added t/request.t sub test to cover this member.
  7012.  
  7013. =item $VERSION = 2.29; $DATE="11/19/2001";
  7014.  
  7015.  +Added some extra help text to the ./cgi/asp --help message
  7016.   to clarify how to pass arguments to a script from the command line.
  7017.  
  7018.  +When using $Server->Mail() API, if Content-Type header is set,
  7019.   and MIME-Version is not, then a "MIME-Version: 1.0" header will be sent
  7020.   for the email.  This is correct according to RFC 1521 which specifies
  7021.   for the first time the Content-Type: header for email documents.
  7022.   Thanks to Philip Mak for pointing out this correct behavior.
  7023.  
  7024.  +Made dependent on MLDBM::Sync version .25 to pass the taint_check.t test
  7025.  
  7026.  +Improved server_mail.t test to work with mail servers were relaying is denied
  7027.  
  7028.  +Added <html><body> tags to MailErrorsTo email
  7029.  
  7030.  --Fixed SessionCount / Session_OnEnd bug, where these things were not
  7031.   working for $Sessions that never had anything written to them.
  7032.   This bug was introduced in 2.23/2.25 release.
  7033.  
  7034.   There was an optimization in 2.23/2.25 where a $Session that was never
  7035.   used does not write its state lock file & dbm files to disk, only if
  7036.   it gets written too like $Session->{MARK}++.  Tracking of these NULL $Sessions 
  7037.   then is handled solely in the internal database.  For $Session garbage 
  7038.   collection though which would fire Session_OnEnd events and update 
  7039.   SessionCount, the Apache::ASP::State->GroupMembers() function was just 
  7040.   looking for state files on disk ... now it looks in the internal database 
  7041.   too for SessionID records for garbage collection.
  7042.  
  7043.   Added a test at ./t/session_events.t for these things.
  7044.  
  7045.  +Some optimizations for $Session API use.
  7046.  
  7047.  +Added support for XSLT via XML::LibXSLT, patch courtesy of Michael Buschauer
  7048.  
  7049.  -Got rid of an warning when recompiling changing includes under perl 5.6.1...
  7050.   undef($code) method did not work for this perl version, rather undef(&$code) does.
  7051.   Stopped using using Apache::Symbol for this when available.
  7052.  
  7053.  -Make Apache::ASP script run under perl taint checking -T for perl 5.6.1...
  7054.   $code =~ tr///; does not work to untaint here, so much use the slower:
  7055.   $code =~ /^(.*)$/s; $code = $1; method to untaint.
  7056.  
  7057.  -Check for inline includes changing, included in a dynamic included
  7058.   loaded at runtime via $Response->Include().  Added test case for
  7059.   this at t/include_change.t.  If an inline include of a dynamic include
  7060.   changes, the dynamic include should get recompiled now.
  7061.  
  7062.  -Make OK to use again with PerlTaintCheck On, with MLDBM::Sync 2.25.
  7063.   Fixed in ASP.pm, t/global.asa, and created new t/taint_check.t test script
  7064.  
  7065.  +Load more modules when Apache::ASP is loaded so parent will share more
  7066.   with children httpd: 
  7067.    Apache::Symbol 
  7068.    Devel::Symdump 
  7069.    Config 
  7070.    lib 
  7071.    MLDBM::Sync::SDBM_File
  7072.  
  7073.  +When FileUploadMax bytes is exceeded for a file upload, there will not
  7074.   be an odd error anymore resulting from $CGI::POST_MAX being triggered,
  7075.   instead the file upload input will simply be ignored via $CGI::DISABLE_UPLOADS.
  7076.   This gives the developer the opportunity to tell the user the the file upload
  7077.   was too big, as demonstrated by the ./site/eg/file_upload.asp example.
  7078.  
  7079.   To not let the web client POST a lot of data to your scripts as a form
  7080.   of a denial of service attack use the apache config LimitRequestBody for the 
  7081.   max limits.  You can think of PerlSetVar FileUploadMax as a soft limit, and 
  7082.   apache's LimitRequestBody as a hard limit.
  7083.  
  7084.  --Under certain circumstances with file upload, it seems that IsClientConnected() 
  7085.   would return an aborted client value from $r->connection->aborted, so
  7086.   the buffer output data would not be flushed to the client, and 
  7087.   the HTML page would return to the browser empty.  This would be under
  7088.   normal file upload use.  One work-around was to make sure to initialize
  7089.   the $Request object before $Response->IsClientConnected is called,
  7090.   then $r->connection->aborted returns the right value.
  7091.   
  7092.   This problem was probably introduced with IsClientConnected() code changes
  7093.   starting in the 2.25 release.
  7094.  
  7095. =item $VERSION = 2.27; $DATE="10/31/2001";
  7096.  
  7097.  + Wrapped call to $r->connection->fileno in eval {} so to 
  7098.    preserve backwards compatibility with older mod_perl versions
  7099.    that do not have this method defined.  Thanks to Helmut Zeilinger
  7100.    for catching this.
  7101.  
  7102.  + removed ./dev directory from distribution, useless clutter
  7103.  
  7104.  + Removed dependency on HTTP::Date by taking code into
  7105.    Apache::ASP as Apache::ASP::Date.  This relieves
  7106.    the dependency of Apache::ASP on libwww LWP libraries.
  7107.    If you were using HTTP::Date functions before without loading
  7108.    "use HTTP::Date;" on your own, you will have to do this now.
  7109.  
  7110.  + Streamlined code execution.  Especially worked on 
  7111.    $Response->IsClientConnected which gets called during
  7112.    a normal request execution, and got rid of IO::Select
  7113.    dependency. Some function style calls instead of OO style 
  7114.    calls where private functions were being invokes that one 
  7115.    would not need to override.
  7116.  
  7117.  - Fixed possible bug when flushing a data buffer where there
  7118.    is just a '0' in it.
  7119.  
  7120.  + Updated docs to note that StateCache config was deprecated
  7121.    as of 2.23.  Removed remaining code that referenced the config.
  7122.  
  7123.  + Removed references to unused OrderCollections code.
  7124.  
  7125.  - Better Cache meta key, lower chance of collision with 
  7126.    unrelated data since its using the full MD5 keyspace now
  7127.  
  7128.  + Optimized some debugging statements that resulted 
  7129.    from recent development.
  7130.  
  7131.  + Tie::TextDir .04 and above is supported for StateDB
  7132.    and CacheDB settings with MLDBM::Sync .21. This is good for 
  7133.    CacheDB where output is larger and there are not many 
  7134.    versions to cache, like for XSLTCache, where the site is 
  7135.    mostly static.
  7136.  
  7137.  + Better RESOURCES section to web site, especially with adding
  7138.    some links to past Apache::ASP articles & presentations.
  7139.  
  7140. =item $VERSION = 2.25; $DATE="10/11/2001";
  7141.  
  7142.  + Improved ./site/apps/search application, for better
  7143.    search results at Apache::ASP site.  Also, reengineered
  7144.    application better, with more perl code moved to global.asa.
  7145.    Make use of MLDBM::Sync::SDBM_File, where search database
  7146.    before was engineering around SDBM_File's shortcomings.
  7147.  
  7148.  - Fix for SessionSerialize config, which broke in 2.23
  7149.    Also, added t/session_serialize.t to test suite to catch
  7150.    this problem in the future.
  7151.  
  7152. =item $VERSION = 2.23; $DATE="10/11/2001";
  7153.  
  7154.  +Make sure a couple other small standard modules get loaded
  7155.   upon "PerlModule Apache::ASP", like Time::HiRes, Class::Struct,
  7156.   and MLDBM::Serializer::Data::Dumper.  If not available
  7157.   these modules won't cause errors, but will promote child httpd
  7158.   RAM sharing if they are.
  7159.  
  7160.  -XMLSubs args parsing fix so an arg like z-index
  7161.   does not error under UseStrict.  This is OK now:
  7162.  
  7163.    <my:layer z-index=3 top=0 left=0> HTML </my:layer>
  7164.  
  7165.  -Only remove outermost <SCRIPT> tags from global.asa
  7166.   for IIS/PerlScript compatibility.  Used to remove
  7167.   all <SCRIPT> tags, which hurt when some subs in globa.asa
  7168.   would be printing some JavaScript.
  7169.  
  7170.  +$Response->{IsClientConnected} now updated correctly 
  7171.   before global.asa Script_OnStart.  $Response->IsClientConnect()
  7172.   can be used for accurate accounting, while 
  7173.   $Response->{IsClientConnected} only gets updated
  7174.   after $Response->Flush().  Added test cases to response.t
  7175.  
  7176.  +$Server->HTMLEncode(\$data) API extension, now can take
  7177.   scalar ref, which can give a 5% improvement in benchmarks
  7178.   for data 100K in size.
  7179.  
  7180.  -Access to $Application is locked when Application_OnEnd & 
  7181.   Application_OnStart is called, creating a critical section
  7182.   for use of $Application
  7183.  
  7184.  ++MLDBM::Sync used now for core DBM support in Apache::ASP::State.
  7185.   This drastically simplifies/stabilizes the code in there
  7186.   and will make it easier for future SQL database plugins.
  7187.  
  7188.  +New API for accessing ASP object information in non content
  7189.   handler phases:
  7190.  
  7191.     use Apache::ASP;
  7192.     sub My::Auth::handler {
  7193.       my $r = shift;
  7194.       my $ASP = Apache::ASP->new($r) 
  7195.       my $Session = $ASP->Session;
  7196.     }
  7197.  
  7198.   In the above example, $Session would be the same $Session
  7199.   object created later while running the ASP script for this
  7200.   same request.  
  7201.  
  7202.   Added t/asp_object.t test for this.  Fixed global.asa to only 
  7203.   init StateDir when application.asp starts which is the first 
  7204.   test script to run.
  7205.  
  7206.  -Fixed on Win32 to make Apache::ASP->new($r) able to create
  7207.   multiple master ASP objects per request.  Was not reentrant 
  7208.   safe before, particularly with state locking for dbms like 
  7209.   $Application & $Session.  
  7210.  
  7211.  ++Output caching for includes, built on same layer ( extended )
  7212.   as XSLTCache, test suite at t/cache.t.  Enabled with special 
  7213.   arguments to 
  7214.  
  7215.     $Response->Include(\%args, @include_args)
  7216.     $Response->TrapInclude(\%args, @include_args)
  7217.     $Server->Execute(\%args, @include_args)
  7218.  
  7219.   where %args = (
  7220.     File => 'file.inc',
  7221.     Cache => 1, # to activate cache layer
  7222.     Expires => 3600, # to expire in one hour
  7223.     LastModified => time() - 600, # to expire if cached before 10 minutes ago
  7224.     Key => $Request->Form, # to cache based on checksum of serialized form data,
  7225.     Clear => 1, # to not allow fetch from cache this time, will always execute include
  7226.   );
  7227.  
  7228.   Like the XSLTCache, it uses MLDBM::Sync::SDBM_File
  7229.   by default, but can use DB_File or GDBM_File if
  7230.   CacheDB is set to these.
  7231.  
  7232.   See t/cache.t for API support until this is documented.
  7233.  
  7234.  +CacheSize now supports units of M, K, B like 
  7235.  
  7236.    CacheSize 10M
  7237.    CacheSize 10240K
  7238.    CacheSize 10000000B
  7239.    CacheSize 10000000
  7240.  
  7241.  -Better handling of $Session->Abandon() so multiple
  7242.   request to the same session while its being destroyed
  7243.   will have the right effect.
  7244.  
  7245.  +Optimized XMLSubs parsing.  Scripts with lots lof XMLSubs 
  7246.   now parse faster for the first time.  One test script with 
  7247.   almost 200 such tags went from a parse time of around 3 seconds
  7248.   to .7 seconds after optimizations.
  7249.  
  7250.  +Updated performance tuning docs, particularly for using
  7251.   Apache::ASP->Loader()
  7252.  
  7253.  +$Server->URL($url, \%params) now handles array refs
  7254.   in the params values like
  7255.     $Server->URL($url, { key => [ qw( value1 value2 ) ] })
  7256.  
  7257.   This is so that query string data found in 
  7258.   $Request->QueryString that gets parsed into this form
  7259.   from a string like: ?key=value&key=value2 would be 
  7260.   able to be reused passed back to $Server->URL to 
  7261.   create self referencing URLs more easily.
  7262.  
  7263.  -Bug fix where XMLSubs like <s:td /> now works on perl 
  7264.   5.005xx, thanks to Philip Mak for reporting & fix.
  7265.  
  7266.  +When searching for included files, will now join
  7267.   the absolute path of the directory of the script
  7268.   with the name of the file if its a relative file
  7269.   name like ./header.inc.  Before, would just look
  7270.   for something like ././header.inc by using '.'
  7271.   as the first directory to look for includes in.
  7272.  
  7273.   The result of this is that scripts in two directories
  7274.   configured with the same Global setting should be able
  7275.   to have separate local header.inc files without causing
  7276.   a cached namespace collision.
  7277.  
  7278.  +$Server->Config() call will return a hash ref 
  7279.   to all the config setting for that request, like
  7280.   Apache->dir_config would.
  7281.  
  7282.  -StatINC setting with Apache::ASP->Loader() works again.
  7283.   This makes StatINC & StatINCMatch settings viable 
  7284.   for production & development use when the system has
  7285.   very many modules.
  7286.  
  7287.  -Cookieless session support with configs like SessionQueryParse
  7288.   and SessionQuery now work for URLs with frags in them
  7289.   like http://localhost?arg=value#frag
  7290.  
  7291.  +@rv = $Response->Include() now works where there are
  7292.   multiple return values from an include like:
  7293.   <% return(1,2); %>
  7294.  
  7295. =item $VERSION = 2.21; $DATE="8/5/2001";
  7296.  
  7297.  +Documented RequestParams config in CONFIG misc section.
  7298.  
  7299.  +Documented new XSLT caching directives.
  7300.  
  7301.  +Updated ./site/eg/.htaccess XSLT example config
  7302.   to use XSLTCache setting.
  7303.  
  7304.  +New FAQ section on why perl variables are sticky globals,
  7305.   suggested by Mark Seger.
  7306.  
  7307.  -push Global directory onto @INC during ASP script execution
  7308.   Protect contents of original @INC with local.  This makes
  7309.   things compatible with .09 Apache::ASP where we always had
  7310.   Global in @INC.  Fixed needed by Henrik Tougaard
  7311.  
  7312.  - ; is a valid separator like & for QueryString Parameters
  7313.   Fixed wanted by Anders
  7314.  
  7315.  -XSMLSubsMatch doc fix in CONFIG section
  7316.  
  7317.  +Reduces number of Session groups to 16 from 32, so 
  7318.   session manager for small user sets will be that much faster.
  7319.  
  7320.  +optimizations for internal database, $Application, and $Session
  7321.   creation.
  7322.  
  7323.  +XSLTCache must be set for XSLT caching to begin using CacheDir
  7324.  
  7325.  +CacheDB like StateDB bug sets dbm format for caching, which
  7326.   defaults to MLDBM::Sync::SDBM_File, which works well for caching
  7327.   output sizes < 50K
  7328.  
  7329.  +CacheDir config for XSLT caching ... defaults to StateDir
  7330.  
  7331.  +CacheSize in bytes determines whether the caches in CacheDir
  7332.   are deleted at the end of the request.  A cache will be 
  7333.   reset in this way back to 0 bytes. Defaults to 10000000 bytes
  7334.   or about 10M.
  7335.  
  7336.  +Caching infrastructure work that is being used in XSLT
  7337.   can be leveraged later for output caching of includes,
  7338.   or arbitrary user caching.
  7339.  
  7340.  -t/server_mail.t test now uses valid email for testing
  7341.   purposes ... doesn't actually send a mail, but for SMTP
  7342.   runtime validation purposes it should be OK.
  7343.  
  7344.  +fixed where POST data was read from under MOD_PERL,
  7345.   harmless bug this was that just generated the wrong
  7346.   system debugging message.
  7347.  
  7348. =item $VERSION = 2.19; $DATE="7/10/2001";
  7349.  
  7350.  +update docs in various parts
  7351.  
  7352.  +added ./make_httpd/build_httpds.sh scripts for quick builds
  7353.   of apache + mod_perl + mod_ssl
  7354.  
  7355.  ++plain CGI mode available for ASP execution.  
  7356.   cgi/asp script can now be used to execute ASP 
  7357.   scripts in CGI mode.  See CGI perldoc section for more info.
  7358.   The examples in ./site/eg have been set up to run
  7359.   in cgi mode if desired.  Configuration in CGI section
  7360.   only tested for Apache on Linux.
  7361.  
  7362.  -Fixed some faulty or out of date docs in XML/XSLT section.
  7363.  
  7364.  +added t/server_mail.t test for $Server->Mail(), requires
  7365.   Net::SMTP to be configured properly to succeed.
  7366.  
  7367.  +Net::SMTP debugging not enabled by Debug 1,2,3 configs,
  7368.   not only when system debugging is set with Debug -1,-2,-3
  7369.   However, a Debug param passed to $Server->Mail() will 
  7370.   sucessfully override the Debug -1,-2,-3 setting even
  7371.   when its Debug => 0
  7372.  
  7373.  -Check for undef values during stats for inline includes
  7374.   so we don't trigger unintialized warnings
  7375.  
  7376.  +Documented ';' may separate many directories in the IncludesDir
  7377.   setting for creating a more flexible includes search path.
  7378.  
  7379. =item $VERSION = 2.17; $DATE="6/17/2001";
  7380.  
  7381.  +Added ASP perl mmm-mode subclass and configuration
  7382.   in editors/mmm-asp-perl.el file for better emacs support.
  7383.   Updated SYNTAX/Editors documentation.
  7384.  
  7385.  +Better debugging error message for Debug 2 or 3 settings 
  7386.   for global.asa errors.  Limit debug output for lines
  7387.   preceding rendered script.
  7388.  
  7389.  -In old inline include mode, there should no longer
  7390.   be the error "need id for includes" when using
  7391.   $Response->Include() ... if DynamicIncludes were
  7392.   enabled, this problem would not have likely occured
  7393.   anyway.  DynamicIncludes are preferrable to use so
  7394.   that compiled includes can be shared between scripts.
  7395.   This bug was likely introduced in version 2.11.
  7396.  
  7397.  -Removed logging from $Response->BinaryWrite() in regular
  7398.   debug mode 1 or 2.  Logging still enabled in system Debug mode, -1 or -2
  7399.  
  7400.  -Removed other extra system debugging call that is really not
  7401.   necessary.
  7402.  
  7403. =item $VERSION = 2.15; $DATE="06/12/2001";
  7404.  
  7405.  -Fix for running under perl 5.6.1 by removing parser optimization
  7406.   introduced in 2.11.
  7407.  
  7408.  -Now file upload forms, forms with ENCTYPE="multipart/form-data"
  7409.   can have multiple check boxes and select items marked for 
  7410.   @params = $Request->Form('param_name') functionality.  This 
  7411.   will be demonstrated via the ./site/eg/file_upload.asp example.
  7412.  
  7413. =item $VERSION = 2.11; $DATE="05/29/2001";
  7414.  
  7415.  +Parser optimization from Dariusz Pietrzak
  7416.  
  7417.  -work around for global destruction error message for perl 5.6
  7418.   during install
  7419.  
  7420.  +$Response->{IsClientConnected} now will be set
  7421.   correctly with ! $r->connection->aborted after each
  7422.   $Response->Flush()
  7423.  
  7424.  +New XSLTParser config which can be set to XML::XSLT or
  7425.   XML::Sablotron.  XML::Sablotron renders 10 times faster, 
  7426.   but differently.  XML::XSLT is pure perl, so has wider
  7427.   platform support than XML::Sablotron.  This config affects
  7428.   both the XSLT config and the $Server->XSLT() method.
  7429.  
  7430.  +New $Server->XSLT(\$xsl_data, \$xml_data) API which 
  7431.   allows runtime XSLT on components instead of having to process
  7432.   the entire ASP output as XSLT.  
  7433.  
  7434.  -XSLT support for XML::XSL 0.32.  Things broke after .24.
  7435.  
  7436.  -XSLTCacheSize config no longer supported.  Was a bad 
  7437.   Tie::Cache implementation.  Should be file based cache
  7438.   to greatly increases cache hit ratio.
  7439.  
  7440.  ++$Response->Include(), $Response->TrapInclude(),
  7441.   and $Server->Execute() will all take a scalar ref
  7442.   or \'asdfdsafa' type code as their first argument to execute 
  7443.   a raw script instead of a script file name.  At this time, 
  7444.   compilation of such a script, will not be cached.  It is 
  7445.   compiled/executed as an anonymous subroutine and will be freed
  7446.   when it goes out of scope.
  7447.  
  7448.  + -p argument to cgi/asp script to set GlobalPackage
  7449.   config for static site builds
  7450.  
  7451.  -pod commenting fix where windows clients are used for 
  7452.   ASP script generation.
  7453.  
  7454.  +Some nice performance enhancements, thank to submissions from
  7455.   Ime Smits.  Added some 1-2% per request execution speed.
  7456.  
  7457.  +Added StateDB MLDBM::Sync::SDBM_File support for faster
  7458.   $Session + $Application than DB_File, yet still overcomes
  7459.   SDBM_File's 1024 bytes value limitation.  Documented in 
  7460.   StateDB config, and added Makefile.PL entry.
  7461.  
  7462.  +Removed deprecated MD5 use and replace with Digest::MD5 calls
  7463.  
  7464.  +PerlSetVar InodeNames 1 config which will compile scripts hashed by 
  7465.   their device & inode identifiers, from a stat($file)[0,1] call.
  7466.   This allows for script directories, the Global directory,
  7467.   and IncludesDir directories to be symlinked to without
  7468.   recompiling identical scripts.  Likely only works on Unix
  7469.   systems.  Thanks to Ime Smits for this one.
  7470.  
  7471.  +Streamlined code internally so that includes & scripts were
  7472.   compiled by same code.  This is a baby step toward fusing
  7473.   include & script code compilation models, leading to being
  7474.   able to compile bits of scripts on the fly as ASP subs, 
  7475.   and being able to garbage collect ASP code subroutines.
  7476.  
  7477.  -removed @_ = () in script compilation which would trigger warnings 
  7478.   under PerlWarn being set, thanks for Carl Lipo for reporting this.
  7479.  
  7480.  -StatINC/StatINCMatch fix for not undeffing compiled includes
  7481.   and pages in the GlobalPackage namespace
  7482.  
  7483.  -Create new HTML::FillInForm object for each FormFill
  7484.   done, to avoid potential bug with multiple forms filled
  7485.   by same object.  Thanks to Jim Pavlick for the tip.
  7486.  
  7487.  +Added PREREQ_PM to Makefile.PL, so CPAN installation will
  7488.   pick up the necessary modules correctly, without having
  7489.   to use Bundle::Apache::ASP, thanks to Michael Davis. 
  7490.  
  7491.  + > mode for opening lock files, not >>, since its faster
  7492.  
  7493.  +$Response->Flush() fixed, by giving $| = 1 perl hint
  7494.   to $r->print() and the rest of the perl sub.
  7495.  
  7496.  +$Response->{Cookies}{cookie_name}{Expires} = -86400 * 300;
  7497.   works so negative relative time may be used to expire cookies.
  7498.  
  7499.  +Count() + Key() Collection class API implementations
  7500.  
  7501.  +Added editors/aasp.vim VIM syntax file for Apache::ASP,
  7502.   courtesy of Jon Topper.
  7503.  
  7504.  ++Better line numbering with #line perl pragma.  Especially
  7505.   helps with inline includes.  Lots of work here, & integrated
  7506.   with Debug 2 runtime pretty print debugging.
  7507.  
  7508.  +$Response->{Debug} member toggles on/off whether 
  7509.   $Response->Debug() is active, overriding the Debug setting
  7510.   for this purpose.  Documented.
  7511.  
  7512.  -When Filter is on, Content-Length won't be set and compression
  7513.   won't be used.  These things would not work with a filtering
  7514.   handler after Apache::ASP
  7515.  
  7516. =item $VERSION = 2.09; $DATE="01/30/2001";
  7517.  
  7518.  +Examples in ./site/eg are now UseStrict friendly.  
  7519.   Also fixed up ./site/eg/ssi_filter.ssi example.
  7520.  
  7521.  +Auto purge of old stale session group directories, increasing 
  7522.   session manager performance when using Sessions when migrating
  7523.   to Apache::ASP 2.09+ from older versions.
  7524.  
  7525.  +SessionQueryParse now works for all $Response->{ContentType}
  7526.   starting with 'text' ... before just worked with text/html,
  7527.   now other text formats like wml will work too. 
  7528.  
  7529.  +32 groups instead of 64, better inactive site session group purging.
  7530.  
  7531.  +Default session-id length back up to 32 hex bytes.
  7532.   Better security vs. performance, security more important,
  7533.   especially when performance difference was very little.
  7534.  
  7535.  +PerlSetVar RequestParams 1 creates $Request->Params
  7536.   object with combined contents of $Request->QueryString
  7537.   and $Request->Form
  7538.  
  7539.  ++FormFill feature via HTML::FillInForm.  Activate with
  7540.   $Response->{FormFill} = 1 or PerlSetVar FormFill 1
  7541.   See site/eg/formfill.asp for example.
  7542.  
  7543.  ++XMLSubs tags of the same name may be embedded in each other
  7544.   recursively now.
  7545.  
  7546.  +No umask() use on Win32 as it seems unclear what it would do
  7547.  
  7548.  +simpler Apache::ASP::State file handle mode of >> when opening 
  7549.   lock file.  saves doing a -e $file test.
  7550.  
  7551.  +AuthServerVariables config to init $Request->ServerVariables
  7552.   with basic auth data as documented.  This used to be default
  7553.   behavior, but triggers "need AuthName" warnings from recent
  7554.   versions of Apache when AuthName is not set.
  7555.  
  7556.  -Renamed Apache::ASP::Loader class to Apache::ASP::Load
  7557.   as it collided with the Apache::ASP->Loader() function
  7558.   namespace.  Class used internally by Apache::ASP->Loader()
  7559.   so no public API changed here.
  7560.  
  7561.  +-Read of POST input for $Request->BinaryRead() even
  7562.    if its not from a form.  Only set up $Request->Form
  7563.    if this is from a form POST.
  7564.  
  7565.  +faster POST/GET param parsing
  7566.  
  7567. =item $VERSION = 2.07; $DATE="11/26/2000";
  7568.  
  7569.  -+-+ Session Manager
  7570.   empty state group directories are not removed, thus alleviating
  7571.   one potential race condition.  This impacted performance
  7572.   on idle sites severely as there were now 256 directories
  7573.   to check, so made many performance enhancements to the 
  7574.   session manager.  The session manager is built to handle
  7575.   up to 20,000 client sessions over a 20 minute period.  It
  7576.   will slow the system down as it approaches this capacity.
  7577.  
  7578.   One such enhancement was session-ids now being 11 bytes long 
  7579.   so that its .lock file is only 16 characters in length.  
  7580.   Supposedly some file systems lookup files 16 characters or 
  7581.   less in a fast hashed lookup.  This new session-id has
  7582.   4.4 x 10^12 possible values.  I try to keep this space as
  7583.   large as possible to prevent a brute force attack.
  7584.  
  7585.   Another enhancement was to limit the group directories
  7586.   to 64 by only allowing the session-id prefix to be [0-3][0-f]
  7587.   instead of [0-f][0-f], checking 64 empty directories on an
  7588.   idle site takes little time for the session manager, compared
  7589.   to 256 which felt significant from the client end, especially
  7590.   on Win32 where requests are serialized.  
  7591.  
  7592.   If upgrading to this version, you would do well to delete
  7593.   empty StateDir group directories while your site is idle.
  7594.   Upgrading during an idle time will have a similar effect,
  7595.   as old Apache::ASP versions would delete empty directories.
  7596.  
  7597.  -$Application->GetSession($session_id) now creates
  7598.   an session object that only lasts until the next
  7599.   invocation of $Application->GetSession().  This is 
  7600.   to avoid opening too many file handles at once,
  7601.   where each session requires opening a lock file.
  7602.  
  7603.  +added experimental support for Apache::Filter 1.013 
  7604.   filter_register call
  7605.  
  7606.  +make test cases for $Response->Include() and 
  7607.   $Response->TrapInclude()
  7608.  
  7609.  +Documented CollectionItem config.
  7610.  
  7611.  +New $Request->QueryString('multiple args')->Count()
  7612.   interface implemented for CollectionItem config.
  7613.   Also $Request->QueryString('multiple args')->Item(1) method.
  7614.   Note ASP collections start counting at 1.
  7615.  
  7616.  --fixed race condition, where multiple processes might 
  7617.   try creating the same state directory at the same time, with
  7618.   one winning, and one generating an error.  Now, web process
  7619.   will recheck for directory existence and error if 
  7620.   it doesn't. 
  7621.  
  7622.  -global.asa compilation will be cached correctly, not
  7623.   sure when this broke.  It was getting reloaded every request.
  7624.  
  7625.  -StateAllWrite config, when set creates state files
  7626.   with a+rw or 0666 permissions, and state directories
  7627.   with a+rwx or 0777 permissions.  This allows web servers
  7628.   running as different users on the same machine to share a 
  7629.   common StateDir config.  Also StateGroupWrite config
  7630.   with perms 0770 and 0660 respectively.
  7631.  
  7632.  -Apache::ASP->Loader() now won't follow links to 
  7633.   directories when searching for scripts to load.
  7634.  
  7635.  +New RegisterIncludes config which is on by default only
  7636.   when using Apache::ASP->Loader(), for compiling includes
  7637.   when precompiling scripts.
  7638.  
  7639.  +Apache::ASP::CompileInclude path optimized, which underlies
  7640.   $Response->Include()
  7641.  
  7642.  +$Request->QueryString->('foo')->Item() syntax enabled
  7643.   with CollectionItem config setting.  Default syntax
  7644.   supported is $Request->QueryString('foo') which is
  7645.   in compatible.  Other syntax like $Request->{Form}{foo}
  7646.   and $Request->Form->Item('foo') will work in either case.
  7647.  
  7648.  +New fix suggested for missing Apache reference in 
  7649.   Apache::ASP handler startup for RedHat RPMs.  Added
  7650.   to error message.
  7651.  
  7652.  --Backup flock() unlocking try for QNX will not corrupt the 
  7653.   normal flock() LOCK_UN usage, after trying to unlock a file
  7654.   that doesn't exist.  This bug was uncovered from the below 
  7655.   group deletion race condition that existed. 
  7656.  
  7657.  -Session garbage collection will not delete new group
  7658.   directories that have just been created but are empty.
  7659.   There was a race condition where a new group directory would
  7660.   be created, but then deleted by a garbage collector before
  7661.   it could be initialized correctly with new state files.
  7662.  
  7663.  +Better random session-id checksums for $Session creation.
  7664.   per process srand() initialization, because srand() 
  7665.   may be called once prefork and never called again.
  7666.   Call without arguments to rely on perl's decent rand
  7667.   seeding.  Then when calling rand() in Secret() we have
  7668.   enough random data, that even if someone else calls srand()
  7669.   to something fixed, should not mess things up terribly since
  7670.   we checksum things like $$ & time, as well as perl memory
  7671.   references.
  7672.  
  7673.  +XMLSubs installation make test.
  7674.  
  7675.  -Fix for multiline arguments for XMLSubs
  7676.  
  7677. =item $VERSION = 2.03; $DATE="08/01/2000";
  7678.  
  7679.  +License change to GPL.  See LICENSE section.
  7680.  
  7681.  +Setup of www.apache-asp.org site, finally!
  7682.  
  7683.  -get rid of Apache::ASP->Loader() warning message for perl 5.6.0
  7684.  
  7685. =item $VERSION = 2.01; $DATE="07/22/2000";
  7686.  
  7687.  +$data_ref = $Response->TrapInclude('file.inc') API
  7688.   extension which allows for easy post processing of
  7689.   data from includes
  7690.  
  7691.  +./site/eg/source.inc syntax highlighting improvements
  7692.  
  7693.  +XMLSubsMatch compile time parsing performance improvement
  7694.  
  7695. =item $VERSION = 2.00; $DATE="07/15/2000";
  7696.  
  7697.  -UniquePackages config works again, broke a couple versions back
  7698.  
  7699.  +better error handling for methods called on $Application
  7700.   that don't exist, hard to debug before
  7701.  
  7702. =item $VERSION = 1.95; $DATE="07/10/2000";
  7703.  
  7704.  !!!!! EXAMPLES SECURITY BUG FOUND & FIXED !!!!!
  7705.  
  7706.  --FIXED: distribution example ./site/eg/source.asp now parses 
  7707.   out special characters of the open() call when reading local 
  7708.   files.
  7709.  
  7710.   This bug would allow a malicious user possible writing
  7711.   of files in the same directory as the source.asp script.  This
  7712.   writing exploit would only have effect if the web server user
  7713.   has write permission on those files.
  7714.  
  7715.   Similar bug announced by openhack.org for minivend software
  7716.   in story at: 
  7717.     http://www.zdnet.com/eweek/stories/general/0,11011,2600258,00.html
  7718.  
  7719.   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  7720.  
  7721.  -$0 now set to transferred file, when using $Server->Transfer
  7722.  
  7723.  -Fix for XMLSubsMatch parsing on cases with 2 or more args passed
  7724.   to tag sub that was standalone like 
  7725.     <Apps:header type="header" title="Moo" foo="moo" />
  7726.  
  7727. =item $VERSION = 1.93; $DATE="07/03/2000";
  7728.  
  7729.  -sub second timing with Time::HiRes was adding <!-- -->
  7730.   comments by HTML by default, which would possibly
  7731.   break specific programs looking for precise HTML output.
  7732.   Now this behavior must be explicitly turned on with
  7733.   the TimeHiRes config setting.
  7734.  
  7735.   These comments will only appear in HTML only if 
  7736.   Debug is enabled as well.
  7737.  
  7738.   Timed log entries will only occur if 
  7739.   system debugging is enabled, with Debug -1 or -2
  7740.  
  7741. =item $VERSION = 1.91; $DATE="07/02/2000";
  7742.  
  7743.  +Documented XMLSubsMatch & XSLT* configuration
  7744.   settings in CONFIG section.
  7745.  
  7746.  +XSLT XSL template is now first executed as an 
  7747.   ASP script just like the XML scripts.  This is 
  7748.   just one step away now from implementing XSP logic.
  7749.  
  7750.  +$Server->Execute and $Server->Transfer API extensions
  7751.   implemented.  Execute is the same as $Request->Include()
  7752.   and $Server->Transfer is like an apache internal redirect
  7753.   but keeps the current ASP objects for the next script.
  7754.  
  7755.   Added examples, transfer.htm, and modified dynamic_includes.htm.
  7756.  
  7757.  +Better compile time error debugging with Debug 2 or -2.
  7758.   Will hilite/link the buggy line for global.asa errors, 
  7759.   include errors, and XML/XSLT errors just like with 
  7760.   ASP scripts before.
  7761.  
  7762.  +Nice source hiliting when viewing source for the example
  7763.   scripts.
  7764.  
  7765.  +Runtime string writing optimization for static HTML going
  7766.   through $Response.
  7767.  
  7768.  +New version numbering just like everyone else.  Starting at 1.91
  7769.   since I seem to be off by a factor of 10, last release would have
  7770.   been 1.9.
  7771.  
  7772. =item $VERSION = 0.19; $DATE="NOT RELEASED";
  7773.  
  7774.  +XMLSubsMatch and XSLT* settings documented in 
  7775.   the XML/XSLT section of the site/README.
  7776.  
  7777.  -XMLSubsMatch will strip parens in a pattern match
  7778.   so it does not interfere with internal matching use.
  7779.  
  7780.  +XSLT integration allowing XML to be rendered by XSLT
  7781.   on the fly.  XSLT specifies XSL file to transform XML.
  7782.   XSLTMatch is a regexp that matches XML file names, like \.xml$,
  7783.   which will be transformed by XSLT setting, default .*
  7784.   
  7785.   XSLTCacheSize when specified uses Tie::Cache to cached XML DOMs 
  7786.   internally and cache XSLT transformations output per XML/XSL 
  7787.   combination.  XML DOM objects can take a lot of RAM, so use
  7788.   this setting judiciously like setting to 100.  Definitely 
  7789.   experiment with this value.
  7790.  
  7791.  +More client info in the error mail feature, including
  7792.   client IP, form data, query string, and HTTP_* client headers
  7793.  
  7794.  +With Time::HiRes loaded, and Debug set to non 0, 
  7795.   will add a <!-- Apache::ASP served request in xx.xx seconds -->
  7796.   to text/html output, similar to Cocoon, per user request  
  7797.   Will also add this to the system debug error log output
  7798.   when Debug is < 0
  7799.  
  7800.  -bug fix on object initialization optimization earlier
  7801.   in this release, that was introduced for faster event
  7802.   handler execution.
  7803.  
  7804.  +Apache::ASP::Parse() takes a file name, scalar, or
  7805.   scalar ref for arguments of data to parse for greater
  7806.   integration ability with other applications.
  7807.  
  7808.  +PodComments optimization, small speed increase at
  7809.   compilation time.
  7810.  
  7811.  +String optimization on internal rendering that avoids 
  7812.   unnecessary copying of static html, by using refs.  Should 
  7813.   make a small difference on sites with large amounts of 
  7814.   static html.
  7815.  
  7816.  +CompressGzip setting which, when Compress::Zlib is installed,
  7817.   will compress text/html automatically going out to the web
  7818.   browser if the client supports gzip encoding.
  7819.  
  7820.  ++Script_OnFlush event handler, and auxiliary work optimizing
  7821.   asp events in general.  $Response->{BinaryRef} created which
  7822.   is a reference to outgoing output, which can be used 
  7823.   to modify the data at runtime before it goes out to the client. 
  7824.  
  7825.  +Some code optimizations that boost speed from 22 to 24 
  7826.   hits per second when using Sessions without $Application,
  7827.   on a simple hello world benchmark on a WinNT PII300.
  7828.  
  7829.  ++Better SessionManagement, more aware of server farms that 
  7830.   don't have reliable NFS locking.  The key here is to have only
  7831.   one process on one server in charge of session garbage collection
  7832.   at any one time, and try to create this situation with a snazzy
  7833.   CleanupMaster routine.  This is done by having a process register
  7834.   itself in the internal database with a server key created at
  7835.   apache start time.  If this key gets stale, another process can 
  7836.   become the master, and this period will not exceed the period
  7837.   SessionTimeout / StateManager.
  7838.  
  7839.   ** Work on session manager sponsored by LRN, http://www.lrn.com.  **
  7840.   ** This work was used to deploy a server farm in production with  **
  7841.   ** NFS mounted StateDir. Thanks to Craig Samuel for his belief in **
  7842.   ** open source. :)                                                **
  7843.  
  7844.   Future work for server farm capabilities might include breaking
  7845.   up the internal database into one of 256 internal databases 
  7846.   hashed by the first 2 chars of the session id.  Also on the plate
  7847.   is Apache::Session like abilities with locking and/or data storage
  7848.   occuring in a SQL database.  The first dbs to be done will include
  7849.   MySQL & Oracle.
  7850.  
  7851.  +Better session security which will create a new session id for an 
  7852.   incoming session id that does not match one already seen.  This will
  7853.   help for those with Search engines that have bookmarked
  7854.   pages with the session ids in the query strings.  This breaks away
  7855.   from standard ASP session id implementation which will automatically
  7856.   use the session id presented by the browser, now a new session id will
  7857.   be returned if the presented one is invalid or expired.
  7858.  
  7859.  -$Application->GetSession will only return a session if
  7860.   one already existed.  It would create one before by default.
  7861.  
  7862.  +Script_OnFlush global.asa event handler, and $Response->{BinaryRef}
  7863.   member which is a scalar reference to the content about to be flushed.
  7864.   See ./site/eg/global.asa for example usage, used in this case to
  7865.   insert font tags on the fly into the output.
  7866.  
  7867.  +Highlighting and linking of line error when Debug is set to 2 or -2.
  7868.  
  7869.  --removed fork() call from flock() backup routine? How did 
  7870.    that get in there?  Oh right, testing on Win32. :(
  7871.    Very painful lesson this one, sorry to whom it may concern.
  7872.  
  7873.  +$Application->SessionCount support turned off by default
  7874.   must enable with SessionCount config option.  This feature
  7875.   puts an unnecessary load on busy sites, so not default 
  7876.   behavior now.  
  7877.  
  7878.  ++XMLSubsMatch setting that allows the developer to 
  7879.   create custom tags XML style that execute perl subroutines.
  7880.   See ./site/eg/xml_subs.asp
  7881.  
  7882.  +MailFrom config option that defaults the From: field for 
  7883.   mails sent via the Mail* configs and $Server->Mail()
  7884.  
  7885.  +$Server->Mail(\%mail, %smtp_args) API extension
  7886.  
  7887.  +MailErrorsTo & MailAlertTo now can take comma
  7888.   separated email addresses for multiple recipients.
  7889.  
  7890.  -tracking of subroutines defined in scripts and includes so 
  7891.   StatINC won't undefine them when reloading the GlobalPackage, 
  7892.   and so an warning will be logged when another script redefines 
  7893.   the same subroutine name, which has been the bane of at least
  7894.   a few developers.
  7895.  
  7896.  -Loader() will now recompile dynamic includes that 
  7897.   have changed, even if main including script has not.
  7898.   This is useful if you are using Loader() in a 
  7899.   PerlRestartHandler, for reloading scripts when
  7900.   gracefully restarting apache.
  7901.  
  7902.  -Apache::ASP used to always set the status to 200 by 
  7903.   default explicitly with $r->status().  This would be 
  7904.   a problem if a script was being used to as a 404 
  7905.   ErrorDocument, because it would always return a 200 error
  7906.   code, which is just wrong.  $Response->{Status} is now 
  7907.   undefined by default and will only be used if set by 
  7908.   the developer.  
  7909.  
  7910.   Note that by default a script will still return a 200 status, 
  7911.   but $Response->{Status} may be used to override this behavior.
  7912.  
  7913.  +$Server->Config($setting) API extension that allows developer
  7914.   to access config settings like Global, StateDir, etc., and is a 
  7915.   wrapper around Apache->dir_config($setting)
  7916.  
  7917.  +Loader() will log the number of scripts
  7918.   recompiled and the number of scripts checked, instead
  7919.   of just the number of scripts recompiled, which is
  7920.   misleading as it reports 0 for child httpds after
  7921.   a parent fork that used Loader() upon startup.      
  7922.  
  7923.  -Apache::ASP->Loader() would have a bad error if it didn't load 
  7924.   any scripts when given a directory, prints "loaded 0 scripts" now
  7925.  
  7926. =item $VERSION = 0.18; $DATE="02/03/2000";
  7927.  
  7928.  +Documented SessionQuery* & $Server->URL() and 
  7929.   cleaned up formatting some, as well as redoing
  7930.   some of the sections ordering for better readability.
  7931.   Document the cookieless session functionality more
  7932.   in a new SESSIONS section.  Also documented new 
  7933.   FileUpload configs and $Request->FileUpload collection.
  7934.   Documented StatScripts.
  7935.  
  7936.  +StatScripts setting which if set to 0 will not reload
  7937.   includes, global.asa, or scripts when changed.
  7938.  
  7939.  +FileUpload file handles cleanup at garbage collection
  7940.   time so developer does not have to worry about lazy coding
  7941.   and undeffing filehandles used in code.  Also set 
  7942.   uploaded filehandles to binmode automatically on Win32 
  7943.   platforms, saving the developer yet more typing.
  7944.  
  7945.  +FileUploadTemp setting, default 0, if set will leave
  7946.   a temp file on disk during the request, which may be 
  7947.   helpful for processing by other programs, but is also
  7948.   a security risk in that others could potentially read 
  7949.   this file while the script is running. 
  7950.  
  7951.   The path to the temp file will be available at
  7952.   $Request->{FileUpload}{$form_field}{TempFile}.
  7953.   The regular use of file uploads remains the same
  7954.   with the <$filehandle> to the upload at 
  7955.   $Request->{Form}{$form_field}.
  7956.  
  7957.  +FileUploadMax setting, default 0, currently an 
  7958.   alias for $CGI::POST_MAX, which determines the 
  7959.   max size for a file upload in bytes.  
  7960.  
  7961.  +SessionQueryParse only auto parses session-ids
  7962.   into links when a session-id COOKIE is NOT found.
  7963.   This feature is only enabled then when a user has
  7964.   disabled cookies, so the runtime penalty of this
  7965.   feature won't drag down the whole site, since most
  7966.   users will have cookies turned on.   
  7967.  
  7968.  -StatINC & StatINCMatch will not undef Fnctl.pm flock 
  7969.   functions constants like O_RDWR, because the code references
  7970.   are not well trackable.  This would result in sporadic 500 server
  7971.   errors when a changed module was reloaded that imported O_* flock 
  7972.   functions from Fnctl.
  7973.  
  7974.  +SessionQueryParse & SessionQueryParseMatch
  7975.   settings that enable auto parsing session ids into 
  7976.   URLs for cookieless sessions.  Will pick up URLs in 
  7977.   <a href>, <area href>, <form action>, <frame src>,
  7978.   <iframe src>, <img src>, <input src>, <link href>
  7979.   $Response->Redirect($URL) and the first URL in 
  7980.   script tags like <script>*.location.href=$URL</script>
  7981.  
  7982.   These settings require that buffering be enabled, as
  7983.   Apache::ASP will parse through the buffer to parse the URLs.
  7984.  
  7985.   With SessionQueryParse on, it will just parse non-absolute
  7986.   URLs, but with SessionQueryParseMatch set to some server
  7987.   url regexp, like ^http://localhost , will also parse
  7988.   in the session id for URLs that match that.
  7989.  
  7990.   When testing, the performance hit from this parsing
  7991.   a script dropped from 12.5 hits/sec on my WinNT box
  7992.   to 11.7 hits per second for 1K of buffered output.
  7993.   The difference is .007 of my PII300's processing power
  7994.   per second.
  7995.  
  7996.   For 10K of output then, my guess is that this speed
  7997.   of script, would be slowed to 6.8 hits per second.
  7998.   This kind of performance hit would also slow a
  7999.   script running at 40 hits per second on a UNIX box
  8000.   to 31 hits/sec for 1K, and to 11 hits/sec for 10K parsed.
  8001.  
  8002.   Your mileage may vary and you will have to test the difference
  8003.   yourself.  Get yourself a valid URL with a session-id in
  8004.   it, and run it through ab, or Socrates, with SessionQuery
  8005.   turned on, and then with SessionQueryParse set to see 
  8006.   the difference.  SessionQuery just enables of session id
  8007.   setting from the query string but will not auto parse urls.
  8008.  
  8009.  -If buffering, Content-Length will again be set.
  8010.   It broke, probably while I was tuning in the past 
  8011.   couple versions.
  8012.  
  8013.  +UseStrict setting compiles all scripts including
  8014.   global.asa with "use strict" turned on for catching
  8015.   more coding errors.  With this setting enabled,
  8016.   use strict errors die during compilation forcing
  8017.   Apache::ASP to try to recompile the script until
  8018.   successful.
  8019.  
  8020.  -Object use in includes like $Response->Write() 
  8021.   no longer error with "use strict" programming.  
  8022.  
  8023.  +SessionQuery config setting with $Server->URL($url, { %params } ) 
  8024.   alpha API extensions to enable cookieless sessions.
  8025.  
  8026.  +Debugging not longer produces internal debugging
  8027.   by default.  Set to -1,-2 for internal debugging
  8028.   for Debug settings 1 & 2.
  8029.  
  8030.  +Both StateSerializer & StateDB can be changed 
  8031.   without affecting a live web site, by storing 
  8032.   the configurations for $Application & $Session 
  8033.   in an internal database, so that if $Session was
  8034.   created with SDBM_File for the StateDB (default),
  8035.   it will keep this StateDB setting until it ends.
  8036.  
  8037.  +StateSerializer config setting.  Default Data::Dumper,
  8038.   can also be set to Storable.  Controls how data is
  8039.   serialized before writing to $Application & $Session.
  8040.  
  8041.  +Beefed up the make test suite.
  8042.  
  8043.  +Improved the locking, streamlining a bit of the 
  8044.   $Application / $Session setup process.  Bench is up to 
  8045.   22 from 21 hits / sec on dev NT box.
  8046.  
  8047.  +Cut more fat for faster startup, now on my dev box 
  8048.   I get 44 hits per sec Apache::ASP vs. 48 Embperl 
  8049.   vs. 52 CGI via Apache::Registry for the HelloWorld Scripts.
  8050.  
  8051.  -Improved linking for the online site documentation, 
  8052.   where a few links before were bad.
  8053.  
  8054. =item $VERSION = 0.17; $DATE="11/15/99";
  8055.  
  8056.  ++20%+ faster startup script execution, as measured by the 
  8057.   HelloWorld bench.  I cut a lot of the fat out of 
  8058.   the code, and is now at least 20% faster on startup 
  8059.   both with and without state.
  8060.  
  8061.   On my dev (NT, apache 1.3.6+mod_perl) machine, I now get:
  8062.  
  8063.     42 hits per sec on Apache::ASP HelloWorld bench
  8064.     46 hits per sec on Embperl (1.2b10) and
  8065.     51 hits per sec for CGI Apache::Registry scripts  
  8066.  
  8067.   Before Apache::ASP was clocking some 31 hits per sec.
  8068.   Apache::ASP also went from 75 to 102 hits per second 
  8069.   on Solaris.
  8070.  
  8071.  +PerlTaintCheck On friendly.  This is mod_perl's way 
  8072.   of providing -T taint checking.  When Apache::ASP
  8073.   is used with state objects like $Session or $Application,
  8074.   MLDBM must also be made taint friendly with:
  8075.  
  8076.     $MLDBM::RemoveTaint = 1;
  8077.  
  8078.   which could be put in the global.asa.  Documented.
  8079.  
  8080.  +Added $Response->ErrorDocument($error_code, $uri_or_string) 
  8081.   API extension which allows for setting of Apache's error
  8082.   document at runtime.  This is really just a wrapper 
  8083.   for Apache->custom_response() renamed so it syncs with
  8084.   the Apache ErrorDocument config setting.  Updated
  8085.   documentation, and added error_document.htm example.
  8086.  
  8087.  =OrderCollections setting was added, but then REMOVED
  8088.   because it was not going to be used.  It bound 
  8089.   $Request->* collections/hashes to Tie::IxHash, so that data
  8090.   in those collections would be read in the order the 
  8091.   browser sent it, when eaching through or with keys.
  8092.  
  8093.  -global.asa will be reloaded when changed.  This broke
  8094.   when I optimized the modification times with (stat($file))[9]
  8095.   rather than "use File::stat; stat($file)->mtime"
  8096.  
  8097.  -Make Apache::ASP->Loader() PerlRestartHandler safe,
  8098.   had some unstrict code that was doing the wrong thing.
  8099.  
  8100.  -IncludesDir config now works with DynamicIncludes.
  8101.  
  8102.  +DebugBufferLength feature added, giving control to 
  8103.   how much buffered output gets shown when debugging errors.
  8104.  
  8105.  ++Tuning of $Response->Write(), which processes all
  8106.   static html internally, to be almost 50% faster for
  8107.   its typical use, when BufferingOn is enabled, and 
  8108.   CgiHeaders are disabled, both being defaults.
  8109.  
  8110.   This can show significant speed improvements for tight
  8111.   loops that render ASP output.
  8112.  
  8113.  +Auto linking of ./site/eg/ text to example scripts
  8114.   at web site.
  8115.  
  8116.  +$Application->GetSession($session_id) API extension, useful
  8117.   for managing active user sessions when storing session ids
  8118.   in $Application.  Documented.
  8119.  
  8120.  -disable use of flock() on Win95/98 where it is unimplemented
  8121.  
  8122.  -@array context of $Request->Form('name') returns
  8123.   undef when value for 'name' is undefined.  Put extra
  8124.   logic in there to make sure this happens. 
  8125.  
  8126. =item $VERSION = 0.16; $DATE="09/22/99";
  8127.  
  8128.  -$Response->{Buffer} and PerlSetVar BufferingOn
  8129.   configs now work when set to 0, to unbuffer output,
  8130.   and send it out to the web client as the script generates it.
  8131.  
  8132.   Buffering is enabled by default, as it is faster, and
  8133.   allows a script to error cleanly in the middle of execution.  
  8134.  
  8135.  +more bullet proof loading of Apache::Symbol, changed the 
  8136.   way Apache::ASP loads modules in general.  It used to 
  8137.   check for the module to load every time, if it hadn't loaded
  8138.   successfully before, but now it just tries once per httpd,
  8139.   so the web server will have to be restarted to see new installed
  8140.   modules.  This is just for modules that Apache::ASP relies on.
  8141.  
  8142.   Old modules that are changed or updated with an installation
  8143.   are still reloaded with the StatINC settings if so configured. 
  8144.  
  8145.  +ASP web site wraps <font face="courier new"> around <pre>
  8146.   tags now to override the other font used for the text
  8147.   areas.  The spacing was all weird in Netscape before
  8148.   for <pre> sections.
  8149.  
  8150.  -Fixed Content-Length calculation when using the Clean
  8151.   option, so that the length is calculated after the HTML
  8152.   is clean, not before.  This would cause a browser to 
  8153.   hang sometimes.
  8154.  
  8155.  +Added IncludesDir config option that if set will also be
  8156.   used to check for includes, so that includes may easily be
  8157.   shared between applications.  By default only Global and 
  8158.   the directory the script is in are checked for includes.
  8159.  
  8160.   Also added IncludesDir as a possible configuration option
  8161.   for Apache::ASP->Loader()
  8162.  
  8163.  -Re-enabled the Application_OnStart & OnEnd events, after
  8164.   breaking them when implementing the AllowApplicationState
  8165.   config setting.
  8166.  
  8167.  +Better pre-fork caching ... StatINC & StatINCMatch are now 
  8168.   args for Apache::ASP->Loader(), so StatINC symbols loading
  8169.   may be done pre-fork and shared between httpds.  This lowers
  8170.   the child httpd init cost of StatINC.  Documented.
  8171.  
  8172.  +Made Apache::ASP Basic Authorization friendly so authentication
  8173.   can be handled by ASP scripts.  If AuthName and AuthType Apache
  8174.   config directives are set, and a $Response->{Status} is set to 
  8175.   401, a user will be prompted for username/password authentication
  8176.   and the entered data will show up in ServerVariables as:
  8177.     $env = $Request->ServerVariables
  8178.     $env->{REMOTE_USER} = $env->{AUTH_USER} = username
  8179.     $env->{AUTH_PASSWD} = password
  8180.     $env->{AUTH_NAME}   = your realm
  8181.     $env->{AUTH_TYPE}   = 'Basic'
  8182.  
  8183.   This is the same place to find auth data as if Apache had some 
  8184.   authentication handler deal with the auth phase separately.
  8185.  
  8186.  -MailErrorsTo should report the right file now that generates
  8187.   the error.
  8188.  
  8189. =item $VERSION = 0.15; $DATE="08/24/1999";
  8190.  
  8191.  --State databases like $Session, $Application are 
  8192.   now tied/untied to every lock/unlock triggered by read/write 
  8193.   access.  This was necessary for correctness issues, so that 
  8194.   database file handles are flushed appropriately between writes
  8195.   in a highly concurrent multi-process environment.
  8196.  
  8197.   This problem raised its ugly head because under high volume, 
  8198.   a DB_File can become corrupt if not flushed correctly.  
  8199.   Unfortunately, there is no way to flush SDBM_Files & DB_Files 
  8200.   consistently other than to tie/untie the databases every access.
  8201.  
  8202.   DB_File may be used optionally for StateDB, but the default is
  8203.   to use SDBM_File which is much faster, but limited to 1024 byte
  8204.   key/value pairs.
  8205.  
  8206.   For SDBM_Files before, if there were too many concurrent 
  8207.   writes to a shared database like $Application, some of the 
  8208.   writes would not be saved because another process
  8209.   might overwrite the changes with its own.
  8210.  
  8211.   There is now a 10 fold performance DECREASE associated
  8212.   with reading from and writing to files like $Session 
  8213.   and $Application.  With rough benchmarks I can get about
  8214.   100 increments (++) now per second to $Session->{count}, where
  8215.   before I could get 1000 increments / second.  
  8216.  
  8217.   You can improve this if you have many reads / writes happening
  8218.   at the same time, by placing locking code around the group like
  8219.   
  8220.     $Session->Lock();
  8221.     $Session->{count}++;
  8222.     $Session->{count}++;
  8223.     $Session->{count}++;
  8224.     $Session->UnLock();    
  8225.  
  8226.   This method will reduce the number of ties to the $Session database
  8227.   from 6 to 1 for this kind of code, and will improve the performance
  8228.   dramatically.
  8229.  
  8230.   Also, instead of using explicit $Session locking, you can 
  8231.   create an automatic lock on $Session per script by setting
  8232.   SessionSerialize in your config to 1.  The danger here is
  8233.   if you have any long running scripts, the user will have
  8234.   to wait for it to finish before another script can be run.
  8235.  
  8236.   To see the number of lock/unlocks or ties/unties to each database
  8237.   during a script execution, look at the last lines of debug output
  8238.   to your error log when Debug is set to 1.  This can help you
  8239.   performance tweak access to these databases.
  8240.  
  8241.  +Updated documentation with new config settings and
  8242.   API extensions.
  8243.  
  8244.  +Added AllowApplicationState config option which allows
  8245.   you to leave $Application undefined, and will not
  8246.   execute Application_OnStart or Application_OnEnd.
  8247.   This can be a slight performance increase of 2-3% if
  8248.   you are not using $Application, but are using $Session.
  8249.  
  8250.  +Added $Session->Lock() / $Session->UnLock() API routines
  8251.   necessary additions since access to session is not
  8252.   serialized by default like IIS ASP.  Also prompted
  8253.   by change in locking code which retied to SDBM_File
  8254.   or DB_File each lock.  If you $Session->Lock / UnLock
  8255.   around many read/writes, you will increase performance.
  8256.  
  8257.  +Added StateCache config which, if set will cache
  8258.   the file handle locks for $Application and an internal 
  8259.   database used for tracking $Session info.  This caching can 
  8260.   make an ASP application perform up to 10% faster,
  8261.   at a cost of each web server process holding 2 more 
  8262.   cached file handles open, per ASP application using
  8263.   this configuration.  The data written to or read from
  8264.   these state databases is not cached, just the locking 
  8265.   file handles are held open.
  8266.  
  8267.  -Added in much more locking in session manager 
  8268.   and session garbage collector to help avoid collisions
  8269.   between the two.  There were definite windows that the
  8270.   two would collide in, during which bad things could 
  8271.   happen on a high volume site.
  8272.  
  8273.  -Fixed some warnings in DESTROY and ParseParams()
  8274.  
  8275. =item $VERSION = 0.14; $DATE="07/29/1999";
  8276.  
  8277.  -CGI & StatINC or StatINCMatch would have bad results
  8278.   at times, with StatINC deleting dynamically compiled
  8279.   CGI subroutines, that were imported into other scripts
  8280.   and modules namespaces.
  8281.  
  8282.   A couple tweaks, and now StatINC & CGI play nice again ;)
  8283.   StatINCMatch should be safe to use in production with CGI. 
  8284.   This affects in particular environments that use file upload, 
  8285.   since CGI is loaded automatically by Apache::ASP to handle 
  8286.   file uploads.
  8287.  
  8288.   This fix should also affect other seemingly random 
  8289.   times when StatINC or StatINCMatch don't seem to do 
  8290.   the right thing.
  8291.  
  8292.  +use of ASP objects like $Response are now "use strict"
  8293.   safe in scripts, while UniquePackages config is set.
  8294.  
  8295.  +Better handling of "use strict" errors in ASP scripts.
  8296.   The error is detected, and the developer is pointed to the 
  8297.   Apache error log for the exact error.  
  8298.  
  8299.   The script with "use strict" errors will be recompiled again.  Its seems 
  8300.   though that "use strict" will only throw its error once, so that a script 
  8301.   can be recompiled with the same errors, and work w/o any use strict
  8302.   error messaging.  
  8303.  
  8304. =item $VERSION = 0.12; $DATE="07/01/1999";
  8305.  
  8306.  -Compiles are now 10 +times faster for scripts with lots of big
  8307.   embedded perl blocks <% #perl %>
  8308.  
  8309.   Compiles were slow because of an old PerlScript compatibility
  8310.   parsing trick where $Request->QueryString('hi')->{item}
  8311.   would be parsed to $Request->QueryString('hi') which works.
  8312.   I think the regexp that I was using had O(n^2) characteristics
  8313.   and it took a really big perl block to 10 +seconds to parse
  8314.   to understand there was a problem :(
  8315.  
  8316.   I doubt anyone needed this compatibility, I don't even see
  8317.   any code that looks like this in the online PerlScript examples,
  8318.   so I've commented out this parsing trick for now.  If you 
  8319.   need me to bring back this functionality, it will be in the 
  8320.   form of a config setting.
  8321.  
  8322.   For information on PerlScript compatibility, see the PerlScript
  8323.   section in the ASP docs.
  8324.  
  8325.  -Added UniquePackages config option, that if set brings back 
  8326.   the old method of compiling each ASP script into its own
  8327.   separate package.  As of v.10, scripts are compiled by default
  8328.   into the same package, so that scripts, dynamic includes & global.asa
  8329.   can share globals.  This BROKE scripts in the same ASP Application
  8330.   that defined the same sub routines, as their subs would redefine
  8331.   each other.  
  8332.  
  8333.   UniquePackages has scripts compiled into separate perl packages,
  8334.   so they may define subs with the same name, w/o fear of overlap.
  8335.   Under this settings, scripts will not be able to share globals.  
  8336.  
  8337.  -Secure field for cookies in $Response->Cookies() must be TRUE to 
  8338.   force cookie to be secure.  Before, it just had to be defined, 
  8339.   which gave wrong behavior for Secure => 0. 
  8340.  
  8341.  +$Response->{IsClientConnected} set to one by default.  Will
  8342.   work out a real value when I upgrade to apache 1.3.6.  This
  8343.   value has no meaning before, as apache aborts the perl code
  8344.   when a client drops its connection in earlier versions.
  8345.  
  8346.  +better compile time debugging of dynamic includes, with 
  8347.   Debug 2 setting
  8348.  
  8349.  +"use strict" friendly handling of compiling dynamic includes
  8350.   with errors
  8351.  
  8352. =item $VERSION = 0.11; $DATE="06/24/1999";
  8353.  
  8354.  +Lots of documentation updates
  8355.  
  8356.  +The MailHost config option is the smtp server used for 
  8357.   relay emails for the Mail* config options.
  8358.  
  8359.  +MailAlertTo config option used for sending a short administrative
  8360.   alert for an internal ASP error, server code 500.  This is the 
  8361.   compliment to MailErrorsTo, but is suited for sending a to a
  8362.   small text based pager.  The email sent by MailErrorsTo would
  8363.   then be checked by the web admin for quick response & debugging
  8364.   for the incident. 
  8365.  
  8366.   The MailAlertPeriod config specifies the time in minutes during 
  8367.   which only one alert will be sent, which defaults to 20.
  8368.  
  8369.  +MailErrorsTo config options sends the results of a 500 error
  8370.   to the email address specified as if Debug were set to 2.
  8371.   If Debug 2 is set, this config will not be on, as it is
  8372.   for production use only.  Debug settings less than 2 only 
  8373.   log errors to the apache server error log.
  8374.  
  8375.  -StatINCMatch / StatINC can be used in production and work
  8376.   even after a server graceful restart, which is essential for 
  8377.   a production server.
  8378.  
  8379.  -Content-Length header is set again, if BufferingOn is set, and
  8380.   haven't $Response->Flush()'d.  This broke when I introduce
  8381.   the Script_OnEnd event handler.
  8382.  
  8383.  +Optimized reloading of the GlobalPackage perl module upon changes, 
  8384.   so that scripts and dynamic includes don't have to be recompiled.  
  8385.   The global.asa will still have to be though.  Since we started
  8386.   compiling all routines into a package that can be named with
  8387.   GlobalPackage, we've been undeffing compiled scripts and includes
  8388.   when the real GlobalPackage changed on disk, as we do a full sweep
  8389.   through the namespace.  Now, we skip those subs that we know to 
  8390.   be includes or scripts. 
  8391.  
  8392.  -Using Apache::Symbol::undef() to undefine precompiled scripts
  8393.   and includes when reloading those scripts.  Doing just an undef() 
  8394.   would sometimes result in an "active subroutine undef" error.
  8395.   This bug came out when I started thrashing the StatINC system
  8396.   for production use.
  8397.  
  8398.  +StatINCMatch setting created for production use reloading of
  8399.   perl modules.  StatINCMatch allows StatINC reloading of a
  8400.   subset of all the modules defined in %INC, those that match
  8401.   $module =~ /$StatINCMatch/, where module is some module name
  8402.   like Class/Struct.pm
  8403.  
  8404.  +Reoptimized pod comment parsing.  I slowed it down to sync
  8405.   lines numbers in the last version, but found another corner I could cut.
  8406.  
  8407. =item $VERSION = 0.10; $DATE="05/24/1999";
  8408.  
  8409.  += improvement; - = bug fix
  8410.  
  8411.  +Added index.html file to ./eg to help people wade through
  8412.   the examples.  This one has been long overdue.
  8413.  
  8414.  +Clean config option, or setting $Response->{Clean} to 1 - 9,
  8415.   uses HTML::Clean to compress text/html output of ASP scripts.
  8416.   I like the Clean 1 setting which is lightweight, stripping 
  8417.   white space for about 10% compression, at a cost of less than
  8418.   a 5% performance penalty.
  8419.  
  8420.  +Using pod style commenting no longer confuses the line
  8421.   numbering.  ASP script line numbers are almost exactly match
  8422.   their compiled perl version, except that normal inline includes
  8423.   (not dynamic) insert extra text which can confuse line numbering.
  8424.   If you want perl error line numbers to entirely sync with your 
  8425.   ASP scripts, I would suggest learning how to use dynamic includes,
  8426.   as opposed to inline includes.
  8427.  
  8428.  -Wrapped StatINC reloading of libs in an eval, and capturing
  8429.   error for Debug 2 setting.  This makes changing libs with StatINC
  8430.   on a little more friendly when there are errors. 
  8431.  
  8432.  -$Request->QueryString() now stores multiple values for the 
  8433.   same key, just as $Request->Form() has since v.07.  In
  8434.   wantarray() context like @vals = $Request->QueryString('dupkey'),
  8435.   @vals will store whatever values where associated with dupkey
  8436.   in the query string like (1,2) from: ?dupkey=1&dupkey=2
  8437.  
  8438.  +The GlobalPackage config directive may be defined
  8439.   to explicitly set the perl module that all scripts and global.asa
  8440.   are compiled into.
  8441.  
  8442.  -Dynamic includes may be in the Global directory, just like
  8443.   normal includes.
  8444.  
  8445.  +Perl script generated from asp scripts should match line
  8446.   for line, seen in errors, except when using inline (default) 
  8447.   includes, pod comments, or <% #comment %> perl comments, which 
  8448.   will throw off the line counts by adding text, removing
  8449.   text, or having an extra newline added, respectively.
  8450.  
  8451.  -Script_OnEnd may now send output to the browser.  Before
  8452.   $main::Response->End() was being called at the end of the
  8453.   main script preventing further output.
  8454.  
  8455. ++All scripts are compiled as routines in a namespace uniquely
  8456.   defined by the global.asa of the ASP application.  Thus,
  8457.   scripts, includes, and global.asa routines will share
  8458.   all globals defined in the global.asa namespace.   This means
  8459.   that globals between scripts will be shared, and globals
  8460.   defined in a global.asa will be available to scripts.
  8461.  
  8462.   Scripts used to have their own namespace, thus globals
  8463.   were not shared between them.
  8464.  
  8465.  +a -o $output_dir switch on the ./cgi/asp script allows
  8466.   it to execute scripts and write their output to an output
  8467.   directory.  Useful for building static html sites, based on
  8468.   asp scripts.  An example use would be:
  8469.  
  8470.     asp -b -o out *.asp
  8471.  
  8472.   Without an output directory, script output is written to STDOUT
  8473.  
  8474.  
  8475. =item $VERSION = 0.09; $DATE="04/22/1999";
  8476.  
  8477.  +Updated Makefile.PL optional modules output for CGI & DB_File
  8478.  
  8479.  +Improved docs on $Response->Cookies() and $Request->Cookies()
  8480.  
  8481.  +Added PERFORMANCE doc to main README, and added sub section
  8482.   on precompiling scripts with Apache::ASP->Loader()
  8483.  
  8484.  +Naming of CompileIncludes switched over to DynamicIncludes 
  8485.   for greater clarity.
  8486.  
  8487.  +Dynamic includes can now reference ASP objects like $Session
  8488.   w/o the $main::* syntax.  These subs are no longer anonymous
  8489.   subs, and are now compiled into the namespace of the global.asa package.
  8490.  
  8491.  +Apache::ASP->Loader() precompiles dynamic includes too. Making this work
  8492.   required fixing some subtle bugs / dependencies in the compiling process.
  8493.  
  8494.  +Added Apache::ASP->Loader() similar to Apache::RegistryLoader for
  8495.   precompiling ASP scripts.  Precompile a whole site at server 
  8496.   startup with one function call.
  8497.  
  8498.  +Prettied the error messaging with Debug 2.
  8499.  
  8500.  +$Response->Debug(@args) debugging extension, which
  8501.   allows a developer to hook into the module's debugging,
  8502.   and only have @args be written to error_log when Debug is greater
  8503.   than 0.
  8504.  
  8505.  -Put write locking code around State writes, like $Session
  8506.   and $Application.  I thought I fixed this bug a while ago.
  8507.  
  8508.  -API change: converted $Session->Timeout() and $Session->SessionID() 
  8509.   methods into $Session->{Timeout} and $Session->{SessionID} properties.
  8510.   The use of these properties as methods is deprecated, but 
  8511.   backwards compatibility will remain.  Updated ./eg/session.asp
  8512.   to use these new properties.
  8513.  
  8514.  +Implemented $Response->{PICS} which if set sends out a PICS-Label
  8515.   HTTP header, useful for ratings.
  8516.  
  8517.  +Implemented $Response->{CacheControl} and $Response->{Charset} members.
  8518.   By default, CacheControl is 'private', and this value gets sent out
  8519.   every request as HTTP header Cache-Control.  Charset appends itself
  8520.   onto the content type header.
  8521.  
  8522.  +Implemented $Request->BinaryRead(), $Request->{TotalBytes},
  8523.   documented them, and updated ./eg/form.asp for an example usage. 
  8524.  
  8525.  +Implemented $Response->BinaryWrite(), documented, and created
  8526.   and example in ./eg/binary_write.htm
  8527.  
  8528.  +Implemented $Server->MapPath() and created example of its use
  8529.   in ./eg/server.htm
  8530.  
  8531.  -$Request->Form() now reads file uploads correctly with 
  8532.   the latest CGI.pm, where $Request->Form('file_field') returns
  8533.   the actual file name uploaded, which can be used as a file handle
  8534.   to read in the data.  Before, $Request->Form('file_field') would
  8535.   return a glob that looks like *Fh::filename, so to get the file
  8536.   name, you would have to parse it like =~ s/^\*Fh\:\://,
  8537.   which you no longer have to do.  As long as parsing was done as
  8538.   mentioned, the change should be backwards compatible.
  8539.  
  8540.  +Updated  +enhanced documentation on file uploads.  Created extra
  8541.   comments about it as an FAQ, and under $Response->Form(), the latter
  8542.   being an obvious place for a developer to look for it.
  8543.  
  8544.  +Updated ./eg/file_upload.asp to show use of non file form data, 
  8545.   with which we had a bug before.
  8546.  
  8547.  +Finished retieing *STDIN to cached STDIN contents, so that 
  8548.   CGI input routines may be used transparently, along side with
  8549.   use of $Request->Form()
  8550.  
  8551.  +Cleaned up and optimized $Request code
  8552.  
  8553.  +Updated documentation for CGI input & file uploads.  Created
  8554.   file upload FAQ.
  8555.  
  8556.  +Reworked ./eg/cgi.htm example to use CGI input routines
  8557.   after doing a native read of STDIN.
  8558.  
  8559.  ++Added dynamic includes with <!--include file=file args=@args-->
  8560.   extension.  This style of include is compiled as an anonymous sub & 
  8561.   cached, and then executed with @args passed to the subroutine for 
  8562.   execution.  This is include may also be rewritten as a new API 
  8563.   extension: $Response->Include('file', @args)
  8564.  
  8565.  +Added ./eg/compiled_includes.htm example documenting new dynamic includes.
  8566.  
  8567.  +Documented SSI: native file includes, and the rest with filtering 
  8568.   to Apache::SSI
  8569.  
  8570.  +Turned the documentation of Filter config to value of Off so 
  8571.   people won't cut and paste the On config by default.
  8572.  
  8573.  +Added SecureSession config option, which forces session cookie to 
  8574.   be sent only under https secured www page requests.
  8575.  
  8576.  +Added StateDB config option allows use of DB_File for $Session, since 
  8577.   default use of SDBM_File is limited.  See StateDB in README.
  8578.  
  8579.  +file include syntax w/o quotes supported like <!--#include file=test.inc-->
  8580.  
  8581.  +Nested includes are supported, with includes including each other.
  8582.   Recursive includes are detected and errors out when an include has been 
  8583.   included 100 times for a script.  Better to quit early than 
  8584.   have a process spin out of control. (PORTABLE ? probably not)
  8585.  
  8586.  +Allow <!--include file=file.inc--> notation w/o quotes around file names
  8587.  
  8588.  -PerlSetEnv apache conf setting now get passed through to 
  8589.   $Request->ServerVariables. This update has ServerVariables 
  8590.   getting data from %ENV instead of $r->cgi_env
  8591.  
  8592.  +README FAQ for PerlHandler errors
  8593.  
  8594.  
  8595. =item $VERSION = 0.08; $DATE="02/06/1999";
  8596.  
  8597.  ++SSI with Apache::Filter & Apache::SSI, see config options & ./eg files
  8598.   Currently filtering only works in the direction Apache::ASP -> Apache::SSI,
  8599.   will not work the other way around, as SSI must come last in a set of filters
  8600.  
  8601.  +SSI file includes may reference files in the Global directory, better 
  8602.   code sharing
  8603.  
  8604.  - <% @array... %> no longer dropped from code.
  8605.  
  8606.  +perl =pod comments are stripped from script before compiling, and associated
  8607.   PodComments configuration options.
  8608.  
  8609.  +Command line cgi/asp script takes various options, and allows execution
  8610.   of multiple asp scripts at one time.  This script should be used for
  8611.   command line debugging.  This is also the beginning of building
  8612.   a static site from asp scripts with the -b option, suppressing headers.
  8613.  
  8614.  +$Response->AddHeader('Set-Cookie') works for multiple cookies.
  8615.  
  8616.  -$Response->Cookies('foo', '0') works, was dropping 0 because of boolean test
  8617.  
  8618.  -Fixed up some config doc errors.
  8619.  
  8620.  
  8621. =item $VERSION = 0.07; $DATE="01/20/1999";
  8622.  
  8623.  -removed SIG{__WARN__} handler, it was a bad idea.
  8624.  
  8625.  -fixes file locking on QNX, work around poor flock porting
  8626.  
  8627.  +removed message about Win32::OLE on UNIX platforms from Makefile.PL
  8628.  
  8629.  -Better lock garbage collection.  Works with StatINC seamlessly.
  8630.  
  8631.  -Multiple select forms now work in array context with $Response->Form()
  8632.     @values = $Response->Form('multi');
  8633.  
  8634.  -Better CGI.pm compatibility with $r->header_out('Content-type'),
  8635.   improved garbage collection under modperl, esp. w/ file uploads
  8636.  
  8637.  
  8638. =item $VERSION = 0.06; $DATE="12/21/1998";
  8639.  
  8640.  +Application_OnStart & Application_OnEnd event handlers support.
  8641.  
  8642.  -Compatible with CGI.pm 2.46 headers() 
  8643.  
  8644.  -Compatible with CGI.pm $q = new CGI({}), caveat: does not set params 
  8645.  
  8646.  +use strict; followed by use of objects like $Session is fine.
  8647.  
  8648.  -Multiple cookies may be set per script execution.
  8649.  
  8650.  +file upload implemented via CGI.pm
  8651.  
  8652.  ++global.asa implemented with events Session_OnStart and Session_OnEnd
  8653.   working appropriately.
  8654.  
  8655.  +StateDir configuration directive implemented.
  8656.   StateDir allows the session state directory to be specified separately 
  8657.   from the Global directory, useful for operating systems with caching file 
  8658.   systems.
  8659.  
  8660.  +StateManager config directive.  StateManager specifies how frequently
  8661.   Sessions are cleaned up, with 10 (default) meaning that old Sessions
  8662.   will be cleaned up 10 times per SessionTimeout period (default 20 minutes).
  8663.  
  8664.  +$Application->SessionCount() implemented, non-portable method.
  8665.     : returns the number of currently active sessions
  8666.  
  8667.  -STOP button fix.  Users may hit STOP button during script 
  8668.   execution, and Apache::ASP will cleanup with a routine registered
  8669.   in Apache's $r->register_cleanup.  Works well supposedly.
  8670.  
  8671.  +PerlScript compatibility work, trying to make ports smoother.
  8672.     : Collection emulator, no ->{Count} property
  8673.     : $.*(.*)->{Item} parsed automatically, 
  8674.       shedding the ->{Item} for Collection support (? better way ?)
  8675.     : No VBScript dates support, just HTTP RFC dates with HTTP::Date
  8676.     : Win32::OLE::in not supported, just use "keys %{$Collection}"    
  8677.  
  8678.  +./cgi/asp script for testing scripts from the command line
  8679.     : will be upgraded to CGI method of doing asp
  8680.     : is not "correct" in anyway, so not documented for now
  8681.       but still useful
  8682.  
  8683.  +strips DOS carriage returns from scripts automatically, so that
  8684.   programs like FrontPage can upload pages to UNIX servers
  8685.   without perl choking on the extra \r characters.
  8686.  
  8687.  
  8688. =item $VERSION = 0.05; $DATE="10/19/1998";
  8689.  
  8690.  +Added PERFORMANCE doc, which includes benchmarks  +hints.
  8691.  
  8692.  +Better installation warnings and errors for other modules required. 
  8693.  
  8694.  -Turned off StatINC in eg/.htaccess, as not everyone installs Devel::Symdump
  8695.  
  8696.  -Fixed AUTOLOAD state bug, which wouldn't let you each through state
  8697.   objects, like %{$Session}, or each %$Session, (bug introduced in v.04)
  8698.  
  8699.  +Parses ASP white space better.  HTML output matches author's intent
  8700.   by better dealing with white space surrounding <% perl blocks %>
  8701.  
  8702.  -Scalar insertion code <%=$foo%> can now span many lines.
  8703.  
  8704.  +Added include.t test script for includes.
  8705.  
  8706.  +Script recompiles when included files change.
  8707.  
  8708.  +Files can be included in script with 
  8709.   SSI <!--#include file="filename"--> syntax, needs to be
  8710.   done in ASP module to allow compilation of included code and html 
  8711.   into script.  Future chaining with Apache::SSI will allow static 
  8712.   html includes, and other SSI directives
  8713.  
  8714.  
  8715. =item $VERSION = 0.04; $DATE="10/14/1998";
  8716.  
  8717.  +Example script eg/cgi.htm demonstrating CGI.pm use for output.
  8718.  
  8719.  +Optimized ASP parsing, faster and more legible executing code
  8720.     : try 'die();' in code with setting PerlSetVar Debug 2
  8721.  
  8722.  +Cleaned up code for running with 'use strict'
  8723.  
  8724.  -Fixed directory handle leak on Solaris, from not closing after opendir()
  8725.  
  8726.  +StatINC overhaul.  StatINC setting now works as it should, with 
  8727.   the caveat that exported functions will not be refreshed.
  8728.  
  8729.  +NoState setting optimization, disallows $Application & $Session
  8730.  
  8731.  +$Application->*Lock() functions implemented
  8732.  
  8733.  -SoftRedirect setting for those who want scripts to keep running
  8734.   after a Redirect()
  8735.  
  8736.  +SessionSerialize setting to lock session while script is running
  8737.     : Microsoft ASP style session locking
  8738.     : For a session, scripts execute one at a time 
  8739.     : NOT recommended use, please see note.
  8740.  
  8741.  -MLDBM can be used for other things without messing up internal use
  8742.     : before if it was used with different DB's and serializers,
  8743.       internal state could be lost.
  8744.  
  8745.  --State file locking.  Corruption worries, and loss of data no more.
  8746.  
  8747.  +CGI header support, developer can use CGI.pm for *output*, or just print()
  8748.     : print "Set-Cookie: test=cookie\n", and things will just work
  8749.     : use CGI.pm for output
  8750.     : utilizes $r->send_cgi_header(), thanks Doug!
  8751.  
  8752.  +Improved Cookie implementation, more flexible and complete
  8753.     - Domain cookie key now works
  8754.     : Expire times now taken from time(), and relative time in sec
  8755.     : Request->Cookies() reading more flexible, with wantarray()
  8756.       on hash cookie values, %hash = $Request->Cookie('test');
  8757.  
  8758.  -make test module naming correction, was t.pm, now T.pm for Unix
  8759.  
  8760.  +POD / README cleanup, formatting and HTML friendly.
  8761.  
  8762.  
  8763. =item $VERSION = 0.03; $DATE="09/14/1998";
  8764.  
  8765.  +Installation 'make test' now works
  8766.  
  8767.  +ActiveX objects on Win32 implemented with $Server->CreateObject() 
  8768.  
  8769.  +Cookies implemented: $Response->Cookies() & $Request->Cookies()
  8770.  
  8771.  -Fixed $Response object API, converting some methods to object members.
  8772.   Deprecated methods, but backwards compatible.
  8773.  
  8774.  +Improved error messaging, debug output
  8775.  
  8776.  +$, influences $Response->Write(@strings) behavior
  8777.  
  8778.  +perl print() works, sending output to $Response object
  8779.  
  8780.  +$Response->Write() prints scalars, arrays, and hashes.  Before only scalars.
  8781.  
  8782.  +Begin implementation of $Server object.
  8783.  
  8784.  +Implemented $Response->{Expires} and $Response->{ExpiresAbsolute}
  8785.  
  8786.  +Added "PerlSetVar StatINC" config option
  8787.  
  8788.  +$0 is aliased to current script filename
  8789.  
  8790.  +ASP Objects ($Response, etc.) are set in main package
  8791.   Thus notation like $main::Response->Write() can be used anywhere.
  8792.  
  8793.  
  8794. =item $VERSION = 0.02; $DATE="07/12/1998";
  8795.  
  8796.  ++Session Manager, won't break under denial of service attack
  8797.  
  8798.  +Fleshed out $Response, $Session objects, almost full implementation.
  8799.  
  8800.  +Enormously more documentation.
  8801.  
  8802.  -Fixed error handling with Debug = 2.
  8803.  
  8804.  -Documentation fixed for pod2man support.  README now more man-like.
  8805.  
  8806.  -Stripped \r\n dos characters from installation files
  8807.  
  8808.  -755 mode set for session state directory when created
  8809.  
  8810.  -Loads Win32/OLE properly, won't break with UNIX
  8811.  
  8812.  
  8813. =item $VERSION = 0.01; $DATE="06/26/1998";
  8814.  
  8815.  Syntax Support
  8816.  --------------
  8817.  Initial release, could be considered alpha software.
  8818.  Allows developers to embed perl in html ASP style.
  8819.  
  8820.  <!-- sample here -->
  8821.  <html>
  8822.  <body>
  8823.  <% for(1..10) { %>
  8824.      counting: <%=$_%> <br>
  8825.  <% } %>
  8826.  </body>
  8827.  </html>
  8828.  
  8829.  ASP Objects
  8830.  -----------
  8831.  $Session, $Application, $Response, $Request objects available
  8832.  for use in asp pages.
  8833.  
  8834.  $Session & $Application data is preserved using SDBM files.
  8835.  
  8836.  $Session id's are tracked through the use of cookies.
  8837.  
  8838.  Security
  8839.  --------
  8840.  Timeouts any attempt to use a session id that doesn't already 
  8841.  exist.  Should stop hackers, since there is no wire speed guessing
  8842.  cookies.
  8843.  
  8844. =head1 LICENSE
  8845.  
  8846. Copyright (c) 1998-2003, Josh Chamas, Chamas Enterprises Inc. 
  8847. All rights reserved.
  8848.  
  8849. Apache::ASP is a perl native port of Active Server Pages for Apache
  8850. and mod_perl.  This software is licensed under the GPL.
  8851.  
  8852. This program is free software; you can redistribute it and/or
  8853. modify it under the terms of the GNU General Public License
  8854. as published by the Free Software Foundation; either version 2
  8855. of the License, or (at your option) any later version.
  8856.  
  8857. This program is distributed in the hope that it will be useful,
  8858. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8859. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8860. GNU General Public License for more details.
  8861.  
  8862. For the full text of the GPL, see the license file in the 
  8863. distribution of this software, visit the GPL site at 
  8864. http://www.gnu.org/copyleft/gpl.html or write to the Free Software
  8865. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  8866.  
  8867. For general licensing questions, please see the SUPPORT section.
  8868.  
  8869. To contact us about licensing terms, please email asp@chamas.com.
  8870.  
  8871. =cut
  8872.  
  8873.  
  8874.  
  8875.