mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
add InvalidURL exception - raised if port is given but empty or non-numeric
This commit is contained in:
parent
1ce0073a4e
commit
9d38997e8c
1 changed files with 7 additions and 1 deletions
|
@ -347,7 +347,10 @@ class HTTPConnection:
|
||||||
if port is None:
|
if port is None:
|
||||||
i = host.find(':')
|
i = host.find(':')
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
|
try:
|
||||||
port = int(host[i+1:])
|
port = int(host[i+1:])
|
||||||
|
except ValueError:
|
||||||
|
raise InvalidURL, "nonnumeric port: '%s'"%host[i+1:]
|
||||||
host = host[:i]
|
host = host[:i]
|
||||||
else:
|
else:
|
||||||
port = self.default_port
|
port = self.default_port
|
||||||
|
@ -808,6 +811,9 @@ class HTTPException(Exception):
|
||||||
class NotConnected(HTTPException):
|
class NotConnected(HTTPException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class InvalidURL(HTTPException):
|
||||||
|
pass
|
||||||
|
|
||||||
class UnknownProtocol(HTTPException):
|
class UnknownProtocol(HTTPException):
|
||||||
def __init__(self, version):
|
def __init__(self, version):
|
||||||
self.version = version
|
self.version = version
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue