Jim, that might be the way to go. Mod_proxy and the subrequests pass the data back to the browser via an output filter. I believe you just want to see the data and not pass it back to the client. Libcurl should do exactly what you need.
Joe -- http://www.silverhawk.net/ On Jun 23, 2012 4:51 AM, <oh...@cox.net> wrote: > > ---- Sorin Manolache <sor...@gmail.com> wrote: > > On 2012-06-23 04:47, oh...@cox.net wrote: > > > Hi, > > > > > > Per earlier threads on this list, I've been working on an Apache > module. For the time being, I'm kind of stuck because of the problems that > I've run into with trying to integrate my module with a 3rd party library, > so just for my module, which is mainly a proof-of-concept, I'd like to have > my module do an HTTP GET request. > > > > > > So, I was wondering if anyone has some simple example code for doing > that from within a module, maybe using libcurl, or just natively using > sockets? > > > > > > I'm trying to do this myself, and I've been looking at using libcurl, > but most of the examples that I've seen use the "easy" setup, so if someone > has something like that that can be shared, it'd be a big help. > Conversely, if I figure it out, I'll post some working snippets here :)... > > > > > I'll say the same thing as Ben, try with apache, either mod_proxy or > > ap_run_sub_request. That if you make one outgoing request per incoming > > request. If you want several outgoing requests, in parallel preferably, > > per incoming request, then go with some 3rd-party library. > > > > I have some in-house C++ wrappers for libcurl (curl_multi_* + timeouts + > > client pools), but they are not straightforward to use, a lot of setup > > is involved, and they are not thoroughly tested. > > > > S > > Sorin and Ben, > > I'll take a look at mod_proxy.c later, but, FYI, I just tried the > following: > > - I added the following to my tweaked mod_headers.c: > > #include "curl/curl.h" > . > . > . > void callCurl() { > CURL *curl; > CURLcode res; > > curl = curl_easy_init(); > if(curl) { > curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com"); > res = curl_easy_perform(curl); > > /* always cleanup */ > curl_easy_cleanup(curl); > } > return; > } > > - I compiled with apxs, with no additonal -L or -l > > - I added a call to callCurl() in my code where I knew it'd get called. > > - In my httpd.conf, I added in front of the LoadModule for mod_headers: > > LoadFile /usr/lib64/libcurl.so.3.0.0 > > > Then I started Apache in single process (-k start -X), and it started, and > then I tested, and it worked!! > > For this prototype, I'll try to see if I can get this to the point that I > confirm what I'm doing, then I'll go back and look at mod_proxy.c to maybe > do native HTTP GET. > > Thanks, > Jim >