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
49c44087
Kaydet (Commit)
49c44087
authored
Nis 12, 2011
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue11703 - urllib2.get_url does not handle fragment in url properly.
üst
7c9d3472
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
test_urllib.py
Lib/test/test_urllib.py
+10
-0
test_urllib2.py
Lib/test/test_urllib2.py
+14
-1
test_urllib2net.py
Lib/test/test_urllib2net.py
+1
-1
urllib2.py
Lib/urllib2.py
+5
-2
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
49c44087
...
...
@@ -148,6 +148,16 @@ class urlopen_HttpTests(unittest.TestCase):
finally
:
self
.
unfakehttp
()
def
test_url_fragment
(
self
):
# Issue #11703: geturl() omits fragments in the original URL.
url
=
'http://docs.python.org/library/urllib.html#OK'
self
.
fakehttp
(
'Hello!'
)
try
:
fp
=
urllib
.
urlopen
(
url
)
self
.
assertEqual
(
fp
.
geturl
(),
url
)
finally
:
self
.
unfakehttp
()
def
test_read_bogus
(
self
):
# urlopen() should raise IOError for many error codes.
self
.
fakehttp
(
'''HTTP/1.1 401 Authentication Required
...
...
Lib/test/test_urllib2.py
Dosyayı görüntüle @
49c44087
...
...
@@ -1007,6 +1007,15 @@ class HandlerTests(unittest.TestCase):
o
.
open
(
"http://www.example.com/"
)
self
.
assertTrue
(
not
hh
.
req
.
has_header
(
"Cookie"
))
def
test_redirect_fragment
(
self
):
redirected_url
=
'http://www.example.com/index.html#OK
\r\n\r\n
'
hh
=
MockHTTPHandler
(
302
,
'Location: '
+
redirected_url
)
hdeh
=
urllib2
.
HTTPDefaultErrorHandler
()
hrh
=
urllib2
.
HTTPRedirectHandler
()
o
=
build_test_opener
(
hh
,
hdeh
,
hrh
)
fp
=
o
.
open
(
'http://www.example.com'
)
self
.
assertEqual
(
fp
.
geturl
(),
redirected_url
.
strip
())
def
test_proxy
(
self
):
o
=
OpenerDirector
()
ph
=
urllib2
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com:3128"
))
...
...
@@ -1292,12 +1301,16 @@ class RequestTests(unittest.TestCase):
req
=
Request
(
"<URL:http://www.python.org>"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
())
def
test_url
with
_fragment
(
self
):
def
test_url_fragment
(
self
):
req
=
Request
(
"http://www.python.org/?qs=query#fragment=true"
)
self
.
assertEqual
(
"/?qs=query"
,
req
.
get_selector
())
req
=
Request
(
"http://www.python.org/#fun=true"
)
self
.
assertEqual
(
"/"
,
req
.
get_selector
())
# Issue 11703: geturl() omits fragment in the original URL.
url
=
'http://docs.python.org/library/urllib2.html#OK'
req
=
Request
(
url
)
self
.
assertEqual
(
req
.
get_full_url
(),
url
)
def
test_main
(
verbose
=
None
):
from
test
import
test_urllib2
...
...
Lib/test/test_urllib2net.py
Dosyayı görüntüle @
49c44087
...
...
@@ -160,7 +160,7 @@ class OtherNetworkTests(unittest.TestCase):
req
=
urllib2
.
Request
(
urlwith_frag
)
res
=
urllib2
.
urlopen
(
req
)
self
.
assertEqual
(
res
.
geturl
(),
"http://docs.python.org/glossary.html"
)
"http://docs.python.org/glossary.html
#glossary
"
)
def
test_fileno
(
self
):
req
=
urllib2
.
Request
(
"http://www.python.org"
)
...
...
Lib/urllib2.py
Dosyayı görüntüle @
49c44087
...
...
@@ -190,7 +190,7 @@ class Request:
origin_req_host
=
None
,
unverifiable
=
False
):
# unwrap('<URL:type://host/path>') --> 'type://host/path'
self
.
__original
=
unwrap
(
url
)
self
.
__original
,
fragment
=
splittag
(
self
.
__original
)
self
.
__original
,
self
.
__
fragment
=
splittag
(
self
.
__original
)
self
.
type
=
None
# self.__r_type is what's left after doing the splittype
self
.
host
=
None
...
...
@@ -236,7 +236,10 @@ class Request:
return
self
.
data
def
get_full_url
(
self
):
return
self
.
__original
if
self
.
__fragment
:
return
'
%
s#
%
s'
%
(
self
.
__original
,
self
.
__fragment
)
else
:
return
self
.
__original
def
get_type
(
self
):
if
self
.
type
is
None
:
...
...
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