You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@locus.apache.org on 2000/12/23 04:30:37 UTC
cvs commit: httpd-site/apreq Apache-Cookie.html Apache-Request.html index.html libapreq.html
jimw 00/12/22 19:30:37
Added: apreq Apache-Cookie.html Apache-Request.html index.html
libapreq.html
Log:
intro page and documentation for libapreq
Revision Changes Path
1.1 httpd-site/apreq/Apache-Cookie.html
Index: Apache-Cookie.html
===================================================================
<HTML>
<HEAD>
<TITLE>Apache::Cookie - HTTP Cookies Class</TITLE>
<LINK REV="made" HREF="mailto:perl@packages.debian.org">
</HEAD>
<BODY>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#methods">METHODS</A></LI>
<UL>
<LI><A HREF="#new">new</A></LI>
<LI><A HREF="#bake">bake</A></LI>
<LI><A HREF="#parse">parse</A></LI>
<LI><A HREF="#fetch">fetch</A></LI>
<LI><A HREF="#as_string">as_string</A></LI>
<LI><A HREF="#name">name</A></LI>
<LI><A HREF="#value">value</A></LI>
<LI><A HREF="#domain">domain</A></LI>
<LI><A HREF="#path">path</A></LI>
<LI><A HREF="#expires">expires</A></LI>
<LI><A HREF="#secure">secure</A></LI>
</UL>
<LI><A HREF="#see also">SEE ALSO</A></LI>
<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Apache::Cookie - HTTP Cookies Class</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
use Apache::Cookie ();
my $cookie = Apache::Cookie->new($r, ...);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>The Apache::Cookie module is a Perl interface to the cookie routines
in <EM>libapreq</EM>. The interface is based on Lincoln Stein's CGI::Cookie
module.</P>
<P>
<HR>
<H1><A NAME="methods">METHODS</A></H1>
<P>This interface is identical the to <EM>CGI::Cookie</EM> interface with one
exception noted below. Refer the to <EM>CGI::Cookie</EM> documentation while
these docs are ``under construction.''</P>
<P>
<H2><A NAME="new">new</A></H2>
<P>Just like CGI::Cookie::new, but requires an <EM>Apache</EM> request object:</P>
<PRE>
my $cookie = Apache::Cookie->new($r,
-name => 'foo',
-value => 'bar',
-expires => '+3M',
-domain => '.capricorn.com',
-path => '/cgi-bin/database',
-secure => 1
);</PRE>
<P>
<H2><A NAME="bake">bake</A></H2>
<P>Put cookie in the oven to bake.
(Add a <EM>Set-Cookie</EM> header to the outgoing headers table.)</P>
<PRE>
$cookie->bake;</PRE>
<P>
<H2><A NAME="parse">parse</A></H2>
<P>This method parses the given string if present, otherwise, the incoming
<EM>Cookie</EM> header:</P>
<PRE>
my $cookies = $cookie->parse; #hash ref</PRE>
<PRE>
my %cookies = $cookie->parse;</PRE>
<PRE>
my %cookies = $cookie->parse($cookie_string);</PRE>
<P>
<H2><A NAME="fetch">fetch</A></H2>
<P>Fetch and parse the incoming <EM>Cookie</EM> header:</P>
<PRE>
my $cookies = Apache::Cookie->fetch; #hash ref</PRE>
<PRE>
my %cookies = Apache::Cookie->fetch;</PRE>
<P>
<H2><A NAME="as_string">as_string</A></H2>
<P>Format the cookie object as a string:</P>
<PRE>
#same as $cookie->bake
$r->err_headers_out->add("Set-Cookie" => $cookie->as_string);</PRE>
<P>
<H2><A NAME="name">name</A></H2>
<P>Get or set the name of the cookie:</P>
<PRE>
my $name = $cookie->name;</PRE>
<PRE>
$cookie->name("Foo");</PRE>
<P>
<H2><A NAME="value">value</A></H2>
<P>Get or set the values of the cookie:</P>
<PRE>
my $value = $cookie->value;
my @values = $cookie->value;</PRE>
<PRE>
$cookie->value("string");
$cookie->value(\@array);</PRE>
<P>
<H2><A NAME="domain">domain</A></H2>
<P>Get or set the domain for the cookie:</P>
<PRE>
my $domain = $cookie->domain;
$cookie->domain(".cp.net");</PRE>
<P>
<H2><A NAME="path">path</A></H2>
<P>Get or set the path for the cookie:</P>
<PRE>
my $path = $cookie->path;
$cookie->path("/");</PRE>
<P>
<H2><A NAME="expires">expires</A></H2>
<P>Get or set the expire time for the cookie:</P>
<PRE>
my $expires = $cookie->expires;
$cookie->expires("+3h");</PRE>
<P>
<H2><A NAME="secure">secure</A></H2>
<P>Get or set the secure flag for the cookie:</P>
<PRE>
my $secure = $cookie->secure;
$cookie->secure(1);</PRE>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P>Apache(3), Apache::Request(3)</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Doug MacEachern</P>
</BODY>
</HTML>
1.1 httpd-site/apreq/Apache-Request.html
Index: Apache-Request.html
===================================================================
<HTML>
<HEAD>
<TITLE>Apache::Request - Methods for dealing with client request data</TITLE>
<LINK REV="made" HREF="mailto:perl@packages.debian.org">
</HEAD>
<BODY>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#apache::request methods">Apache::Request METHODS</A></LI>
<UL>
<LI><A HREF="#new">new</A></LI>
<LI><A HREF="#instance">instance</A></LI>
<LI><A HREF="#parse">parse</A></LI>
<LI><A HREF="#param">param</A></LI>
<LI><A HREF="#upload">upload</A></LI>
</UL>
<LI><A HREF="#apache::upload methods">Apache::Upload METHODS</A></LI>
<UL>
<LI><A HREF="#name">name</A></LI>
<LI><A HREF="#filename">filename</A></LI>
<LI><A HREF="#fh">fh</A></LI>
<LI><A HREF="#size">size</A></LI>
<LI><A HREF="#info">info</A></LI>
<LI><A HREF="#type">type</A></LI>
<LI><A HREF="#next">next</A></LI>
</UL>
<LI><A HREF="#see also">SEE ALSO</A></LI>
<LI><A HREF="#credits">CREDITS</A></LI>
<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Apache::Request - Methods for dealing with client request data</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
use Apache::Request ();
my $apr = Apache::Request->new($r);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P><EM>Apache::Request</EM> is a subclass of the <EM>Apache</EM> class, which adds methods
for parsing <STRONG>GET</STRONG> requests and <STRONG>POST</STRONG> requests where <EM>Content-type</EM>
is one of <EM>application/x-www-form-urlencoded</EM> or
<EM>multipart/form-data</EM>. See the <CODE>libapreq(3)</CODE> manpage for more details.</P>
<P>
<HR>
<H1><A NAME="apache::request methods">Apache::Request METHODS</A></H1>
<P>
<H2><A NAME="new">new</A></H2>
<P>Create a new <EM>Apache::Request</EM> object with an <EM>Apache</EM> request_rec object:</P>
<PRE>
my $apr = Apache::Request->new($r);</PRE>
<P>All methods from the <EM>Apache</EM> class are inherited.</P>
<P>The following attributes are optional:</P>
<DL>
<DT><STRONG><A NAME="item_POST_MAX">POST_MAX</A></STRONG><BR>
<DD>
Limit the size of POST data. <EM>Apache::Request::parse</EM> will return an
error code if the size is exceeded:
<PRE>
my $apr = Apache::Request->new($r, POST_MAX => 1024);
my $status = $apr->parse;</PRE>
<PRE>
if ($status) {
my $errmsg = $apr->notes("error-notes");
...
return $status;
}</PRE>
<P></P>
<DT><STRONG><A NAME="item_DISABLE_UPLOADS">DISABLE_UPLOADS</A></STRONG><BR>
<DD>
Disable file uploads. <EM>Apache::Request::parse</EM> will return an
error code if a file upload is attempted:
<PRE>
my $apr = Apache::Request->new($r, DISABLE_UPLOADS => 1);
my $status = $apr->parse;</PRE>
<PRE>
if ($status) {
my $errmsg = $apr->notes("error-notes");
...
return $status;
}</PRE>
<P></P></DL>
<P>
<H2><A NAME="instance">instance</A></H2>
<P>The <CODE>instance()</CODE> class method allows Apache::Request to be a singleton.
This means that whenever you call Apache::Request-><CODE>instance()</CODE> within a
single request you always get the same Apache::Request object back.
This solves the problem with creating the Apache::Request object twice
within the same request - the symptoms being that the second
Apache::Request object will not contain the form parameters because
they have already been read and parsed.</P>
<PRE>
my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1);</PRE>
<P>Note that <CODE>instance()</CODE> call will take the same parameters as the above
call to <CODE>new()</CODE>, however the parameters will only have an effect the
first time <CODE>instance()</CODE> is called within a single request. Extra
parameters will be ignored on subsequent calls to <CODE>instance()</CODE> within
the same request.</P>
<P>Subrequests receive a new Apache::Request object when they call
<CODE>instance()</CODE> - the parent request's Apache::Request object is not copied
into the subrequest.</P>
<P>Also note that it is unwise to use the <CODE>parse()</CODE> method when using
<CODE>instance()</CODE> because you may end up trying to call it twice, and
detecting errors where there are none.</P>
<P>
<H2><A NAME="parse">parse</A></H2>
<P>The <EM>parse</EM> method does the actual work of parsing the request.
It is called for you by the accessor methods, so it is not required but
can be useful to provide a more user-friendly message should an error
occur:
</P>
<PRE>
my $r = shift;
my $apr = Apache::Request->new($r);</PRE>
<PRE>
my $status = $apr->parse;
unless ($status == OK) {
$apr->custom_response($status, $apr->notes("error-notes"));
return $status;
}</PRE>
<P>
<H2><A NAME="param">param</A></H2>
<P>Get or set request parameters:</P>
<PRE>
my $value = $apr->param('foo');
my @values = $apr->param('foo');
my @params = $apr->param;
$apr->param('foo' => [qw(one two three)]);</PRE>
<P>
<H2><A NAME="upload">upload</A></H2>
<P>Returns a single <EM>Apache::Upload</EM> object in a scalar context or
all <EM>Apache::Upload</EM> objects in an array context:</P>
<PRE>
my $upload = $apr->upload;
my $fh = $upload->fh;
my $lines = 0;
while(<$fh>) {
++$lines;
...
}</PRE>
<P>An optional name parameter can be passed to return the <EM>Apache::Upload</EM>
object associated with the given name:</P>
<PRE>
my $upload = $apr->upload($name);</PRE>
<P>
<HR>
<H1><A NAME="apache::upload methods">Apache::Upload METHODS</A></H1>
<P>
<H2><A NAME="name">name</A></H2>
<P>The name of the filefield parameter:</P>
<PRE>
my $name = $upload->name;</PRE>
<P>
<H2><A NAME="filename">filename</A></H2>
<P>The filename of the uploaded file:</P>
<PRE>
my $filename = $upload->filename;</PRE>
<P>
<H2><A NAME="fh">fh</A></H2>
<P>The filehandle pointing to the uploaded file:</P>
<PRE>
my $fh = $upload->fh;
while (<$fh>) {
...
}</PRE>
<P>
<H2><A NAME="size">size</A></H2>
<P>The size of the file in bytes:</P>
<PRE>
my $size = $upload->size;</PRE>
<P>
<H2><A NAME="info">info</A></H2>
<P>The additional header information for the uploaded file.
Returns a hash reference tied to the <EM>Apache::Table</EM> class.
An optional <EM>key</EM> argument can be passed to return the value of
a given header rather than a hash reference. Examples:</P>
<PRE>
my $info = $upload->info;
while (my($key, $val) = each %$info) {
...
}</PRE>
<PRE>
my $val = $upload->info("Content-type");</PRE>
<P>
<H2><A NAME="type">type</A></H2>
<P>Returns the <EM>Content-Type</EM> for the given <EM>Apache::Upload</EM> object:</P>
<PRE>
my $type = $upload->type;
#same as
my $type = $upload->info("Content-Type");</PRE>
<P>
<H2><A NAME="next">next</A></H2>
<P>As an alternative to using the <EM>Apache::Request</EM> <EM>upload</EM> method in
an array context:</P>
<PRE>
for (my $upload = $apr->upload; $upload; $upload = $upload->next) {
...
}</PRE>
<PRE>
#functionally the same as:</PRE>
<PRE>
for my $upload ($apr->upload) {
...
}</PRE>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P><CODE>libapreq(3)</CODE></P>
<P>
<HR>
<H1><A NAME="credits">CREDITS</A></H1>
<P>This interface is based on the original pure Perl version by Lincoln Stein.</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Doug MacEachern</P>
</BODY>
</HTML>
1.1 httpd-site/apreq/index.html
Index: index.html
===================================================================
<html>
<head>
<title>libapreq - Generic Apache Request Library</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#cc00cc" alink="#cc0000">
<img src="../images/apache_sub.gif" width="500" height="62" alt="Apache">
<h1>libapreq - Generic Apache Request Library</h1>
<p>This package contains modules for manipulating client request
data via the Apache API with Perl and C. Functionality includes:</p>
<ul>
<li>parsing of application/x-www-form-urlencoded data</li>
<li>parsing of multipart/form-data</li>
<li>parsing of HTTP cookies</li>
</ul>
<p>You can view the documentation for the C interface <a
href="libapreq.html">here</a>.
<p>You can view the documentation for the perl interfaces <a
href="Apache-Request.html">here (Apache::Request and Apache::Upload)</a>
and <a href="Apache-Cookie.html">here (Apache::Cookie)</a>.
<hr noshade size="1">
<h2>News</h2>
<p><b>December 23, 2000</b> - libapreq-0.31_03 was released for testing.</p>
<p><b>December 17, 2000</b> - libapreq-0.31_02 was released for testing.</p>
<hr noshade size="1">
<h2>Downloads</h2>
<p>You can download the latest stable version of libapreq from:</p>
<ul>
<li><a href="/dist/">http://httpd.apache.org/dist/</a></li>
<li><a href="http://search.cpan.org/search?mode=module&query=libapreq">CPAN</a> ('perl -MCPAN -e "install libapreq"')
</ul>
<!-- TODO: provide information on getting latest source via public cvs server -->
<p>You can also browse through <a href="http://www.apache.org/websrc/viewcvs.cgi/httpd-apreq/">the CVS repository for libapreq</a>.</p>
<hr noshade size="1">
<h2>Mailing Lists</h2>
<p>There are two mailing lists devoted to the development of libapreq.</p>
<ul>
<li><a href="mailto:apreq-dev-subscribe@httpd.apache.org">apreq-dev@httpd.apache.org</a> - for discussion about the development of libapreq (low volume)</li>
<li><a href="mailto:apreq-cvs-subscribe@httpd.apache.org">apreq-cvs@httpd.apache.org</a> - when changes are commited to the cvs repository, cvs log messages are automatically sent to this list (low volume)</li>
</ul>
<hr noshade size="1">
<small>$Id: index.html,v 1.1 2000/12/23 03:30:36 jimw Exp $</small>
</table>
</body>
</html>
1.1 httpd-site/apreq/libapreq.html
Index: libapreq.html
===================================================================
<HTML>
<HEAD>
<TITLE>libapreq - Apache Request C Library</TITLE>
<LINK REV="made" HREF="mailto:perl@packages.debian.org">
</HEAD>
<BODY>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<LI><A HREF="#apacherequest">ApacheRequest</A></LI>
<UL>
<LI><A HREF="#apacherequest *apacherequest_new (request_rec *r)">ApacheRequest *ApacheRequest_new (request_rec *r)</A></LI>
<LI><A HREF="#int apacherequest_parse (apacherequest *req)">int ApacheRequest_parse (ApacheRequest *req)</A></LI>
<LI><A HREF="#const char *apacherequest_param (apacherequest *req, const char *key)">const char *ApacheRequest_param (ApacheRequest *req, const char *key)</A></LI>
<LI><A HREF="#array_header *apacherequest_params (apacherequest *req, const char *key)">array_header *ApacheRequest_params (ApacheRequest *req, const char *key)</A></LI>
<LI><A HREF="#char *apacherequest_params_as_string (apacherequest *req, const char *key)">char *ApacheRequest_params_as_string (ApacheRequest *req, const char *key)</A></LI>
<LI><A HREF="#apacheupload *upload = apacherequest_upload (apacherequest *req)">ApacheUpload *upload = ApacheRequest_upload (ApacheRequest *req)</A></LI>
</UL>
<LI><A HREF="#apacheupload">ApacheUpload</A></LI>
<UL>
<LI><A HREF="#apacheupload *apacheupload_find (apacheupload *upload, char *name)">ApacheUpload *ApacheUpload_find (ApacheUpload *upload, char *name)</A></LI>
<LI><A HREF="#const char *apacheupload_info (apacheupload *upload, char *key)">const char *ApacheUpload_info (ApacheUpload *upload, char *key)</A></LI>
<LI><A HREF="#const char *apacheupload_type (apacheupload *upload)">const char *ApacheUpload_type (ApacheUpload *upload)</A></LI>
</UL>
<LI><A HREF="#apachecookie">ApacheCookie</A></LI>
<UL>
<LI><A HREF="#apachecookie *apachecookie_new (request_rec *r, ...)">ApacheCookie *ApacheCookie_new (request_rec *r, ...)</A></LI>
<LI><A HREF="#char *apachecookie_attr (apachecookie *c, char *key, char *val)">char *ApacheCookie_attr (ApacheCookie *c, char *key, char *val)</A></LI>
<LI><A HREF="#apachecookiejar *apachecookie_parse (request_rec *r, const char *data)">ApacheCookieJar *ApacheCookie_parse (request_rec *r, const char *data)</A></LI>
<LI><A HREF="#int apachecookieitems (apachecookie *c)">int ApacheCookieItems (ApacheCookie *c)</A></LI>
<LI><A HREF="#char *apachecookiefetch (apachecookie *c, int n)">char *ApacheCookieFetch (ApacheCookie *c, int n)</A></LI>
<LI><A HREF="#void apachecookieadd (apachecookie *c, char *value)">void ApacheCookieAdd (ApacheCookie *c, char *value)</A></LI>
<LI><A HREF="#int apachecookiejaritems (apachecookiejar *cookies)">int ApacheCookieJarItems (ApacheCookieJar *cookies)</A></LI>
<LI><A HREF="#apachecookie *apachecookiejarfetch (apachecookiejar *cookies, int n)">ApacheCookie *ApacheCookieJarFetch (ApacheCookieJar *cookies, int n)</A></LI>
<LI><A HREF="#void apachecookiejaradd (apachecookiejar *cookies, apachecookie *c)">void ApacheCookieJarAdd (ApacheCookieJar *cookies, ApacheCookie *c)</A></LI>
<LI><A HREF="#char *apachecookie_expires (apachecookie *c, char *time_str)">char *ApacheCookie_expires (ApacheCookie *c, char *time_str)</A></LI>
<LI><A HREF="#void apachecookie_bake (apachecookie *c)">void ApacheCookie_bake (ApacheCookie *c)</A></LI>
<LI><A HREF="#char *apachecookie_as_string (apachecookie *c)">char *ApacheCookie_as_string (ApacheCookie *c)</A></LI>
</UL>
<LI><A HREF="#credits">CREDITS</A></LI>
<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>libapreq - Apache Request C Library</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>
<HR>
<H1><A NAME="apacherequest">ApacheRequest</A></H1>
<DL>
<DT><STRONG><A NAME="item_parms">req->parms</A></STRONG><BR>
<DD>
This field is an Apache <EM>table</EM> that holds the parsed contents of
<STRONG>GET</STRONG> and <STRONG>POST</STRONG> requests.
Example:
<PRE>
table *data = req->parms;
ap_table_set(data, "Key", "Value");</PRE>
<P></P>
<DT><STRONG><A NAME="item_post_max">req->post_max</A></STRONG><BR>
<DD>
Limit the size of POST data. <EM>ApacheRequest_parse</EM> will return an
error code if the size is exceeded:
<PRE>
int status;
ApacheRequest *req = ApacheRequest_new(r);</PRE>
<PRE>
req->post_max = 1204;
if((status = ApacheRequest_parse(req)) != OK) {
char *errmsg = ap_table_get(r->notes, "error-notes");
...
return status;
}</PRE>
<P></P>
<DT><STRONG><A NAME="item_disable_uploads">req->disable_uploads</A></STRONG><BR>
<DD>
Disable file uploads. <EM>ApacheRequest_parse</EM> will return an
error code if a file upload is attempted:
<PRE>
int status;
ApacheRequest *req = ApacheRequest_new(r);</PRE>
<PRE>
req->disable_uploads = 1;
if((status = ApacheRequest_parse(req)) != OK) {
char *errmsg = ap_table_get(r->notes, "error-notes");
...
return status;
}</PRE>
<P></P></DL>
<P>
<H2><A NAME="apacherequest *apacherequest_new (request_rec *r)">ApacheRequest *ApacheRequest_new (request_rec *r)</A></H2>
<P>This function creates a new <EM>ApacheRequest</EM> object using the given
<EM>request_rec</EM> structure:</P>
<PRE>
ApacheRequest *req = ApacheRequest_new(r);</PRE>
<P>
<H2><A NAME="int apacherequest_parse (apacherequest *req)">int ApacheRequest_parse (ApacheRequest *req)</A></H2>
<P>If the request method is <STRONG>GET</STRONG> or <STRONG>POST</STRONG>, the query string
arguments and the client form data will be read, parsed and saved.
In addition, if the request method is <STRONG>POST</STRONG> and the <EM>Content-type</EM> is
<EM>multipart/form-data</EM>, the uploaded files will be written to
temporary files which can be accessed with the <EM>upload</EM> field names.
The return value is <STRONG>OK</STRONG> on success, otherwise an error code that
your handler should return.</P>
<P>
<H2><A NAME="const char *apacherequest_param (apacherequest *req, const char *key)">const char *ApacheRequest_param (ApacheRequest *req, const char *key)</A></H2>
<P>This function will return the value of the given parameter <EM>key</EM>:</P>
<PRE>
const char *value = ApacheRequest_param(req, "Key");</PRE>
<P>
<H2><A NAME="array_header *apacherequest_params (apacherequest *req, const char *key)">array_header *ApacheRequest_params (ApacheRequest *req, const char *key)</A></H2>
<P>This function will return an <EM>array_header</EM> of values for the given
parameter <EM>key</EM>:</P>
<PRE>
array_header *values = ApacheRequest_params(req, "Key");</PRE>
<P>
<H2><A NAME="char *apacherequest_params_as_string (apacherequest *req, const char *key)">char *ApacheRequest_params_as_string (ApacheRequest *req, const char *key)</A></H2>
<P>This function will format multi-value parmeters into a comma delimited string.</P>
<PRE>
char *list = ApacheRequest_params_as_string(req, "Key");</PRE>
<P>
<H2><A NAME="apacheupload *upload = apacherequest_upload (apacherequest *req)">ApacheUpload *upload = ApacheRequest_upload (ApacheRequest *req)</A></H2>
<P>If the request <EM>Content-type</EM> was that of <EM>multipart/form-data</EM>,
this will return an <EM>ApacheUpload</EM> pointer containing the upload data,
<STRONG>NULL</STRONG> otherwise. See <EM>ApacheUpload</EM>.</P>
<PRE>
ApacheUpload *upload = ApacheRequest_upload(req);</PRE>
<P>
<HR>
<H1><A NAME="apacheupload">ApacheUpload</A></H1>
<P>The <EM>ApacheUpload</EM> structure holds all information for all uploaded
files and is accessed via the <EM>upload</EM> field of an <EM>ApacheRequest</EM>
structure.</P>
<DL>
<DT><STRONG><A NAME="item_name">upload->name</A></STRONG><BR>
<DD>
The name of the filefield parameter:
<PRE>
char *name = upload->name;</PRE>
<P></P>
<DT><STRONG><A NAME="item_filename">upload->filename</A></STRONG><BR>
<DD>
The name of the upload file:
<PRE>
char *filename = upload->filename;</PRE>
<P></P>
<DT><STRONG><A NAME="item_fp">upload->fp</A></STRONG><BR>
<DD>
A file pointer to the uploaded file:
<PRE>
FILE *fp = upload->fp;</PRE>
<P></P>
<DT><STRONG><A NAME="item_size">upload->size</A></STRONG><BR>
<DD>
The size of the uploaded file in bytes:
<PRE>
long size = upload->size;</PRE>
<P></P>
<DT><STRONG><A NAME="item_info">upload->info</A></STRONG><BR>
<DD>
The additional header information for the uploaded file:
<PRE>
table *info = upload->info;
const char *type = ap_table_get(info, "Content-type");</PRE>
<P></P>
<DT><STRONG><A NAME="item_next">upload->next</A></STRONG><BR>
<DD>
Pointer to the next <EM>ApacheUpload</EM> structure if multiple files were
uploaded:
<PRE>
ApacheUpload *uptr;
for (uptr = ApacheRequest_upload(req); uptr; uptr = uptr->next) {
char *name = uptr->name;
FILE *fp = uptr->fp;
...
}</PRE>
<P></P></DL>
<P>
<H2><A NAME="apacheupload *apacheupload_find (apacheupload *upload, char *name)">ApacheUpload *ApacheUpload_find (ApacheUpload *upload, char *name)</A></H2>
<P>Returns the <EM>ApacheUpload</EM> pointer associated with <EM>name</EM> or
<STRONG>NULL</STRONG> if <EM>name</EM> is not found in the list:</P>
<PRE>
ApacheUpload *upload = ApacheUpload_find(upload, name);</PRE>
<P>
<H2><A NAME="const char *apacheupload_info (apacheupload *upload, char *key)">const char *ApacheUpload_info (ApacheUpload *upload, char *key)</A></H2>
<P>Shortcut for accessing the <EM>info</EM> table:</P>
<PRE>
const char *type = ApacheUpload_info(upload, "Content-Type");</PRE>
<P>
<H2><A NAME="const char *apacheupload_type (apacheupload *upload)">const char *ApacheUpload_type (ApacheUpload *upload)</A></H2>
<P>Shortcut for accessing the uploaded file <EM>Content-Type</EM>:</P>
<PRE>
const char *type = ApacheUpload_type(upload);</PRE>
<P>
<HR>
<H1><A NAME="apachecookie">ApacheCookie</A></H1>
<P>
<H2><A NAME="apachecookie *apachecookie_new (request_rec *r, ...)">ApacheCookie *ApacheCookie_new (request_rec *r, ...)</A></H2>
<P>This function creates a new <EM>ApacheCookie</EM> object, using the given
<EM>request_request</EM> and optional attribute arguments which are as follows:</P>
<DL>
<DT><STRONG><A NAME="item_%2Dname">-name</A></STRONG><BR>
<DD>
Sets the <EM>name</EM> field to the given value.
<P></P>
<DT><STRONG><A NAME="item_%2Dvalue">-value</A></STRONG><BR>
<DD>
Adds the value to <EM>values</EM> field.
<P></P>
<DT><STRONG><A NAME="item_%2Dexpires">-expires</A></STRONG><BR>
<DD>
Sets the <EM>expires</EM> field to the calculated date string.
See <EM>ApacheCookie_expires</EM> for a listing of format options.
The default is <STRONG>NULL</STRONG>.
<P></P>
<DT><STRONG><A NAME="item_%2Ddomain">-domain</A></STRONG><BR>
<DD>
Sets the <EM>domain</EM> field to the given value.
The default is <STRONG>NULL</STRONG>.
<P></P>
<DT><STRONG><A NAME="item_%2Dpath">-path</A></STRONG><BR>
<DD>
Sets the <EM>path</EM> field to the given value.
The default <EM>path</EM> is derived from the requested <EM>uri</EM>.
<P></P>
<DT><STRONG><A NAME="item_%2Dsecure">-secure</A></STRONG><BR>
<DD>
Sets the <EM>secure</EM> field to true or false using a given string value
of <EM>On</EM> or <EM>Off</EM>.
The default is <EM>Off</EM>.
<P></P></DL>
<P>Example:</P>
<PRE>
ApacheCookie *c = ApacheCookie_new(r,
"-name", "foo",
"-value", "bar",
"-expires", "+3M",
"-domain", ".cp.net",
"-path", "/mypath/database",
"-secure", "On",
NULL);</PRE>
<P>
<H2><A NAME="char *apachecookie_attr (apachecookie *c, char *key, char *val)">char *ApacheCookie_attr (ApacheCookie *c, char *key, char *val)</A></H2>
<P>This function is used to get or set a cookie attribute pair, accepting
the same attributes as the list above. Example:</P>
<PRE>
char *name = ApacheCookie_attr(c, "-name"); /* same as c->name */
(void *)ApacheCookie_attr(c, "-expires", "+3h");</PRE>
<P>
<H2><A NAME="apachecookiejar *apachecookie_parse (request_rec *r, const char *data)">ApacheCookieJar *ApacheCookie_parse (request_rec *r, const char *data)</A></H2>
<P>This function parses the given <EM>data</EM> string or the incoming
<EM>Cookie</EM> header, returning an <EM>ApacheCookieJar</EM> of <EM>ApacheCookie</EM>
objects.</P>
<P>Example:</P>
<PRE>
int i;
ApacheCookieJar *cookies = ApacheCookie_parse(r, NULL);
for (i = 0; i < ApacheCookieJarItems(cookies); i++) {
ApacheCookie *c = ApacheCookieJarFetch(cookies, i);
int j;
for (j = 0; j < ApacheCookieItems(c); j++) {
char *name = c->name;
char *value = ApacheCookieFetch(c, j);
...
}
}</PRE>
<P>
<H2><A NAME="int apachecookieitems (apachecookie *c)">int ApacheCookieItems (ApacheCookie *c)</A></H2>
<P>The number of values for the given cookie.</P>
<P>
<H2><A NAME="char *apachecookiefetch (apachecookie *c, int n)">char *ApacheCookieFetch (ApacheCookie *c, int n)</A></H2>
<P>The <EM>n</EM>th value for the given cookie.</P>
<P>
<H2><A NAME="void apachecookieadd (apachecookie *c, char *value)">void ApacheCookieAdd (ApacheCookie *c, char *value)</A></H2>
<P>Add a new value to the cookie.</P>
<P>
<H2><A NAME="int apachecookiejaritems (apachecookiejar *cookies)">int ApacheCookieJarItems (ApacheCookieJar *cookies)</A></H2>
<P>The number of cookies in the given cookie jar.</P>
<P>
<H2><A NAME="apachecookie *apachecookiejarfetch (apachecookiejar *cookies, int n)">ApacheCookie *ApacheCookieJarFetch (ApacheCookieJar *cookies, int n)</A></H2>
<P>The <EM>n</EM>th cookie in the given cookie jar.</P>
<P>
<H2><A NAME="void apachecookiejaradd (apachecookiejar *cookies, apachecookie *c)">void ApacheCookieJarAdd (ApacheCookieJar *cookies, ApacheCookie *c)</A></H2>
<P>Add a new cookie to the cookie jar.</P>
<P>
<H2><A NAME="char *apachecookie_expires (apachecookie *c, char *time_str)">char *ApacheCookie_expires (ApacheCookie *c, char *time_str)</A></H2>
<P>This function gets or sets the expiration date for cookie.
The following forms are all valid for the <EM>time_str</EM> parmeter:</P>
<PRE>
+30s 30 seconds from now
+10m ten minutes from now
+1h one hour from now
-1d yesterday (i.e. "ASAP!")
now immediately
+3M in three months
+10y in ten years time
Thursday, 25-Apr-1999 00:40:33 GMT at the indicated time & date</PRE>
<P>
<H2><A NAME="void apachecookie_bake (apachecookie *c)">void ApacheCookie_bake (ApacheCookie *c)</A></H2>
<P>Put cookie in the oven to bake.
(Add a <EM>Set-Cookie</EM> header to the outgoing headers table.)</P>
<PRE>
ApacheCookie_bake(c);</PRE>
<P>
<H2><A NAME="char *apachecookie_as_string (apachecookie *c)">char *ApacheCookie_as_string (ApacheCookie *c)</A></H2>
<P>Returns a string version of the cookie:</P>
<PRE>
ap_table_add(r->headers_out, "Set-Cookie", ApacheCookie_as_string(c));</PRE>
<P>
<HR>
<H1><A NAME="credits">CREDITS</A></H1>
<P>This library is based on Perl modules by Lincoln Stein.</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Doug MacEachern</P>
</BODY>
</HTML>