Apache-ASP
view release on metacpan or search on metacpan
Response buffer will not be cleared automatically, so if you want this
to serve as a faster $Response->Redirect(), you will need to call
$Response->Clear() before calling this method.
This new script will take over current execution and the current script
will not continue to be executed afterwards. It differs from Execute()
because the original script will not pick up where it left off.
As of Apache::ASP 2.31, this method now accepts optional arguments like
$Response->Include & $Server->Execute. $Server->Transfer is now just a
wrapper for:
$Response->Include($file, @args);
$Response->End;
$Server->URLEncode($string)
Returns the URL-escaped version of the string $string. +'s are
substituted in for spaces and special characters are escaped to the
ascii equivalents. Strings encoded in this manner are safe to put in
urls... they are especially useful for encoding data used in a query
string as in:
$data = $Server->URLEncode("test data");
$url = "http://localhost?data=$data";
$url evaluates to http://localhost?data=test+data, and is a
valid URL for use in anchor <a> tags and redirects, etc.
$Server->URL($url, \%params)
Will return a URL with %params serialized into a query string like:
$url = $Server->URL('test.asp', { test => value });
which would give you a URL of test.asp?test=value
Used in conjunction with the SessionQuery* settings, the returned URL
will also have the session id inserted into the query string, making
this a critical part of that method of implementing cookieless sessions.
For more information on that topic please read on the setting in the
CONFIG section, and the SESSIONS section too.
$Server->XSLT(\$xsl_data, \$xml_data)
* NON-PORTABLE API EXTENSION *
This method takes string references for XSL and XML data and returns the
XSLT output as a string reference like:
my $xslt_data_ref = $Server->XSLT(\$xsl_data, \$xml_data)
print $$xslt_data_ref;
The XSLT parser defaults to XML::XSLT, and is configured with the
XSLTParser setting, which can also use XML::Sablotron ( support added in
2.11 ), and XML::LibXSLT ( support added in 2.29 ). Please see the
CONFIG section for more information on the XSLT* settings that drive
this API. The XSLT setting itself uses this API internally to do its
rendering.
This API was created to allow developers easy XSLT component rendering
without having to render the entire ASP scripts via XSLT. This will make
an easy plugin architecture for those looking to integrate XML into
their existing ASP application frameworks.
At some point, the API will likely take files as arguments, but not as
of the 2.11 release.
SSI
SSI is great! One of the main features of server side includes is to include
other files in the script being requested. In Apache::ASP, this is
implemented in a couple ways, the most crucial of which is implemented in
the file include. Formatted as
<!--#include file=filename.inc-->
,the .inc being merely a convention, text from the included file will be
inserted directly into the script being executed and the script will be
compiled as a whole. Whenever the script or any of its includes change, the
script will be recompiled.
Includes go a great length to promote good decomposition and code sharing in
ASP scripts, but they are still fairly static. As of version .09, includes
may have dynamic runtime execution, as subroutines compiled into the
global.asa namespace. The first way to invoke includes dynamically is
<!--#include file=filename.inc args=@args-->
If @args is specified, Apache::ASP knows to execute the include at runtime
instead of inlining it directly into the compiled code of the script. It
does this by compiling the script at runtime as a subroutine, and caching it
for future invocations. Then the compiled subroutine is executed and has
@args passed into its as arguments.
This is still might be too static for some, as @args is still hardcoded into
the ASP script, so finally, one may execute an include at runtime by
utilizing this API extension
$Response->Include("filename.inc", @args);
which is a direct translation of the dynamic include above.
Although inline includes should be a little faster, runtime dynamic includes
represent great potential savings in httpd memory, as includes are shared
between scripts keeping the size of each script to a minimum. This can often
be significant saving if much of the formatting occurs in an included header
of a www page.
By default, all includes will be inlined unless called with an args
parameter. However, if you want all your includes to be compiled as subs and
dynamically executed at runtime, turn the DynamicIncludes config option on
as documented above.
Apache::SSI for mod_perl 1.3.x only
One of the things missing above is the
<!--#include virtual=filename.cgi-->
tag. This and many other SSI code extensions are available by filtering
Apache::ASP output through Apache::SSI via the Apache::Filter and the Filter
config options, available in mod_perl 1.3.x / Apache 1.3.x. Unfortunately
this functionality is not available with mod_perl 2 / Apache 2.
For more information on how to wire Apache::ASP and Apache::SSI together,
When I got here there was a huge argument about needing a game engine
and I belive this has been the key... Games are approx. 10 time faster
than before. The games don't break anylonger. All in all a great tool
for advancement.
-- JC Fant IV
Cine.gr
...we ported our biggest yet ASP site from IIS (well, actually rewrote),
Cine.gr and it is a killer site. In some cases, the whole thing got
almost 25 (no typo) times faster... None of this would ever be possible
without Apache::ASP (I do not ever want to write ``print "<HTML>\n";''
again).
RESOURCES
Here are some important resources listed related to the use of Apache::ASP
for publishing web applications. If you have any more to suggest, please
email the Apache::ASP list at asp[at]perl.apache.org
Articles
Apache::ASP Introduction ( #1 in 3 part series )
http://www.apache-asp.org/articles/perlmonth1_intro.html
Apache::ASP Site Building ( #2 in 3 part series )
http://www.apache-asp.org/articles/perlmonth2_build.html
Apache::ASP Site Tuning ( #3 in 3 part series )
http://www.apache-asp.org/articles/perlmonth3_tune.html
Embedded Perl ( part of a series on Perl )
http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/index15.html
Books
mod_perl "Eagle" Book
http://www.modperl.com
mod_perl Developer's Cookbook
http://www.modperlcookbook.org
Programming the Perl DBI
http://www.oreilly.com/catalog/perldbi/
Reference Cards
Apache & mod_perl Reference Cards
http://www.refcards.com/
Web Sites
mod_perl Apache web module
http://perl.apache.org
mod_perl 1.x Guide
http://perl.apache.org/guide/
Perl Programming Language
http://www.perl.com
Apache Web Server
http://www.apache.org
TODO
There is no specific time frame in which these things will be implemented.
Please let me know if any of these is of particular interest to you, and I
will give it higher priority.
WILL BE DONE
+ Database storage of $Session & $Application, so web clusters
may scale better than the current NFS/CIFS StateDir implementation
allows, maybe via Apache::Session.
CHANGES
Apache::ASP has been in development since 1998, and was production ready
since its .02 release. Releases are always used in a production setting
before being made publically available.
In July 2000, the version numbers of releases went from .19 to 1.9 which is
more relevant to software development outside the perl community. Where a
.10 perl module usually means first production ready release, this would be
the equivalent of a 1.0 release for other kinds of software.
+ = improvement - = bug fix (d) = documentations
$VERSION = 2.63; $DATE="03/14/2018"
+ Added section ``raw'' to MailErrors.inc to debug POSTs without
form fields
- MailErrorsHTML now uses monospaced fonts for errors. Easier on
the eyes and more informative
$VERSION = 2.62; $DATE="08/16/2011"
- Fixed 'application/x-www-form-urlencoded' for AJAX POSTs post
Firefox 3.x
+ First sourceforge.net hosted version
+ Incremented version number to actually match SVN branch tag
$VERSION = 2.61; $DATE="05/24/2008"
- updated for more recent mod_perl 2 environment to trigger correct loading of modules
+ loads modules in a backwards compatible way for older versions of mod_perl 1.99_07 to 1.99_09
+ license changes from GPL to Perl Artistic License
$VERSION = 2.59; $DATE="05/23/2005"
+ added "use bytes" to Response object to calculate Content-Length
correctly for UTF8 data, which should require therefore at least
perl version 5.6 installed
+ updated to work with latest mod_perl 2.0 module naming convention,
thanks to Randy Kobes for patch
+ examples now exclude usage of Apache::Filter & Apache::SSI under mod_perl 2.0
$VERSION = 2.57; $DATE="01/29/2004"
- $Server->Transfer will update $0 correctly
- return 0 for mod_perl handler to work with latest mod_perl 2 release
when we were returning 200 ( HTTP_OK ) before
- fixed bug in $Server->URL when called like $Server->URL($url)
without parameters. Its not clear which perl versions this bug
+Loader() will log the number of scripts
recompiled and the number of scripts checked, instead
of just the number of scripts recompiled, which is
misleading as it reports 0 for child httpds after
a parent fork that used Loader() upon startup.
-Apache::ASP->Loader() would have a bad error if it didn't load
any scripts when given a directory, prints "loaded 0 scripts" now
$VERSION = 0.18; $DATE="02/03/2000";
+Documented SessionQuery* & $Server->URL() and
cleaned up formatting some, as well as redoing
some of the sections ordering for better readability.
Document the cookieless session functionality more
in a new SESSIONS section. Also documented new
FileUpload configs and $Request->FileUpload collection.
Documented StatScripts.
+StatScripts setting which if set to 0 will not reload
includes, global.asa, or scripts when changed.
+FileUpload file handles cleanup at garbage collection
time so developer does not have to worry about lazy coding
and undeffing filehandles used in code. Also set
uploaded filehandles to binmode automatically on Win32
platforms, saving the developer yet more typing.
+FileUploadTemp setting, default 0, if set will leave
a temp file on disk during the request, which may be
helpful for processing by other programs, but is also
a security risk in that others could potentially read
this file while the script is running.
The path to the temp file will be available at
$Request->{FileUpload}{$form_field}{TempFile}.
The regular use of file uploads remains the same
with the <$filehandle> to the upload at
$Request->{Form}{$form_field}.
+FileUploadMax setting, default 0, currently an
alias for $CGI::POST_MAX, which determines the
max size for a file upload in bytes.
+SessionQueryParse only auto parses session-ids
into links when a session-id COOKIE is NOT found.
This feature is only enabled then when a user has
disabled cookies, so the runtime penalty of this
feature won't drag down the whole site, since most
users will have cookies turned on.
-StatINC & StatINCMatch will not undef Fnctl.pm flock
functions constants like O_RDWR, because the code references
are not well trackable. This would result in sporadic 500 server
errors when a changed module was reloaded that imported O_* flock
functions from Fnctl.
+SessionQueryParse & SessionQueryParseMatch
settings that enable auto parsing session ids into
URLs for cookieless sessions. Will pick up URLs in
<a href>, <area href>, <form action>, <frame src>,
<iframe src>, <img src>, <input src>, <link href>
$Response->Redirect($URL) and the first URL in
script tags like <script>*.location.href=$URL</script>
These settings require that buffering be enabled, as
Apache::ASP will parse through the buffer to parse the URLs.
With SessionQueryParse on, it will just parse non-absolute
URLs, but with SessionQueryParseMatch set to some server
url regexp, like ^http://localhost , will also parse
in the session id for URLs that match that.
When testing, the performance hit from this parsing
a script dropped from 12.5 hits/sec on my WinNT box
to 11.7 hits per second for 1K of buffered output.
The difference is .007 of my PII300's processing power
per second.
For 10K of output then, my guess is that this speed
of script, would be slowed to 6.8 hits per second.
This kind of performance hit would also slow a
script running at 40 hits per second on a UNIX box
to 31 hits/sec for 1K, and to 11 hits/sec for 10K parsed.
Your mileage may vary and you will have to test the difference
yourself. Get yourself a valid URL with a session-id in
it, and run it through ab, or Socrates, with SessionQuery
turned on, and then with SessionQueryParse set to see
the difference. SessionQuery just enables of session id
setting from the query string but will not auto parse urls.
-If buffering, Content-Length will again be set.
It broke, probably while I was tuning in the past
couple versions.
+UseStrict setting compiles all scripts including
global.asa with "use strict" turned on for catching
more coding errors. With this setting enabled,
use strict errors die during compilation forcing
Apache::ASP to try to recompile the script until
successful.
-Object use in includes like $Response->Write()
no longer error with "use strict" programming.
+SessionQuery config setting with $Server->URL($url, { %params } )
alpha API extensions to enable cookieless sessions.
+Debugging not longer produces internal debugging
by default. Set to -1,-2 for internal debugging
for Debug settings 1 & 2.
+Both StateSerializer & StateDB can be changed
without affecting a live web site, by storing
the configurations for $Application & $Session
in an internal database, so that if $Session was
created with SDBM_File for the StateDB (default),
it will keep this StateDB setting until it ends.
+StateSerializer config setting. Default Data::Dumper,
can also be set to Storable. Controls how data is
( run in 0.588 second using v1.01-cache-2.11-cpan-df04353d9ac )