Apache-ASP

 view release on metacpan or  search on metacpan

site/objects.html  view on Meta::CPAN

	<a name=%24Response-%3E%7Bbbff130a></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Debug} = 1|0</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension.  Default set to value of Debug config.  May be
used to temporarily activate or inactivate $Response-&gt;Debug()
behavior.  Something like:
<font face="courier new" size=3><pre>
 {
   local $Response-&gt;{Debug} = 1;
   $Response-&gt;Debug($values);
 }
</pre></font>maybe be used to always log something.  The Debug()
method can be better than AppendToLog() because it will
log data in data structures one level deep, whereas
AppendToLog prints just raw string/scalar values.</font>
	
	<p>
	<a name=%24Response-%3E%7Bf2954302></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Expires} = $time</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sends a response header to the client indicating the $time 
in SECONDS in which the document should expire.  A time of 0 means
immediate expiration.  The header generated is a standard
HTTP date like: &quot;Wed, 09 Feb 1994 22:23:32 GMT&quot;.</font>
	
	<p>
	<a name=%24Response-%3E%7B0a525d33></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{ExpiresAbsolute} = $date</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sends a response header to the client with $date being an absolute
time to expire.  Formats accepted are all those accepted by 
HTTP::Date::str2time(), e.g.
<font face="courier new" size=3><pre>
 &quot;Wed, 09 Feb 1994 22:23:32 GMT&quot;     -- HTTP format
 &quot;Tuesday, 08-Feb-94 14:15:29 GMT&quot;   -- old rfc850 HTTP format

 &quot;08-Feb-94&quot;       -- old rfc850 HTTP format    
 &quot;09 Feb 1994&quot;     -- proposed new HTTP format  

 &quot;Feb  3  1994&quot;    -- Unix &#39;ls -l&#39; format
 &quot;Feb  3 17:03&quot;    -- Unix &#39;ls -l&#39; format
</pre></font>
	
	<p>
	<a name=%24Response-%3E%7Bf2167225></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{FormFill} = 0|1</b></font>
<font face="courier new" size=3><pre>
</pre></font>If true, HTML forms generated by the script output will
be auto filled with data from $Request-&gt;Form.  This feature
requires HTML::FillInForm to be installed.  Please see
the FormFill <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a> for more information.
<font face="courier new" size=3><pre>
</pre></font>This setting overrides the FormFill config at runtime
for the script execution only.</font>
	
	<p>
	<a name=%24Response-%3E%7Bf284792c></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{IsClientConnected}</b></font>
<font face="courier new" size=3><pre>
</pre></font>1 if web client is connected, 0 if not.  This value
starts set to 1, and will be updated whenever a
$Response-&gt;Flush() is called.  If BufferingOn is
set, by default $Response-&gt;Flush() will only be
called at the end of the HTML output.  
<font face="courier new" size=3><pre>
</pre></font>As of version 2.23 this value is updated correctly
before global.asa Script_OnStart is called, so 
global script termination may be correctly handled
during that event, which one might want to do 
with excessive user STOP/RELOADS when the web 
server is very busy.
<font face="courier new" size=3><pre>
</pre></font>An API extension $Response-&gt;IsClientConnected
may be called for refreshed connection status
without calling first a $Response-&gt;Flush</font>
	
	<p>
	<a name=%24Response-%3E%7Bc48a3e9e></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{PICS}</b></font>
<font face="courier new" size=3><pre>
</pre></font>If this property has been set, a PICS-Label HTTP header will be
sent with its value.  For those that do not know, PICS is a header
that is useful in rating the internet.  It stands for 
Platform for Internet Content Selection, and you can find more
info about it at: <a href=http://www.w3.org>http://www.w3.org</a></font>
	
	<p>
	<a name=%24Response-%3E%7B7098f2f6></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->{Status} = $status</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sets the status code returned by the server.  Can be used to
set messages like 500, internal server error</font>
	
	<p>
	<a name=%24Response-%3EA8c17d8af></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->AddHeader($name, $value)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Adds a custom header to a web page.  Headers are sent only before any
text from the main page is sent, so if you want to set a header
after some text on a page, you must turn BufferingOn.</font>
	
	<p>
	<a name=%24Response-%3EA1b47bb43></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->AppendToLog($message)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Adds $message to the server log.  Useful for debugging.</font>
	
	<p>
	<a name=%24Response-%3EB202b8013></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->BinaryWrite($data)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Writes binary data to the client.  The only
difference from $Response-&gt;Write() is that $Response-&gt;Flush()
is called internally first, so the data cannot be parsed 
as an html header.  Flushing flushes the header if has not
already been written.
<font face="courier new" size=3><pre>
</pre></font>If you have set the $Response-&gt;{ContentType}
to something other than text/html, cgi header parsing (see <a href=cgi.html><font size=-1 face=verdana><b>CGI</b></font></a>
notes), will be automatically be turned off, so you will not
necessarily need to use BinaryWrite for writing binary data.
<font face="courier new" size=3><pre>
</pre></font>For an example of BinaryWrite, see the binary_write.htm example 
in <a href=eg/binary_write.htm>./site/eg/binary_write.htm</a>
<font face="courier new" size=3><pre>
</pre></font>Please note that if you are on Win32, you will need to 

site/objects.html  view on Meta::CPAN

      { Key =&gt; $Request-&gt;Form }

  Clear - If set to 1, or boolean true, will always execute the include 
    and update the cache entry for it.
</pre></font>Motivation: If an include takes 1 second to execute
because of complex SQL to a database, and you can
cache the output of this include because it is not realtime data,
and the cache layer runs at .01 seconds, then you have a 
100 fold savings on that part of the script.  Site scalability
can be dramatically increased in this way by intelligently
caching bottlenecks in the web application.
<font face="courier new" size=3><pre>
</pre></font>Use Sparingly: If you have a fast include, then it may execute faster
than the cache layer runs, in which case you may actually
slow your site down by using this feature.  Therefore
try to use this sparingly, and only when sure you really
need it.  Apache::ASP scripts generally execute very
quickly, so most developers will not need to use this feature
at all.</font>
	
	<p>
	<a name=%24Response-%3EI368566a8></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Include(\$script_text, @args)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Added in Apache::ASP 2.11, this method allows for executing ASP scripts
that are generated dynamically by passing in a reference to the script
data instead of the file name.  This works just like the normal
$Response-&gt;Include() API, except a string reference is passed in
instead of a filename.  For example:
<font face="courier new" size=3><pre>
  &lt;%
    my $script = &quot;&lt;\% print &#39;TEST&#39;; %\&gt;&quot;;
    $Response-&gt;Include(\$script);
  %&gt;
</pre></font>This include would output TEST.  Note that tokens like
&lt;% and %&gt; must be escaped so Apache::ASP does not try
to compile those code blocks directly when compiling
the original script.  If the $script data were fetched
directly from some external resource like a database,
then these tokens would not need to be escaped at all as in:
<font face="courier new" size=3><pre>
  &lt;%
    my $script = $dbh-&gt;selectrow_array(
       &quot;select script_text from scripts where script_id = ?&quot;,
       undef, $script_id
       );
    $Response-&gt;Include(\$script);
  %&gt;
</pre></font>This method could also be used to render other types of dynamic scripts,
like XML docs using XMLSubs for example, though for complex
runtime XML rendering, one should use something better suited like XSLT.
See the $Server-&gt;XSLT API for more on this topic.</font>
	
	<p>
	<a name=%24Response-%3EIbe084bb0></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->IsClientConnected()</b></font>
<font face="courier new" size=3><pre>
</pre></font>API Extension.  1 for web client still connected, 0 if 
disconnected which might happen if the user hits the stop button.
The original API for this $Response-&gt;{IsClientConnected}
is only updated after a $Response-&gt;Flush is called,
so this method may be called for a refreshed status.
<font face="courier new" size=3><pre>
</pre></font>Note $Response-&gt;Flush calls $Response-&gt;IsClientConnected
to update $Response-&gt;{IsClientConnected} so to use this
you are going straight to the source!  But if you are doing
a loop like:
<font face="courier new" size=3><pre>
  while(@data) {
    $Response-&gt;End if ! $Response-&gt;{IsClientConnected};
    my $row = shift @data;
    %&gt; &lt;%= $row %&gt; &lt;%
    $Response-&gt;Flush;
  }
</pre></font>Then its more efficient to use the member instead of 
the method since $Response-&gt;Flush() has already updated
that value for you.</font>
	
	<p>
	<a name=%24Response-%3ER0203b227></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Redirect($url)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Sends the client a command to go to a different url $url.  
Script immediately ends.</font>
	
	<p>
	<a name=%24Response-%3ET13ecbe6d></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->TrapInclude($file, @args)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Calls $Response-&gt;Include() with same arguments as
passed to it, but instead traps the include output buffer
and returns it as as a perl string reference.  This allows
one to postprocess the output buffer before sending
to the client.
<font face="courier new" size=3><pre>
  my $string_ref = $Response-&gt;TrapInclude(&#39;file.inc&#39;);
  $$string_ref =~ s/\s+/ /sg; # squash whitespace like Clean 1
  print $$string_ref;
</pre></font>The data is returned as a referenece to save on what
might be a large string copy.  You may dereference the data
with the $$string_ref notation.</font>
	
	<p>
	<a name=%24Response-%3EW0307fe16></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Response->Write($data)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Write output to the HTML page.  &lt;%=$data%&gt; syntax is shorthand for
a $Response-&gt;Write($data).  All final output to the client must at
some point go through this method.</font>
	
	<p>
	<a name=%24Request%20Objc3cab62e></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>$Request Object</b></font>
<font face="courier new" size=3><pre>
</pre></font>The request object manages the input from the client browser, like
posts, query strings, cookies, etc.  Normal return results are values
if an index is specified, or a collection / perl hash ref if no index 
is specified.  WARNING, the latter property is not supported in 
ActiveState <a href=http://www.activestate.com/ActivePerl/><font size=-1 face=verdana><b>PerlScript</b></font></a>, so if you use the hashes returned by such
a technique, it will not be portable.
<font face="courier new" size=3><pre>
</pre></font>A normal use of this feature would be to iterate through the 
form variables in the form hash...
<font face="courier new" size=3><pre>
 $form = $Request-&gt;Form();
 for(keys %{$form}) {
	$Response-&gt;Write(&quot;$_: $form-&gt;{$_}&lt;br&gt;\n&quot;);
 }
</pre></font>Please see the <a href=eg/server_variables.htm>./site/eg/server_variables.htm</a> asp file for this 
method in action.
<font face="courier new" size=3><pre>
</pre></font>Note that if a form POST or query string contains duplicate
values for a key, those values will be returned through
normal use of the $Request object:
<font face="courier new" size=3><pre>
  @values = $Request-&gt;Form(&#39;key&#39;);



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