httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lewis <...@joe-lewis.com>
Subject Re: Run Subrequest
Date Thu, 15 Oct 2009 15:32:50 GMT
Jens Frey wrote:
> Hi all,
>
> i am trying to run a subrequest to a URI which get's proxied to check the return code
of the 
> machine the proxy points to (e.g. 200, 500). The problem now is that the proxy module
answers the request,
> but the content i want to send is omitted, so the question is, how can i avoid that mod_proxy

> responds and instead my response is written, any ideas?
>   

I have done this before.  The way I accomplished this was to place a 
filter into the subrequest that copies the data into a structure you 
have for it, and doesn't pass the brigade on to the regular filters.  e.g. :

static apr_status_t include_output_filter(ap_filter_t *f, 
apr_bucket_brigade *bb) {
[loop through the buckets to get what you want, calling 
APR_BUCKET_REMOVE() after each]
}

Then, in your include function :

  ctx->include_filter = apr_palloc(f->r->pool,sizeof(ap_filter_t));
  ctx->include_filter->ctx = current_filter;
  ctx->include_filter->next = NULL;
  (ctx)->include_filter->r = f->r;
  (ctx)->include_filter->c = f->r->connection;
  (ctx)->include_filter->frec = 
apr_palloc(f->r->pool,sizeof(ap_filter_rec_t));
  memset((ctx)->include_filter->frec,0,sizeof(ap_filter_rec_t));
  (ctx)->include_filter->frec->name = "MYMOD-INCLUDE-WRAPPER";
  (ctx)->include_filter->frec->filter_func.out_func = 
&include_output_filter;
  (ctx)->include_filter->frec->next = NULL;
  (ctx)->include_filter->frec->ftype = AP_FTYPE_RESOURCE;

  (ctx)->include_r = ap_sub_req_lookup_uri(uri,f->r,(ctx)->include_filter);

This should give you what the subrequest returned, and since you use 
your own output filter that doesn't pass anything on, it won't send 
anything to the client.

Joe
-- 
Joe Lewis
Chief Nerd 	SILVERHAWK <http://www.silverhawk.net/> 	

------------------------------------------------------------------------
/Some say the glass is half empty, some say the glass is half full, I 
say, are you going to drink that?
    --Lisa Claymen/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message