Apache-ASP

 view release on metacpan or  search on metacpan

site/objects.html  view on Meta::CPAN

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-&gt;Cookies(&#39;name&#39;, &#39;value&#39;); 
  --&gt; Set-Cookie: name=value; path=/

 $Response-&gt;Cookies(&quot;Test&quot;, &quot;data1&quot;, &quot;test value&quot;);     
 $Response-&gt;Cookies(&quot;Test&quot;, &quot;data2&quot;, &quot;more test&quot;);      
 $Response-&gt;Cookies(
	&quot;Test&quot;, &quot;Expires&quot;, 
	&amp;HTTP::Date::time2str(time+86400)
	); 
 $Response-&gt;Cookies(&quot;Test&quot;, &quot;Secure&quot;, 1);               
 $Response-&gt;Cookies(&quot;Test&quot;, &quot;Path&quot;, &quot;/&quot;);
 $Response-&gt;Cookies(&quot;Test&quot;, &quot;Domain&quot;, &quot;host.com&quot;);
  --&gt;	Set-Cookie:Test=data1=test%20value&amp;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-&gt;Cookies(&#39;Test&#39;, &#39;data1&#39;);
 $Request-&gt;Cookies(&#39;Test&#39;, &#39;data2&#39;);
</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-&gt;{Cookies}{Test} = 
	{ 
		Secure	=&gt; 1, 
		Value	=&gt;	
			{
				data1 =&gt; &#39;test value&#39;, 
				data2 =&gt; &#39;more test&#39;
			},
		Expires	=&gt; 86400, # not portable, see above
		Domain	=&gt; &#39;host.com&#39;,
		Path    =&gt; &#39;/&#39;
	};
</pre></font>and the first command would be:
<font face="courier new" size=3><pre>
 # you don&#39;t need to use hash notation when you are only setting 
 # a simple value
 $Response-&gt;{Cookies}{&#39;Test Name&#39;} = &#39;Test Value&#39;; 
</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-&gt;Debug(sub { &quot;some value&quot; });
</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-&gt;Debug( sub { Carp::longmess(&#39;debug trace&#39;) };
 $SIG{__WARN__} = \&amp;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 &lt;% # comment %&gt; 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,

site/objects.html  view on Meta::CPAN

</pre></font>Returns the value of the server variable / environment variable
with name $name.  If $name is not specified, returns a ref to 
a hash of all the server / environment variables data.  The following
would be a common use of this method:
<font face="courier new" size=3><pre>
 $env = $Request-&gt;ServerVariables();
 # %{$env} here would be equivalent to the cgi %ENV in perl.
</pre></font>
	
	<p>
	<a name=%24Application971dfe6c></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>$Application Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>Like the $Session object, you may use the $Application object to 
store data across the entire life of the application.  Every
page in the ASP application always has access to this object.
So if you wanted to keep track of how many visitors there where
to the application during its lifetime, you might have a line
like this:
<font face="courier new" size=3><pre>
 $Application-&gt;{num_users}++
</pre></font>The Lock and Unlock methods are used to prevent simultaneous 
access to the $Application object.</font>
	
	<p>
	<a name=%24Application7d01ce04></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Application->Lock()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Locks the Application object for the life of the script, or until
UnLock() unlocks it, whichever comes first.  When $Application
is locked, this guarantees that data being read and written to it 
will not suddenly change on you between the reads and the writes.
<font face="courier new" size=3><pre>
</pre></font>This and the $Session object both lock automatically upon
every read and every write to ensure data integrity.  This 
lock is useful for concurrent access control purposes.
<font face="courier new" size=3><pre>
</pre></font>Be careful to not be too liberal with this, as you can quickly 
create application bottlenecks with its improper use.</font>
	
	<p>
	<a name=%24Application2899ee54></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Application->UnLock()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Unlocks the $Application object.  If already unlocked, does nothing.</font>
	
	<p>
	<a name=%24Applicationaeaabc29></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Application->GetSession($sess_id)</b></font>
<font face="courier new" size=3><pre>
</pre></font>This NON-PORTABLE API extension returns a user $Session given
a session id.  This allows one to easily write a session manager if
session ids are stored in $Application during Session_OnStart, with 
full access to these sessions for administrative purposes.  
<font face="courier new" size=3><pre>
</pre></font>Be careful not to expose full session ids over the net, as they
could be used by a hacker to impersonate another user.  So when 
creating a session manager, for example, you could create
some other id to reference the SessionID internally, which 
would allow you to control the sessions.  This kind of application
would best be served under a secure web server.
<font face="courier new" size=3><pre>
</pre></font>The <a href=eg/global_asa_demo.asp>./site/eg/global_asa_demo.asp</a> script makes use of this routine 
to display all the data in current user sessions.</font>
	
	<p>
	<a name=%24Application7441b337></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Application->SessionCount()</b></font>
<font face="courier new" size=3><pre>
</pre></font>This NON-PORTABLE method returns the current number of active sessions
in the application, and is enabled by the SessionCount configuration setting.
This method is not implemented as part of the original ASP
object model, but is implemented here because it is useful.  In particular,
when accessing databases with license requirements, one can monitor usage
effectively through accessing this value.</font>
	
	<p>
	<a name=%24Server%20Objeed08cf85></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>$Server Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>The server object is that object that handles everything the other
objects do not.  The best part of the server object for Win32 users is 
the CreateObject method which allows developers to create instances of
ActiveX components, like the ADO component.</font>
	
	<p>
	<a name=%24Server-%3E%7BSc74a89b4a></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->{ScriptTimeout} = $seconds</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented. May never be.  Please see the 
Apache Timeout configuration option, normally in httpd.conf.</font>
	
	<p>
	<a name=%24Server-%3ECon7d9785f8></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->Config($setting)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension.  Allows a developer to read the <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a>
settings, like Global, GlobalPackage, StateDir, etc.
Currently implemented as a wrapper around 
<font face="courier new" size=3><pre>
  Apache-&gt;dir_config($setting)
</pre></font>May also be invoked as $Server-&gt;Config(), which will
return a hash ref of all the PerlSetVar settings.</font>
	
	<p>
	<a name=%24Server-%3ECre0144679e></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->CreateObject($program_id)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Allows use of ActiveX objects on Win32.  This routine returns
a reference to an Win32::OLE object upon success, and nothing upon
failure.  It is through this mechanism that a developer can 
utilize ADO.  The equivalent syntax in VBScript is 
<font face="courier new" size=3><pre>
 Set object = Server.CreateObject(program_id)
</pre></font>For further information, try &#39;perldoc Win32::OLE&#39; from your
favorite command line.</font>
	
	<p>
	<a name=%24Server-%3EExec0fa247a></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->Execute($file, @args)</b></font>
<font face="courier new" size=3><pre>
</pre></font>New method from ASP 3.0, this does the same thing as
<font face="courier new" size=3><pre>
  $Response-&gt;Include($file, @args)
</pre></font>and internally is just a wrapper for such.  Seems like we
had this important functionality before the IIS/ASP camp!</font>
	
	<p>
	<a name=%24Server-%3EFileaa99842></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->File()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the absolute file path to current executing script.
Same as Apache-&gt;request-&gt;filename when running under <a href=http://perl.apache.org><font size=-1 face=verdana><b>mod_perl</b></font></a>.
<font face="courier new" size=3><pre>
</pre></font>ASP API extension.</font>
	
	<p>
	<a name=%24Server-%3EGetb3d1ac42></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Server->GetLastError()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented, will likely not ever be because this is dependent
on how IIS handles errors and is not relevant in Apache.</font>



( run in 0.782 second using v1.01-cache-2.11-cpan-39bf76dae61 )