Reflexive::Client::HTTP - A Reflex(ive) HTTP Client


version 0.007


  my $ua = Reflexive::Client::HTTP->new;

  for my $url (qw( )) {
      HTTP::Request->new( GET => $url ),
          sub { print $url." gave me a ".$_->code."\n" },



Reflexive::Client::HTTP is an HTTP user-agent for Reflex. At the current state it is only a wrapper around POE::Component::Client::HTTP, but we will try to assure stability to the API.



The useragent to use for the HTTP client. Defaults to the package name and the current version of it.


from holds an e-mail address where the client's administrator and/or maintainer may be reached. It defaults to undef, which means no From header will be included in requests.


protocol advertises the protocol that the client wishes to see. Under normal circumstances, it should be left to its default value: "HTTP/1.1".


So far see "Timeout" in POE::Component::Client::HTTP.


max_size specifies the largest response to accept from a server. The content of larger responses will be truncated to OCTET octets. This has been used to return the <head></head> section of web pages without the need to wade through <body></body>.


follow_redirects specifies how many redirects (e.g. 302 Moved) to follow. If not specified defaults to 0, and thus no redirection is followed. This maintains compatibility with the previous behavior, which was not to follow redirects at all.

If redirects are followed, a response chain should be built, and can be accessed through $event->response->previous() or $_->previous() if you use a callback on "request". See HTTP::Response for details here.


proxy specifies one or more proxy hosts that requests will be passed through. If not specified, proxy servers will be taken from the HTTP_PROXY (or http_proxy) environment variable. No proxying will occur unless proxy is set or one of the environment variables exists.

The proxy can be specified either as a host and port, or as one or more URLs. proxy URLs must specify the proxy port, even if it is 80.

  proxy => [ "", 80 ],
  proxy => "",

proxy may specify multiple proxies separated by commas. Reflexive::Client::HTTP will choose proxies from this list at random. This is useful for load balancing requests through multiple gateways.

  proxy => ",",


no_proxy specifies a list of server hosts that will not be proxied. It is useful for local hosts and hosts that do not properly support proxying. If no_proxy is not specified, a list will be taken from the NO_PROXY environment variable.

  no_proxy => [ "localhost", "" ],
  no_proxy => "localhost,",


Specify bind_addr to bind all client sockets to a particular local address.



This function takes as first argument a HTTP::Request and any additional number of arguments you want to give. If you are accessing the client via watches then the args are in the "args" in Reflexive::Client::HTTP::ResponseEvent attribute.

If you give as first additional argumnet a CodeRef, then this one gets executed instead of the emitting of the Reflexive::Client::HTTP::ResponseEvent. It gets all other additional arguments of the request call given as own arguments. Additionall we set $_ to the HTTP::Response object.

  $ua->request( HTTP::Request->new( GET => "" ), sub {
    print "DuckDuckGo gave me ".$_->code."\n";

If you require access to the HTTP::Request object via this method, you need to apply it as one of your arguments yourself on the call of request

A special feature of this fuction is the option to directly chain it. If you are using the CodeRef callback, you can return a new HTTP::Request from this CodeRef together with a new CodeRef and more arguments, to trigger another request for another callback.

  $ua->request( HTTP::Request->new( GET => "" ), sub {
    print "DuckDuckGo gave me ".$_->code."\n";
    return HTTP::Request->new( GET => "" ), sub {
      print "Perl gave me ".$_->code."\n";
      return HTTP::Request->new( GET => "" ), sub {
        print "MetaCPAN gave me ".$_->code."\n";



HTTP::Request HTTP::Response



Big thanks to dngor for helping me through the process to understand Reflex enough for making this. Most of this is based on his code.



  Join #reflex on Highlight Getty or dngor for fast reaction :).

  Pull request and additional contributors are welcome

Issue Tracker


Torsten Raudssus <>


This software is copyright (c) 2012 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.