Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ce6e0687
Kaydet (Commit)
ce6e0687
authored
May 16, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14132: Fix redirect handling when target is just a query string
üst
f95455da
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
+25
-5
test_urllib.py
Lib/test/test_urllib.py
+4
-3
test_urllib2.py
Lib/test/test_urllib2.py
+17
-1
request.py
Lib/urllib/request.py
+1
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
ce6e0687
"""Regresssion tests for
urllib
"""
"""Regresssion tests for
what was in Python 2's "urllib" module
"""
import
urllib.parse
import
urllib.parse
import
urllib.request
import
urllib.request
...
@@ -86,10 +86,11 @@ def fakehttp(fakedata):
...
@@ -86,10 +86,11 @@ def fakehttp(fakedata):
# buffer to store data for verification in urlopen tests.
# buffer to store data for verification in urlopen tests.
buf
=
None
buf
=
None
fakesock
=
FakeSocket
(
fakedata
)
def
connect
(
self
):
def
connect
(
self
):
self
.
sock
=
self
.
fakesock
self
.
sock
=
FakeSocket
(
self
.
fakedata
)
type
(
self
)
.
fakesock
=
self
.
sock
FakeHTTPConnection
.
fakedata
=
fakedata
return
FakeHTTPConnection
return
FakeHTTPConnection
...
...
Lib/test/test_urllib2.py
Dosyayı görüntüle @
ce6e0687
...
@@ -462,7 +462,7 @@ class MockHTTPHandler(urllib.request.BaseHandler):
...
@@ -462,7 +462,7 @@ class MockHTTPHandler(urllib.request.BaseHandler):
self
.
requests
=
[]
self
.
requests
=
[]
def
http_open
(
self
,
req
):
def
http_open
(
self
,
req
):
import
email
,
http
.
client
,
copy
import
email
,
copy
self
.
requests
.
append
(
copy
.
deepcopy
(
req
))
self
.
requests
.
append
(
copy
.
deepcopy
(
req
))
if
self
.
_count
==
0
:
if
self
.
_count
==
0
:
self
.
_count
=
self
.
_count
+
1
self
.
_count
=
self
.
_count
+
1
...
@@ -1208,6 +1208,22 @@ class HandlerTests(unittest.TestCase):
...
@@ -1208,6 +1208,22 @@ class HandlerTests(unittest.TestCase):
fp
=
o
.
open
(
'http://www.example.com'
)
fp
=
o
.
open
(
'http://www.example.com'
)
self
.
assertEqual
(
fp
.
geturl
(),
redirected_url
.
strip
())
self
.
assertEqual
(
fp
.
geturl
(),
redirected_url
.
strip
())
def
test_redirect_no_path
(
self
):
# Issue 14132: Relative redirect strips original path
real_class
=
http
.
client
.
HTTPConnection
response1
=
b
"HTTP/1.1 302 Found
\r\n
Location: ?query
\r\n\r\n
"
http
.
client
.
HTTPConnection
=
test_urllib
.
fakehttp
(
response1
)
self
.
addCleanup
(
setattr
,
http
.
client
,
"HTTPConnection"
,
real_class
)
urls
=
iter
((
"/path"
,
"/path?query"
))
def
request
(
conn
,
method
,
url
,
*
pos
,
**
kw
):
self
.
assertEqual
(
url
,
next
(
urls
))
real_class
.
request
(
conn
,
method
,
url
,
*
pos
,
**
kw
)
# Change response for subsequent connection
conn
.
__class__
.
fakedata
=
b
"HTTP/1.1 200 OK
\r\n\r\n
Hello!"
http
.
client
.
HTTPConnection
.
request
=
request
fp
=
urllib
.
request
.
urlopen
(
"http://python.org/path"
)
self
.
assertEqual
(
fp
.
geturl
(),
"http://python.org/path?query"
)
def
test_proxy
(
self
):
def
test_proxy
(
self
):
o
=
OpenerDirector
()
o
=
OpenerDirector
()
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com:3128"
))
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com:3128"
))
...
...
Lib/urllib/request.py
Dosyayı görüntüle @
ce6e0687
...
@@ -652,7 +652,7 @@ class HTTPRedirectHandler(BaseHandler):
...
@@ -652,7 +652,7 @@ class HTTPRedirectHandler(BaseHandler):
"
%
s - Redirection to url '
%
s' is not allowed"
%
(
msg
,
newurl
),
"
%
s - Redirection to url '
%
s' is not allowed"
%
(
msg
,
newurl
),
headers
,
fp
)
headers
,
fp
)
if
not
urlparts
.
path
:
if
not
urlparts
.
path
and
urlparts
.
netloc
:
urlparts
=
list
(
urlparts
)
urlparts
=
list
(
urlparts
)
urlparts
[
2
]
=
"/"
urlparts
[
2
]
=
"/"
newurl
=
urlunparse
(
urlparts
)
newurl
=
urlunparse
(
urlparts
)
...
...
Misc/NEWS
Dosyayı görüntüle @
ce6e0687
...
@@ -118,6 +118,9 @@ Core and Builtins
...
@@ -118,6 +118,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #14132: Fix urllib.request redirect handling when the target only has
a query string. Original fix by Ján Janech.
- Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch
- Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch
contributed by Chi Hsuan Yen.
contributed by Chi Hsuan Yen.
...
...
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