This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bogus URLs cause exception in httplib
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: brian_cox, jhylton
Priority: normal Keywords:

Created on 2002-03-07 17:58 by brian_cox, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (2)
msg9569 - (view) Author: Brian Cox (brian_cox) Date: 2002-03-07 17:58
This is a partial HTTP header from IIS:

HTTP/1.1 302 Redirect
Server: Microsoft-IIS/5.0
Date: Wed, 06 Mar 2002 19:41:34 GMT
P3P: CP='ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo 
PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE 
PUR UNI'
Location: 
http://www.microsoft.comhttp://support.microsoft.com/de
fault.aspx?LN=RU

Notice the 'Location:'; this causes a ValueError 
exception in httplib in class HTTPConnection, method
_set_hostport(): port = int(host[i+1:])

I fixed this by doing:

  try: port = int(host[i+1:])
  except ValueError: raise InvalidHost(host)

and adding: 

class InvalidHost(HTTPException):
	def __init__(self, host):
		self.host = host
	def __str__(self):
		return "invalid host- '%s'" % self.host



msg9570 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-07-02 17:08
Logged In: YES 
user_id=31392

Already fixed by Skip in rev 1.48 & 1.49.
History
Date User Action Args
2022-04-10 16:05:04adminsetgithub: 36221
2002-03-07 17:58:29brian_coxcreate