httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: mod_include supporting POST subrequests
Date Fri, 20 Mar 2009 20:14:54 GMT
Torsten Foertsch wrote:

> I need the include virtual directive to be able to issue POST requests. 
> It should pass the request body to the subrequest. So I came up with 
> the attached patch.
> 
> It allows to write
> 
>   <!--#include method="post" virtual="..." --> or
>   <!--#include method="inherit" virtual="..." -->
> 
> I think the patch is right so far but I wouldn't mind if some more 
> experienced eyes had a look.
> 
> One problem remains. What if the HTML author uses that method=post thing 
> twice? The first call has consumed the post body. The second will try 
> to read something but the client has already sent all it can.
> 
> Hence, I'd like to
> 
>   if (!eof_on_input()) {
>       rr->headers_in = r->headers_in;
>   }
> 
> How can I determine if the request body for the current request has 
> already been consumed?
> 
> Is there a chance that a patch like this will be accepted for inclusion 
> in apache?

Something like this has already been added to trunk, take a look at the 
KEEP_BODY and KEPT_BODY filters in modules/filters/mod_request.c.

To switch it on, define the KeptBodySize directive:

http://httpd.apache.org/docs/trunk/mod/mod_request.html#keptbodysize

When the body is kept, the request method is maintained across 
mod_include, so a POST to foo.shtml will stay a POST through 
<!--#include virtual="bar.cgi"-->. You can nest includes as deep as you 
like, the body is only set aside once.

Regards,
Graham
--

Mime
View raw message