about using httplib on apache with virtual host

Oleg Broytmann phd at phd.pp.ru
Mon Dec 3 04:45:18 EST 2001


On Mon, Dec 03, 2001 at 05:25:30PM +0800, charles huang wrote:
> 	I write a program to get shtml with httplib. I found that it is ok if apache do not with virtual host,but it do not work if apache with virtual host. this is my code:
> 
> import httplib,os,string,sys
> fj_www = httplib.HTTP('www.fjii.com')
> fj_www.putrequest('GET', '/index.shtml')
> fj_www.putheader('Accept', 'text/html')
> fj_www.endheaders()
> #fj_www.send()
> errcode, errmsg, headers = fj_www.getreply()
> if (errcode!=200):
> 	print "it error!\n"
> 	sys.exit()
> www_f = fj_www.getfile()
> data = www_f.read() # Get the raw HTML
> www_f.close()
> print data
> 
> my code is error or httplib do not support virtual host?

   You forgot to notify Apache *which* of its virtual hosts you want to
touch ("Host:" header).

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list