Re: subrequest-run() doesn't send HTTP headers

2003-02-26 Thread Geoffrey Young


[EMAIL PROTECTED] wrote:
Hello list,

i'm trying to run a subrequest from within
a mod_perl content handler. The subrequest
is build from the request's 'lookup_file()'
method. Unfortunately, when i invoke the
'run()' method of the subrequest, no HTTP
headers are sent (even so the documentation
from 'Writing Apache Modules' claims that 'run()' 
  
  ... will do
  everything a response handler is supposed to, 
  including sending the HTTP headers and the 
  document body. 

  ... you must not send the HTTP header and 
  document body yourself ...
well, the Eagle book is a little out of date here

http://marc.theaimsgroup.com/?l=apache-modperlm=96687764724849w=2

subrequests do not include headers, so if you use $sub-run() to send the 
subrequest to the client you are required to send headers yourself.

to alter this behavior, use $sub-run(1).

see Recipe 3.16 in the Cookbook, which is available for free from Sams:

http://www.samspublishing.com/catalog/article.asp?product_id={B95F1178-BE9D-43A8-8061-6E351400EF7F}

HTH

--Geoff

Here's a short test case:

sub handler {
  my $req = shift;
  my $filename = /tmp/sample.html;

  my $sub = $req-lookup_file($filename);
  $status = $sub-status;
  if($status == 200)
{
  $ret = $sub-run;
}
   return ret;
}
Furthermore, if the filename given to 'lookup_uri()'
points to a directory, $sub-status will return '200'
but '$sub-run()' will return '301' (which is o.k. since
the filename should end with a '/' ...).
Any ideas?

  Raf Mattes




Re: subrequest-run() doesn't send HTTP headers

2003-02-26 Thread Geoffrey Young

to alter this behavior, use $sub-run(1).

see Recipe 3.16 in the Cookbook
whoops, that was supposed to be 3.15.

--Geoff



Re: subrequest-run() doesn't send HTTP headers

2003-02-26 Thread rm
On Wed, Feb 26, 2003 at 10:23:53AM -0500, Geoffrey Young wrote:
 
 
 
 well, the Eagle book is a little out of date here
 
 http://marc.theaimsgroup.com/?l=apache-modperlm=96687764724849w=2
 
 subrequests do not include headers, so if you use $sub-run() to send the 
 subrequest to the client you are required to send headers yourself.

which i can't, since i have no idea about the mime-type etc. of the
file ;-/

 to alter this behavior, use $sub-run(1).

Ah, thank's a _lot_, that did it. Now, the only question is: why isn't
that documented?

 see Recipe 3.16 in the Cookbook, which is available for free from Sams:
 
 http://www.samspublishing.com/catalog/article.asp?product_id={B95F1178-BE9D-43A8-8061-6E351400EF7F}

Nice doc-pointer.

 thanks a lot  

  Ralf Mattes



Re: subrequest-run() doesn't send HTTP headers

2003-02-26 Thread Geoffrey Young

subrequests do not include headers, so if you use $sub-run() to send the 
subrequest to the client you are required to send headers yourself.
which i can't, since i have no idea about the mime-type etc. of the
file ;-/
yes you do - the subrequest found out for you :)

$r-send_http_header($sub-content_type);

to alter this behavior, use $sub-run(1).
Ah, thank's a _lot_, that did it. Now, the only question is: why isn't
that documented?
um, it is documented... if you have the Cookbook :)

--Geoff



Re: subrequest-run() doesn't send HTTP headers

2003-02-26 Thread Stas Bekman

to alter this behavior, use $sub-run(1).


Ah, thank's a _lot_, that did it. Now, the only question is: why isn't
that documented?
Please submit a documentation patch for this. It should be somewhere in 
http://perl.apache.org/docs/1.0/api/



__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com