httplib vs. urllib

Gerrit Holl gerrit.holl at pobox.com
Thu Dec 23 05:09:11 EST 1999


jim kraai wrote:
> Why is the output of:
> 	python httplib.py www.ni.dk
> 
> so _vastly_ different than the output of:
> 	python urllib http://www.ni.dk
> 
> This has me _completely_ stumped.

Because of virtual hosts.

Some servers have multiple "virtual hosts". For example, if you go to
ni.dk, you'll see something else than when you go to www.ni.dk. But it's
the same server.

That's because your browser gives a 'host' header:
Host: www.ni.dk

The server returns another page when you give that header.
httplib.py doesn't give that header,
urllib.py, which is on a higher level, does give that header.

regards,
Gerrit.

-- 
"If a machine couldn't run a free operating system, we got rid of it."

  -- Richard Stallman (Open Sources, 1999 O'Reilly and Associates)
 11:07am  up 25 min, 12 users,  load average: 0.00, 0.03, 0.13




More information about the Python-list mailing list