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
0389295d
Commit
0389295d
authored
May 05, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better fix for newurl as suggested by Jim Jewett in SF bug #730963.
parent
f6b444ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
12 deletions
+2
-12
Lib/urllib2.py
Lib/urllib2.py
+2
-12
No files found.
Lib/urllib2.py
View file @
0389295d
...
...
@@ -408,7 +408,7 @@ class HTTPDefaultErrorHandler(BaseHandler):
raise
HTTPError
(
req
.
get_full_url
(),
code
,
msg
,
hdrs
,
fp
)
class
HTTPRedirectHandler
(
BaseHandler
):
def
redirect_request
(
self
,
req
,
fp
,
code
,
msg
,
headers
):
def
redirect_request
(
self
,
req
,
fp
,
code
,
msg
,
headers
,
newurl
):
"""Return a Request or None in response to a redirect.
This is called by the http_error_30x methods when a redirection
...
...
@@ -417,16 +417,6 @@ class HTTPRedirectHandler(BaseHandler):
raise HTTPError if no-one else should try to handle this url. Return
None if you can't but another Handler might.
"""
# XXX 301 and 302 errors must have a location or uri header.
# Not sure about the other error codes.
if
"location"
in
headers
:
newurl
=
headers
[
"location"
]
elif
"uri"
in
headers
:
newurl
=
headers
[
"uri"
]
else
:
return
newurl
=
urlparse
.
urljoin
(
req
.
get_full_url
(),
newurl
)
m
=
req
.
get_method
()
if
(
code
in
(
301
,
302
,
303
,
307
)
and
m
in
(
"GET"
,
"HEAD"
)
or
code
in
(
302
,
303
)
and
m
==
"POST"
):
...
...
@@ -455,7 +445,7 @@ class HTTPRedirectHandler(BaseHandler):
# XXX Probably want to forget about the state of the current
# request, although that might interact poorly with other
# handlers that also use handler-specific request attributes
new
=
self
.
redirect_request
(
req
,
fp
,
code
,
msg
,
headers
)
new
=
self
.
redirect_request
(
req
,
fp
,
code
,
msg
,
headers
,
newurl
)
if
new
is
None
:
return
...
...
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