Sending a HTTP request from within a plugin
brad at danga.com
Wed Jul 25 21:34:04 UTC 2007
There's no Danga::Socket-compatible HTTP client, and our POE/Danga:Socket
integration work isn't yet done, so at this point the only easy (and
recommended) option for you is to use Gearman. You can use
Gearman::Client::Async to use external gearmand servers/workers (which can
then do HTTP requests if needed), or you can embed a Gearman::Server in
the perlbal server process and have child processes under the perlbal
doing their work speaking Gearman protocol over pipes between parent/child
processes. Either way, you get persistent connections too, so rate of
requests isn't a problem.
On Wed, 25 Jul 2007, Robby Dermody wrote:
> Hi guys,
> I'm writing a perlbal plugin where when I receive a certain event
> (specifically, end_proxy_request), I need to make a HTTP request out to an
> external resource. Basically this is because the I have a reproxy setup
> going with perlbal and need to keep state in my environment around when a
> particular resource request starts and stops for each given client. The HTTP
> request will be very simple with only 1 or 2 GET parameters (no POST data),
> and I will just need to receive a single equally basic HTTP response, which
> should be a 200 OK.
> I was looking at the source and it looks like I could use Danga::Socket
> directly for this, however given the fact that these HTTP requests could be
> going out quite frequently (and all to the same host), I'd probably want to
> make the requests on a persistent connection (using KeepAlives).
> It's been a long time since I've worked in perl though, so I was wondering
> if there was a built in mechanism in perlbal or somewhere else I could use
> to make these requests, or some code I could start with to implement this.
More information about the perlbal