httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sergeant <m...@sergeant.org>
Subject Re: Request singleton
Date Tue, 19 Dec 2000 09:00:00 GMT
On Mon, 18 Dec 2000, Jim Winstead wrote:

> you forgot the part of the patch that updates the documentation. :)
>
> (this also doesn't allow setting POST_MAX or DISABLE_UPLOADS. and
> what happens on a subrequest?)

OK, new patch:

Index: Request/Request.pm
===================================================================
RCS file: /home/cvs/httpd-apreq/Request/Request.pm,v
retrieving revision 1.9
diff -r1.9 Request.pm
28a29,39
> sub instance {
>     my $class = shift;
>     my $r = shift;
>     if (my $apreq = $r->pnotes('apreq')) {
>         return $apreq;
>     }
>     my $new_req = $class->new($r, @_);
>     $r->pnotes('apreq', $new_req);
>     return $new_req;
> }
>
92a104,129
>
> =item instance
>
> The instance() class method allows Apache::Request to be a singleton.
> This means that whenever you call Apache::Request->instance() 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.
>
>   my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1);
>
> Note that C<instance()> call will take the same parameters as the above
> call to C<new()>, however the parameters will only have an effect the
> first time C<instance()> is called within a single request. Extra
> parameters will be ignored on subsequent calls to C<instance()> within
> the same request.
>
> Subrequests receive a new Apache::Request object when they call
> instance() - the parent request's Apache::Request object is not copied
> into the subrequest.
>
> Also note that it is unwise to use the C<parse()> method when using
> C<instance()> because you may end up trying to call it twice, and
> detecting errors where there are none.


-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Mime
View raw message