[boulder.pm] http/1.1 question

Walter Pienciak walter at frii.com
Mon Jan 31 23:16:43 CST 2000


On Mon, 31 Jan 2000, Ray Carlino wrote:

> I have a perl script that pares html pages for a text only output. It works
> great on netscape but IE uses http/1.1 and I get an error saying hostname not
> in header. How do I get the hostname for a vhost under apache? I am using ip
> based vhosts and they have different names.
> 
> Thanks
> Ray

Hi,

I'm not clear exactly what you're trying to do -- posting some code
might be helpful if I'm off-base where you're going.

It sounds like what you're asking is how to get the hostname for
an IP address?

use Socket;
$hostname = gethostbyaddr(inet_aton($ip_address), AF_INET);

But if you're doing this on your own systems, you can code the info into
a hash and it'll be much quicker and more robust:

%addresses = (
    "1.2.3.4"	=> "foo.bar.com",
    "1.2.3.5"	=> "baz.bar.com",
);
if ( defined $addresses{$ip_address} ) {
    $hostname = $addresses{$ip_address};
} else { 
    # your whoops function 
    print "Whoops!\n"; 	# Well, maybe something more better than this!
}

Walter





More information about the Boulder-pm mailing list