I have a need to override DNS lookup and to for a request to go to a specific IP address. I decided to try and create a HTTP::Request object with a dotted quad and to manually specify the host in headers. example:
--snip-- my $request = HTTP::Request->new(GET => 'http://10.1.0.1' ); $request->header('host' => 'vhost.behindfirewall.com'); $kernel->post( 'ua', 'request', 'response', $request ); --snip-- This did not work. I kept getting DNS resolve errors <html> <HEAD><TITLE>Error: Internal Server Error</TITLE></HEAD> <BODY> <H1>Error: Internal Server Error</H1> Cannot connect to 10.1.0.1:80 (resolve error ??: Host has no address.) </BODY> </HTML> After some fun playing with the perl debugger I got down to a section of the PoCo::Client::Keepalive code that I think is not correct with how it handles dotted quads. In _ka_resolve_request() there is this code # Skip DNS resolution if it's already a dotted quad. # TODO - Not all dotted quads are good. if ($host !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { DEBUG_DNS and warn "DNS: $host is a dotted quad; skipping lookup"; $kernel->call("$self", ka_add_to_queue => $request); return; } The comments say that if it is a dotted quad then skip resolution but that is not happening. I think the conditional needs to be inverted. Change the '!~' into a '=~'. After I made the change in my copy of PoCo::Client::Keepalive the dotted quad worked as expected.