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
5fee460b
Commit
5fee460b
authored
Jul 19, 2009
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for issue5102, timeout value propages between redirects, proxy, digest and
auth handlers. Fixed tests to reflect the same.
parent
5215875a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+6
-2
Lib/urllib2.py
Lib/urllib2.py
+4
-4
No files found.
Lib/test/test_urllib2.py
View file @
5fee460b
...
@@ -224,8 +224,8 @@ def test_password_manager_default_port(self):
...
@@ -224,8 +224,8 @@ def test_password_manager_default_port(self):
class
MockOpener
:
class
MockOpener
:
addheaders
=
[]
addheaders
=
[]
def
open
(
self
,
req
,
data
=
None
):
def
open
(
self
,
req
,
data
=
None
,
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
):
self
.
req
,
self
.
data
=
req
,
data
self
.
req
,
self
.
data
,
self
.
timeout
=
req
,
data
,
timeout
def
error
(
self
,
proto
,
*
args
):
def
error
(
self
,
proto
,
*
args
):
self
.
proto
,
self
.
args
=
proto
,
args
self
.
proto
,
self
.
args
=
proto
,
args
...
@@ -850,6 +850,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -850,6 +850,7 @@ class HandlerTests(unittest.TestCase):
method
=
getattr
(
h
,
"http_error_%s"
%
code
)
method
=
getattr
(
h
,
"http_error_%s"
%
code
)
req
=
Request
(
from_url
,
data
)
req
=
Request
(
from_url
,
data
)
req
.
add_header
(
"Nonsense"
,
"viking=withhold"
)
req
.
add_header
(
"Nonsense"
,
"viking=withhold"
)
req
.
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
if
data
is
not
None
:
if
data
is
not
None
:
req
.
add_header
(
"Content-Length"
,
str
(
len
(
data
)))
req
.
add_header
(
"Content-Length"
,
str
(
len
(
data
)))
req
.
add_unredirected_header
(
"Spam"
,
"spam"
)
req
.
add_unredirected_header
(
"Spam"
,
"spam"
)
...
@@ -878,6 +879,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -878,6 +879,7 @@ class HandlerTests(unittest.TestCase):
# loop detection
# loop detection
req
=
Request
(
from_url
)
req
=
Request
(
from_url
)
req
.
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
def
redirect
(
h
,
req
,
url
=
to_url
):
def
redirect
(
h
,
req
,
url
=
to_url
):
h
.
http_error_302
(
req
,
MockFile
(),
302
,
"Blah"
,
h
.
http_error_302
(
req
,
MockFile
(),
302
,
"Blah"
,
MockHeaders
({
"location"
:
url
}))
MockHeaders
({
"location"
:
url
}))
...
@@ -887,6 +889,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -887,6 +889,7 @@ class HandlerTests(unittest.TestCase):
# detect infinite loop redirect of a URL to itself
# detect infinite loop redirect of a URL to itself
req
=
Request
(
from_url
,
origin_req_host
=
"example.com"
)
req
=
Request
(
from_url
,
origin_req_host
=
"example.com"
)
count
=
0
count
=
0
req
.
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
try
:
try
:
while
1
:
while
1
:
redirect
(
h
,
req
,
"http://example.com/"
)
redirect
(
h
,
req
,
"http://example.com/"
)
...
@@ -898,6 +901,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -898,6 +901,7 @@ class HandlerTests(unittest.TestCase):
# detect endless non-repeating chain of redirects
# detect endless non-repeating chain of redirects
req
=
Request
(
from_url
,
origin_req_host
=
"example.com"
)
req
=
Request
(
from_url
,
origin_req_host
=
"example.com"
)
count
=
0
count
=
0
req
.
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
try
:
try
:
while
1
:
while
1
:
redirect
(
h
,
req
,
"http://example.com/%d"
%
count
)
redirect
(
h
,
req
,
"http://example.com/%d"
%
count
)
...
...
Lib/urllib2.py
View file @
5fee460b
...
@@ -600,7 +600,7 @@ class HTTPRedirectHandler(BaseHandler):
...
@@ -600,7 +600,7 @@ class HTTPRedirectHandler(BaseHandler):
fp.read()
fp.read()
fp.close()
fp.close()
return self.parent.open(new)
return self.parent.open(new
, timeout=req.timeout
)
http_error_301 = http_error_303 = http_error_307 = http_error_302
http_error_301 = http_error_303 = http_error_307 = http_error_302
...
@@ -716,7 +716,7 @@ class ProxyHandler(BaseHandler):
...
@@ -716,7 +716,7 @@ class ProxyHandler(BaseHandler):
# {'http': 'ftp://proxy.example.com'}, we may end up turning
# {'http': 'ftp://proxy.example.com'}, we may end up turning
# a request for http://acme.example.com/a into one for
# a request for http://acme.example.com/a into one for
# ftp://proxy.example.com/a
# ftp://proxy.example.com/a
return self.parent.open(req)
return self.parent.open(req
, timeout=req.timeout
)
class HTTPPasswordMgr:
class HTTPPasswordMgr:
...
@@ -832,7 +832,7 @@ class AbstractBasicAuthHandler:
...
@@ -832,7 +832,7 @@ class AbstractBasicAuthHandler:
if
req
.
headers
.
get
(
self
.
auth_header
,
None
)
==
auth
:
if
req
.
headers
.
get
(
self
.
auth_header
,
None
)
==
auth
:
return
None
return
None
req
.
add_header
(
self
.
auth_header
,
auth
)
req
.
add_header
(
self
.
auth_header
,
auth
)
return
self
.
parent
.
open
(
req
)
return
self
.
parent
.
open
(
req
,
timeout
=
req
.
timeout
)
else
:
else
:
return
None
return
None
...
@@ -923,7 +923,7 @@ class AbstractDigestAuthHandler:
...
@@ -923,7 +923,7 @@ class AbstractDigestAuthHandler:
if
req
.
headers
.
get
(
self
.
auth_header
,
None
)
==
auth_val
:
if
req
.
headers
.
get
(
self
.
auth_header
,
None
)
==
auth_val
:
return
None
return
None
req
.
add_unredirected_header
(
self
.
auth_header
,
auth_val
)
req
.
add_unredirected_header
(
self
.
auth_header
,
auth_val
)
resp
=
self
.
parent
.
open
(
req
)
resp
=
self
.
parent
.
open
(
req
,
timeout
=
req
.
timeout
)
return
resp
return
resp
def
get_cnonce
(
self
,
nonce
):
def
get_cnonce
(
self
,
nonce
):
...
...
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