Apache-ASP
view release on metacpan or search on metacpan
site/objects.html view on Meta::CPAN
<font face="courier new" size=3><pre>
</pre></font>Please note that if you are on Win32, you will need to
call binmode on a file handle before reading, if
its data is binary.</font>
<p>
<a name=%24Response-%3EC08958c05></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Clear()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Erases buffered ASP output.</font>
<p>
<a name=%24Response-%3ECd77d06d7></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Cookies($name, [$key,] $value)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sets the key or attribute of cookie with name $name to the value $value.
If $key is not defined, the Value of the cookie is set.
ASP CookiePath is assumed to be / in these examples.
<font face="courier new" size=3><pre>
$Response->Cookies('name', 'value');
--> Set-Cookie: name=value; path=/
$Response->Cookies("Test", "data1", "test value");
$Response->Cookies("Test", "data2", "more test");
$Response->Cookies(
"Test", "Expires",
&HTTP::Date::time2str(time+86400)
);
$Response->Cookies("Test", "Secure", 1);
$Response->Cookies("Test", "Path", "/");
$Response->Cookies("Test", "Domain", "host.com");
--> Set-Cookie:Test=data1=test%20value&data2=more%20test; \
expires=Fri, 23 Apr 1999 07:19:52 GMT; \
path=/; domain=host.com; secure
</pre></font>The latter use of $key in the cookies not only sets cookie attributes
such as Expires, but also treats the cookie as a hash of key value pairs
which can later be accesses by
<font face="courier new" size=3><pre>
$Request->Cookies('Test', 'data1');
$Request->Cookies('Test', 'data2');
</pre></font>Because this is perl, you can (NOT PORTABLE) reference the cookies
directly through hash notation. The same 5 commands above could be compressed to:
<font face="courier new" size=3><pre>
$Response->{Cookies}{Test} =
{
Secure => 1,
Value =>
{
data1 => 'test value',
data2 => 'more test'
},
Expires => 86400, # not portable, see above
Domain => 'host.com',
Path => '/'
};
</pre></font>and the first command would be:
<font face="courier new" size=3><pre>
# you don't need to use hash notation when you are only setting
# a simple value
$Response->{Cookies}{'Test Name'} = 'Test Value';
</pre></font>I prefer the hash notation for cookies, as this looks nice, and is
quite perlish. It is here to stay. The Cookie() routine is
very complex and does its best to allow access to the
underlying hash structure of the data. This is the best emulation
I could write trying to match the Collections functionality of
cookies in IIS ASP.
<font face="courier new" size=3><pre>
</pre></font>For more information on Cookies, please go to the source at
<a href=http://home.netscape.com/newsref/std/cookie_spec.html>http://home.netscape.com/newsref/std/cookie_spec.html</a></font>
<p>
<a name=%24Response-%3EDe321f073></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Debug(@args)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API Extension. If the Debug config option is set greater than 0,
this routine will write @args out to server error log. refs in @args
will be expanded one level deep, so data in simple data structures
like one-level hash refs and array refs will be displayed. CODE
refs like
<font face="courier new" size=3><pre>
$Response->Debug(sub { "some value" });
</pre></font>will be executed and their output added to the debug output.
This extension allows the user to tie directly into the
debugging capabilities of this module.
<font face="courier new" size=3><pre>
</pre></font>While developing an app on a production server, it is often
useful to have a separate error log for the application
to catch debugging output separately. One way of implementing
this is to use the Apache ErrorLog configuration directive to
create a separate error log for a virtual host.
<font face="courier new" size=3><pre>
</pre></font>If you want further debugging support, like stack traces
in your code, consider doing things like:
<font face="courier new" size=3><pre>
$Response->Debug( sub { Carp::longmess('debug trace') };
$SIG{__WARN__} = \&Carp::cluck; # then warn() will stack trace
</pre></font>The only way at present to see exactly where in your script
an error occurred is to set the Debug config directive to 2,
and match the error line number to perl script generated
from your ASP script.
<font face="courier new" size=3><pre>
</pre></font>However, as of version 0.10, the perl script generated from the
asp script should match almost exactly line by line, except in
cases of inlined includes, which add to the text of the original script,
pod comments which are entirely yanked out, and <% # comment %> style
comments which have a \n added to them so they still work.
<font face="courier new" size=3><pre>
</pre></font>If you would like to see the HTML preceding an error
while developing, consider setting the BufferingOn
config directive to 0.</font>
<p>
<a name=%24Response-%3EE295b6523></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->End()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sends result to client, and immediately exits script.
Automatically called at end of script, if not already called.</font>
<p>
<a name=%24Response-%3EE0139cee1></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->ErrorDocument($code, $uri)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension that allows for the modification the Apache
ErrorDocument at runtime. $uri may be a on site document,
off site URL, or string containing the error message.
<font face="courier new" size=3><pre>
</pre></font>This extension is useful if you want to have scripts
set error codes with $Response->{Status} like 401
for authentication failure, and to then control from
the script what the error message looks like.
<font face="courier new" size=3><pre>
</pre></font>For more information on the Apache ErrorDocument mechanism,
please see ErrorDocument in the CORE Apache settings,
and the Apache->custom_response() API, for which this method
is a wrapper.</font>
<p>
<a name=%24Response-%3EF8d6e0efc></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Flush()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sends buffered output to client and clears buffer.</font>
<p>
<a name=%24Response-%3EI2a8df2f3></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Include($filename, @args)</b></font>
<font face="courier new" size=3><pre>
</pre></font>This API extension calls the routine compiled from asp script
in $filename with the args @args. This is a direct translation
of the <a href=ssi.html><font size=-1 face=verdana><b>SSI</b></font></a> tag
<font face="courier new" size=3><pre>
<!--#include file=$filename args=@args-->
</pre></font>Please see the SSI section for more on SSI in general.
<font face="courier new" size=3><pre>
</pre></font>This API extension was created to allow greater modularization
of code by allowing includes to be called with runtime
arguments. Files included are compiled once, and the
anonymous code ref from that compilation is cached, thus
including a file in this manner is just like calling a
perl subroutine. The @args can be found in @_ in the
includes like:
<font face="courier new" size=3><pre>
# include.inc
<% my @args = @_; %>
</pre></font>As of 2.23, multiple return values can be returned from
an include like:
<font face="courier new" size=3><pre>
my @rv = $Response->Include($filename, @args);
</pre></font>
<p>
<a name=%24Response-%3EIa3beea1e></a>
<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Include(\%cache_args, @sub_args) *CACHE API*</b></font>
<font face="courier new" size=3><pre>
</pre></font>As of version 2.23, output from an include may be
cached with this API and the <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a> settings CacheDir & CacheDB. This
can be used to execute expensive includes only rarely
where applicable, drastically increasing performance in
some cases.
<font face="courier new" size=3><pre>
</pre></font>This API extension applies to the entire include family:
<font face="courier new" size=3><pre>
my @rv = $Response->Include(\%cache_args, @include_args)
my $html_ref = $Response->TrapInclude(\%cache_args, @include_args)
$Server->Execute(\%cache_args, @include_args)
</pre></font>For this output cache to work, you must load Apache::ASP
in the Apache parent httpd like so:
<font face="courier new" size=3><pre>
# httpd.conf
PerlModule Apache::ASP
</pre></font>The cache arguments are shown here
( run in 0.578 second using v1.01-cache-2.11-cpan-39bf76dae61 )