[Python-bugs-list] [ python-Bugs-527064 ] bogus URLs cause exception in httplib
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 02 Jul 2002 10:08:13 -0700
Bugs item #527064, was opened at 2002-03-07 17:58
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=527064&group_id=5470
Category: Python Library
Group: Python 2.1.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Brian Cox (brian_cox)
Assigned to: Jeremy Hylton (jhylton)
Summary: bogus URLs cause exception in httplib
Initial Comment:
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
----------------------------------------------------------------------
>Comment By: Jeremy Hylton (jhylton)
Date: 2002-07-02 17:08
Message:
Logged In: YES
user_id=31392
Already fixed by Skip in rev 1.48 & 1.49.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=527064&group_id=5470