POE-Declare-HTTP-Online
view release on metacpan or search on metacpan
lib/POE/Declare/HTTP/Online.pm view on Meta::CPAN
# A successful response should result in a redirect.
my $response = shift;
unless ( Params::Util::_INSTANCE($response, 'HTTP::Response') ) {
return 0;
}
unless ( $response->is_redirect ) {
return 0;
}
# Determine the location we are relocating to
my $request = $response->request;
my $location = $response->header('Location') or return 0;
my $uri = $HTTP::URI_CLASS->new($location);
unless ( Params::Util::_INSTANCE($uri, 'URI') and $uri->can('host') ) {
return 0;
}
# It should redirect to the matching www.domain.com for some given domain.com
my $original = quotemeta $request->uri->host;
unless ( $uri->host =~ /^(?:.+\.)?$original$/ ) {
( run in 0.622 second using v1.01-cache-2.11-cpan-5511b514fd6 )