httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Morris <supp...@bettercgi.com>
Subject Re: [Module Dev] Sending http request
Date Wed, 16 Jan 2008 22:23:17 GMT
  If the URL is on the same site, you can
use a subrequest.  Below is an example of
doing a subrequest. ap_run_sub_req only needs
to be run if you need the body of the response.
The headers can be accessed after calling
ap_sub_req_lookup_uri.  Authentication is
skipped for subrequests by default, so if you
need to run autentication call ap_get_basic_auth_pw
as below.  The copying of the authentication
and host headers probably isn't needed, but 
was something I put in before discovering the
need to call ap_get_basic_auth_pw.  I'm no 
expert - I only know what I read in Nick's
fabulous Apache modules book. :) 

subr = ap_sub_req_lookup_uri(r->uri, r, NULL);
apr_table_set( subr->headers_in, "Authorization",
apr_table_get(r->headers_in, "Authorization") );
apr_table_set( subr->headers_in, "Host", apr_table_get(r->headers_in,
"Host") );
ap_get_basic_auth_pw(subr, &sent_pw);
ap_log_rerror( APLOG_MARK, APLOG_ERR, 0, r, "sub request status: %i",
subr->status );
ap_run_sub_req(subr);

--
Ray B. Morris
support@bettercgi.com

Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/

Throttlebox - Intelligent Bandwidth Control
http://www.bettercgi.com/throttlebox/

Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php




On 01/16/2008 04:09:52 PM, karim Bendadda wrote:
> Thank you for replying. I will see your link and reply to the mailing
> list..perhaps this will help .
> 
> On Jan 16, 2008 3:42 PM, Eric Covener <covener@gmail.com> wrote:
> 
> > On Jan 16, 2008 9:36 AM, karim Bendadda <kakibend@gmail.com> wrote:
> > > Hi Everybody,
> > >
> > >      Have you any idea of an apr function wish *sends an HTTP
> request to
> > an
> > > url*?  I have a request request_rec and I need to send it to an
> http url
> > :
> > > http:\\url.com. I'd like something like :
> > *send_request(request_rec,url); *
> > >
> > > P.S: On my last mail (Request External Redirection) I asked you 
> to
> help
> > me
> > > for a redirection but I think that I need to send a new request!
> Sorry
> > for
> > > the inconvenience
> > >
> >
> > nothing that simple probably, but mod_serf in trunk might be of
> interest:
> >
> >
> > 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_serf.c?view=co
> >
> >
> >
> > --
> > Eric Covener
> > covener@gmail.com
> >
> 
> 
> 
> --
> Karim
> 


Mime
View raw message