httplib does not use "hosts" file (Windows)

Gilles Lenfant glenfant at nospam-e-pack.net
Sun Sep 10 16:41:35 EDT 2000


Hi,

Is it a bug or a feature of httplib

I'm running Python 1.5.2 on Windows
There is an Apache/Linux intranet server in my LAN which IP addr/name is in
"\winnt\system32\services\hosts" file (as usual when mixing Linux and
Windows in a LAN).

I can reach it by its name with IE or Netscape ("http://myintranetserver/")
But when I make a python script with httplib with:

h = httplib.HTTP('myintranetserver')
...
I got a "socket error : host not found"

It works when replacing the name by its IP address:
h = httplib.HTTP('192.168.0.15')

It seems that the HTTP __init__() looks for the DNS directly when other
network applications look for the system native host naming scheme.

Is there a workaround to make a name/IP translation for hosts that are not
recorded in the DNS.
Of course I can make a parsing of the "\winnt\system32\services\hosts" file
but if would be more comfortable to have the standard "httplib.HTTP" class
doing it at my place. Hear me Python development crew ? 8o)

I don't know if the same bug/feature is in the Python/Unix and I'll check it
when I shall have time.

Thanks in advance for a hint.





More information about the Python-list mailing list