view release on metacpan or search on metacpan
POE::Component::Client::HTTP->spawn(
Agent => 'SpiffCrawler/0.90', # defaults to something long
Alias => 'ua', # defaults to 'weeble'
From => 'spiffster@perl.org', # defaults to undef (no header)
Protocol => 'HTTP/0.9', # defaults to 'HTTP/1.1'
Timeout => 60, # defaults to 180 seconds
MaxSize => 16384, # defaults to entire response
Streaming => 4096, # defaults to 0 (off)
FollowRedirects => 2, # defaults to 0 (off)
Proxy => "http://localhost:80", # defaults to HTTP_PROXY env. variable
NoProxy => [ "localhost", "127.0.0.1" ], # defs to NO_PROXY env. variable
BindAddr => "12.34.56.78", # defaults to INADDR_ANY
);
$kernel->post(
'ua', # posts to the 'ua' alias
'request', # posts to ua's 'request' state
'response', # which of our states will receive the response
$request, # an HTTP::Request object
);
Protocol => $http_protocol_string
"Protocol" advertises the protocol that the client wishes to see.
Under normal circumstances, it should be left to its default value:
"HTTP/1.1".
Proxy => [ $proxy_host, $proxy_port ]
Proxy => $proxy_url
Proxy => $proxy_url,$proxy_url,...
"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 => [ "127.0.0.1", 80 ],
Proxy => "http://127.0.0.1:80/",
"Proxy" may specify multiple proxies separated by commas.
PoCo::Client::HTTP will choose proxies from this list at random. This
Proxying will render X-PCCH-Peer nearly useless, since the socket will
be connected to a proxy rather than the server itself.
This feature was added at Doreen Grey's request. Doreen wanted a means
to find the remote server's address without having to make an additional
request.
ENVIRONMENT
POE::Component::Client::HTTP uses two standard environment variables:
HTTP_PROXY and NO_PROXY.
HTTP_PROXY sets the proxy server that Client::HTTP will forward requests
through. NO_PROXY sets a list of hosts that will not be forwarded
through a proxy.
See the Proxy and NoProxy constructor parameters for more information
about these variables.
SEE ALSO
This component is built upon HTTP::Request, HTTP::Response, and POE.
Please see its source code and the documentation for its foundation
modules to learn more. If you want to use cookies, you'll need to read
README.mkdn view on Meta::CPAN
POE::Component::Client::HTTP->spawn(
Agent => 'SpiffCrawler/0.90', # defaults to something long
Alias => 'ua', # defaults to 'weeble'
From => 'spiffster@perl.org', # defaults to undef (no header)
Protocol => 'HTTP/0.9', # defaults to 'HTTP/1.1'
Timeout => 60, # defaults to 180 seconds
MaxSize => 16384, # defaults to entire response
Streaming => 4096, # defaults to 0 (off)
FollowRedirects => 2, # defaults to 0 (off)
Proxy => "http://localhost:80", # defaults to HTTP_PROXY env. variable
NoProxy => [ "localhost", "127.0.0.1" ], # defs to NO_PROXY env. variable
BindAddr => "12.34.56.78", # defaults to INADDR_ANY
);
$kernel->post(
'ua', # posts to the 'ua' alias
'request', # posts to ua's 'request' state
'response', # which of our states will receive the response
$request, # an HTTP::Request object
);
lib/POE/Component/Client/HTTP.pm view on Meta::CPAN
POE::Component::Client::HTTP->spawn(
Agent => 'SpiffCrawler/0.90', # defaults to something long
Alias => 'ua', # defaults to 'weeble'
From => 'spiffster@perl.org', # defaults to undef (no header)
Protocol => 'HTTP/0.9', # defaults to 'HTTP/1.1'
Timeout => 60, # defaults to 180 seconds
MaxSize => 16384, # defaults to entire response
Streaming => 4096, # defaults to 0 (off)
FollowRedirects => 2, # defaults to 0 (off)
Proxy => "http://localhost:80", # defaults to HTTP_PROXY env. variable
NoProxy => [ "localhost", "127.0.0.1" ], # defs to NO_PROXY env. variable
BindAddr => "12.34.56.78", # defaults to INADDR_ANY
);
$kernel->post(
'ua', # posts to the 'ua' alias
'request', # posts to ua's 'request' state
'response', # which of our states will receive the response
$request, # an HTTP::Request object
);
lib/POE/Component/Client/HTTP.pm view on Meta::CPAN
"HTTP/1.1".
=item Proxy => [ $proxy_host, $proxy_port ]
=item Proxy => $proxy_url
=item Proxy => $proxy_url,$proxy_url,...
C<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 => [ "127.0.0.1", 80 ],
Proxy => "http://127.0.0.1:80/",
C<Proxy> may specify multiple proxies separated by commas.
PoCo::Client::HTTP will choose proxies from this list at random. This
lib/POE/Component/Client/HTTP.pm view on Meta::CPAN
Proxying will render X-PCCH-Peer nearly useless, since the socket will
be connected to a proxy rather than the server itself.
This feature was added at Doreen Grey's request. Doreen wanted a
means to find the remote server's address without having to make an
additional request.
=head1 ENVIRONMENT
POE::Component::Client::HTTP uses two standard environment variables:
HTTP_PROXY and NO_PROXY.
HTTP_PROXY sets the proxy server that Client::HTTP will forward
requests through. NO_PROXY sets a list of hosts that will not be
forwarded through a proxy.
See the Proxy and NoProxy constructor parameters for more information
about these variables.
=head1 SEE ALSO
This component is built upon HTTP::Request, HTTP::Response, and POE.
Please see its source code and the documentation for its foundation
lib/POE/Component/Client/HTTP/RequestFactory.pm view on Meta::CPAN
use POE::Component::Client::HTTP;
use constant {
FCT_AGENT => 0,
FCT_STREAMING => 1,
FCT_MAXSIZE => 2,
FCT_PROTOCOL => 3,
FCT_COOKIEJAR => 4,
FCT_FROM => 5,
FCT_NOPROXY => 6,
FCT_HTTP_PROXY => 7,
FCT_FOLLOWREDIRECTS => 8,
FCT_TIMEOUT => 9,
};
use constant DEBUG => 0;
use constant DEFAULT_BLOCK_SIZE => 4096;
=head1 NAME
lib/POE/Component/Client/HTTP/RequestFactory.pm view on Meta::CPAN
my $protocol = delete $params->{Protocol};
$protocol = 'HTTP/1.1' unless defined $protocol and length $protocol;
my $cookie_jar = delete $params->{CookieJar};
my $from = delete $params->{From};
my $no_proxy = delete $params->{NoProxy};
my $proxy = delete $params->{Proxy};
my $follow_redirects = delete $params->{FollowRedirects} || 0;
my $timeout = delete $params->{Timeout};
# Process HTTP_PROXY and NO_PROXY environment variables.
$proxy = $ENV{HTTP_PROXY} || $ENV{http_proxy} unless defined $proxy;
$no_proxy = $ENV{NO_PROXY} || $ENV{no_proxy} unless defined $no_proxy;
# Translate environment variable formats into internal versions.
$class->parse_proxy($proxy) if defined $proxy;
if (defined $no_proxy) {
unless (ref($no_proxy) eq 'ARRAY') {
$no_proxy = [ split(/\s*\,\s*/, $no_proxy) ];
}
lib/POE/Component/Client/HTTP/RequestFactory.pm view on Meta::CPAN
$timeout = 180 unless (defined $timeout and $timeout > 0);
my $self = [
$agent, # FCT_AGENT
$streaming, # FCT_STREAMING
$max_size, # FCT_MAXSIZE
$protocol, # FCT_PROTOCOL
$cookie_jar, # FCT_COOKIEJAR
$from, # FCT_FROM
$no_proxy, # FCT_NOPROXY
$proxy, # FCT_HTTP_PROXY
$follow_redirects, # FCT_FOLLOWREDIRECTS
$timeout, # FCT_TIMEOUT
];
return bless $self, $class;
}
=head1 METHODS
lib/POE/Component/Client/HTTP/RequestFactory.pm view on Meta::CPAN
# request URI.
#
# RCAPUTO 2006-03-23: We only support http proxying right now.
# Avoid proxying if this isn't an http request.
# TODO CONNECT - Create a PCCH::Request object in https-CONNECT mode
# if we're using https and there's an appropriate proxy.
my $proxy = $proxy_override;
if ($http_request->uri->scheme() eq "http") {
$proxy ||= $self->[FCT_HTTP_PROXY];
}
if (defined $proxy) {
# This request qualifies for proxying. Replace the host and port
# with the proxy's host and port. This comes after the Host:
# header is set, so it doesn't break the request object.
my $host = $http_request->uri->host;
undef $proxy if (
!defined($host) or
t/07_proxy.t view on Meta::CPAN
use POE::Component::Server::TCP;
use POE::Component::Client::HTTP;
use POE::Filter::HTTPD;
use HTTP::Request;
use HTTP::Request::Common qw(GET PUT);
use HTTP::Response;
# We need some control over proxying here.
BEGIN {
delete $ENV{HTTP_PROXY};
for (qw /HTTP_PROXY http_proxy NO_PROXY no_proxy/) {
delete $ENV{$_};
}
}
POE::Session->create(
inline_states => {
_child => sub { undef },
_stop => sub { undef },
_start => sub {
t/08_discard.t view on Meta::CPAN
use Socket;
POE::Component::Client::HTTP->spawn(
Alias => 'ua',
Timeout => 2,
);
# We are testing against a localhost server.
# Don't proxy, because localhost takes on new meaning.
BEGIN {
delete $ENV{HTTP_PROXY};
delete $ENV{http_proxy};
}
POE::Session->create(
inline_states => {
_start => sub {
my ($kernel) = $_[KERNEL];
$kernel->alias_set('Main');
t/14_gzipped_content.t view on Meta::CPAN
$response->decoded_content eq $original_content,
"gzip encoded transfers decode correctly"
);
},
],
);
# We are testing against a localhost server.
# Don't proxy, because localhost takes on new meaning.
BEGIN {
delete $ENV{HTTP_PROXY};
}
# Spawn one server per test response.
{
foreach (@tests) {
POE::Component::Server::TCP->new(
Alias => "server_$_",
Address => "127.0.0.1",
Port => 0,
Started => \®ister_port,
t/53_response_parser.t view on Meta::CPAN
$response->header("Transfer-Encoding") eq "zort, poit, narf",
"no known transfer encodings"
);
},
],
);
# We are testing against a localhost server.
# Don't proxy, because localhost takes on new meaning.
BEGIN {
delete $ENV{HTTP_PROXY};
}
# Spawn one server per test response.
{
foreach (@tests) {
POE::Component::Server::TCP->new(
Alias => "server_$_",
Address => "127.0.0.1",
Port => 0,
Started => \®ister_port,