Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a5a9a9c3
Commit
a5a9a9c3
authored
Oct 18, 2011
by
Łukasz Langa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #10860: Handle empty port after port delimiter in httplib
parent
551ba20e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
Lib/http/client.py
Lib/http/client.py
+4
-1
Lib/test/test_httplib.py
Lib/test/test_httplib.py
+22
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/http/client.py
View file @
a5a9a9c3
...
...
@@ -678,7 +678,10 @@ class HTTPConnection:
try
:
port
=
int
(
host
[
i
+
1
:])
except
ValueError
:
raise
InvalidURL
(
"nonnumeric port: '%s'"
%
host
[
i
+
1
:])
if
host
[
i
+
1
:]
==
""
:
# http://foo.com:/ == http://foo.com/
port
=
self
.
default_port
else
:
raise
InvalidURL
(
"nonnumeric port: '%s'"
%
host
[
i
+
1
:])
host
=
host
[:
i
]
else
:
port
=
self
.
default_port
...
...
Lib/test/test_httplib.py
View file @
a5a9a9c3
...
...
@@ -161,14 +161,16 @@ class BasicTest(TestCase):
def
test_host_port
(
self
):
# Check invalid host_port
for
hp
in
(
"www.python.org:abc"
,
"
www.python.org:
"
):
for
hp
in
(
"www.python.org:abc"
,
"
user:password@www.python.org
"
):
self
.
assertRaises
(
client
.
InvalidURL
,
client
.
HTTPConnection
,
hp
)
for
hp
,
h
,
p
in
((
"[fe80::207:e9ff:fe9b]:8000"
,
"fe80::207:e9ff:fe9b"
,
8000
),
(
"www.python.org:80"
,
"www.python.org"
,
80
),
(
"www.python.org:"
,
"www.python.org"
,
80
),
(
"www.python.org"
,
"www.python.org"
,
80
),
(
"[fe80::207:e9ff:fe9b]"
,
"fe80::207:e9ff:fe9b"
,
80
)):
(
"[fe80::207:e9ff:fe9b]"
,
"fe80::207:e9ff:fe9b"
,
80
),
(
"[fe80::207:e9ff:fe9b]:"
,
"fe80::207:e9ff:fe9b"
,
80
)):
c
=
client
.
HTTPConnection
(
hp
)
self
.
assertEqual
(
h
,
c
.
host
)
self
.
assertEqual
(
p
,
c
.
port
)
...
...
@@ -539,6 +541,24 @@ class HTTPSTest(TestCase):
resp
=
h
.
getresponse
()
self
.
assertEqual
(
resp
.
status
,
404
)
def
test_host_port
(
self
):
# Check invalid host_port
for
hp
in
(
"www.python.org:abc"
,
"user:password@www.python.org"
):
self
.
assertRaises
(
client
.
InvalidURL
,
client
.
HTTPSConnection
,
hp
)
for
hp
,
h
,
p
in
((
"[fe80::207:e9ff:fe9b]:8000"
,
"fe80::207:e9ff:fe9b"
,
8000
),
(
"www.python.org:443"
,
"www.python.org"
,
443
),
(
"www.python.org:"
,
"www.python.org"
,
443
),
(
"www.python.org"
,
"www.python.org"
,
443
),
(
"[fe80::207:e9ff:fe9b]"
,
"fe80::207:e9ff:fe9b"
,
443
),
(
"[fe80::207:e9ff:fe9b]:"
,
"fe80::207:e9ff:fe9b"
,
443
)):
c
=
client
.
HTTPSConnection
(
hp
)
self
.
assertEqual
(
h
,
c
.
host
)
self
.
assertEqual
(
p
,
c
.
port
)
class
RequestBodyTest
(
TestCase
):
"""Test cases where a request includes a message body."""
...
...
Misc/NEWS
View file @
a5a9a9c3
...
...
@@ -137,6 +137,9 @@ Library
- Issue #12650: Fix a race condition where a subprocess.Popen could leak
resources (FD/zombie) when killed at the wrong time.
- Issue #10860: http.client now correctly handles an empty port after port
delimiter in URLs.
Tests
-----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment