Apache-ASP

 view release on metacpan or  search on metacpan

site/objects.html  view on Meta::CPAN

	<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;);
</pre></font>but you can also access the internal storage, which is
an array reference like so:
<font face="courier new" size=3><pre>
  $array_ref = $Request-&gt;{Form}{&#39;key&#39;};
  @values = @{$array_ref};
</pre></font>Please read the <a href=perlscript.html><font size=-1 face=verdana><b>PERLSCRIPT</b></font></a> section for more information 
on how things like $Request-&gt;QueryString() &amp; $Request-&gt;Form()
behave as collections.</font>
	
	<p>
	<a name=%24Request-%3E%7BM81641f4a></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->{Method}</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension.  Returns the client HTTP request method, as in
GET or POST.  Added in version 2.31.</font>
	
	<p>
	<a name=%24Request-%3E%7BT6acbcf5a></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->{TotalBytes}</b></font>
<font face="courier new" size=3><pre>
</pre></font>The amount of data sent by the client in the body of the 
request, usually the length of the form data.  This is
the same value as $Request-&gt;ServerVariables(&#39;CONTENT_LENGTH&#39;)</font>
	
	<p>
	<a name=%24Request-%3EBi2e1177cf></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->BinaryRead([$length])</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns a string whose contents are the first $length bytes
of the form data, or body, sent by the client request.
If $length is not given, will return all of the form data.
This data is the raw data sent by the client, without any
parsing done on it by Apache::ASP.
<font face="courier new" size=3><pre>
</pre></font>Note that BinaryRead will not return any data for file uploads.
Please see the $Request-&gt;FileUpload() interface for access
to this data.  $Request-&gt;Form() data will also be available
as normal.</font>
	
	<p>
	<a name=%24Request-%3ECled50cd44></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->ClientCertificate()</b></font>
<font face="courier new" size=3><pre>
</pre></font>Not implemented.</font>
	
	<p>
	<a name=%24Request-%3ECoe6d79e01></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->Cookies($name [,$key])</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the value of the Cookie with name $name.  If a $key is
specified, then a lookup will be done on the cookie as if it were
a query string.  So, a cookie set by:
<font face="courier new" size=3><pre>
 Set-Cookie: test=data1=1&amp;data2=2
</pre></font>would have a value of 2 returned by $Request-&gt;Cookies(&#39;test&#39;,&#39;data2&#39;).
<font face="courier new" size=3><pre>
</pre></font>If no name is specified, a hash will be returned of cookie names 
as keys and cookie values as values.  If the cookie value is a query string, 
it will automatically be parsed, and the value will be a hash reference to 
these values.
<font face="courier new" size=3><pre>
</pre></font>When in doubt, try it out.  Remember that unless you set the Expires
attribute of a cookie with $Response-&gt;Cookies(&#39;cookie&#39;, &#39;Expires&#39;, $xyz),
the cookies that you set will only last until you close your browser, 
so you may find your self opening &amp; closing your browser a lot when 
debugging cookies.
<font face="courier new" size=3><pre>
</pre></font>For more information on cookies in ASP, please read $Response-&gt;Cookies()</font>
	
	<p>
	<a name=%24Request-%3EFi6799fcec></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->FileUpload($form_field, $key)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension.  The FileUpload interface to file upload data is
stabilized.  The internal representation of the file uploads
is a hash of hashes, one hash per file upload found in 
the $Request-&gt;Form() collection.  This collection of collections
may be queried through the normal interface like so:
<font face="courier new" size=3><pre>
  $Request-&gt;FileUpload(&#39;upload_file&#39;, &#39;ContentType&#39;);
  $Request-&gt;FileUpload(&#39;upload_file&#39;, &#39;FileHandle&#39;);
  $Request-&gt;FileUpload(&#39;upload_file&#39;, &#39;BrowserFile&#39;);
  $Request-&gt;FileUpload(&#39;upload_file&#39;, &#39;Mime-Header&#39;);
  $Request-&gt;FileUpload(&#39;upload_file&#39;, &#39;TempFile&#39;);

  * note that TempFile must be use with the UploadTempFile 
    configuration setting.
</pre></font>The above represents the old slow collection interface, 
but like all collections in Apache::ASP, you can reference
the internal hash representation more easily.
<font face="courier new" size=3><pre>
  my $fileup = $Request-&gt;{FileUpload}{upload_file};
  $fileup-&gt;{ContentType};
  $fileup-&gt;{BrowserFile};
  $fileup-&gt;{FileHandle};
  $fileup-&gt;{Mime-Header};
  $fileup-&gt;{TempFile};
</pre></font>
	
	<p>
	<a name=%24Request-%3EFo76659178></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->Form($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the value of the input of name $name used in a form
with POST method.  If $name is not specified, returns a ref to 
a hash of all the form data.  One can use this hash to 
create a nice alias to the form data like:
<font face="courier new" size=3><pre>
 # in global.asa
 use vars qw( $Form );
 sub Script_OnStart {
   $Form = $Request-&gt;Form;
 }
 # then in ASP scripts
 &lt;%= $Form-&gt;{var} %&gt;
</pre></font>File upload data will be loaded into $Request-&gt;Form(&#39;file_field&#39;), 
where the value is the actual file name of the file uploaded, and 
the contents of the file can be found by reading from the file
name as a file handle as in:
<font face="courier new" size=3><pre>
 while(read($Request-&gt;Form(&#39;file_field_name&#39;), $data, 1024)) {};
</pre></font>For more information, please see the <a href=cgi.html><font size=-1 face=verdana><b>CGI</b></font></a> / File Upload section,
as file uploads are implemented via the <a href=http://stein.cshl.org/WWW/software/CGI/cgi_docs.html><font size=-1 face=verdana><b>CGI.pm</b></font></a> module.  An
example can be found in the installation 
samples <a href=eg/file_upload.asp>./site/eg/file_upload.asp</a></font>
	
	<p>
	<a name=%24Request-%3EPa455879ca></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->Params($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>API extension. If RequestParams <a href=config.html><font size=-1 face=verdana><b>CONFIG</b></font></a> is set, the $Request-&gt;Params 
object is created with combined contents of $Request-&gt;QueryString 
and $Request-&gt;Form.  This is for developer convenience simlar 
to <a href=http://stein.cshl.org/WWW/software/CGI/cgi_docs.html><font size=-1 face=verdana><b>CGI.pm</b></font></a>&#39;s param() method.  Just like for $Response-&gt;Form, 
one could create a nice alias like:
<font face="courier new" size=3><pre>
 # in global.asa
 use vars qw( $Params );
 sub Script_OnStart {
   $Params = $Request-&gt;Params;
 }
</pre></font>
	
	<p>
	<a name=%24Request-%3EQu7330a0a3></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->QueryString($name)</b></font>
<font face="courier new" size=3><pre>
</pre></font>Returns the value of the input of name $name used in a form
with GET method, or passed by appending a query string to the end of
a url as in <tt>http://localhost/?data=value.</tt>  
If $name is not specified, returns a ref to a hash of all the query 
string data.</font>
	
	<p>
	<a name=%24Request-%3ESe3a73f873></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>$Request->ServerVariables($name)</b></font>
<font face="courier new" size=3><pre>
</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>



( run in 1.056 second using v1.01-cache-2.11-cpan-b16cb0d3907 )