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
fc475a9f
Kaydet (Commit)
fc475a9f
authored
Nis 09, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #26609: Fix HTTP server tests to request an absolute URL path
üst
d0d51542
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
12 deletions
+29
-12
test_httpservers.py
Lib/test/test_httpservers.py
+29
-12
No files found.
Lib/test/test_httpservers.py
Dosyayı görüntüle @
fc475a9f
...
...
@@ -284,6 +284,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self
.
data
=
b
'We are the knights who say Ni!'
self
.
tempdir
=
tempfile
.
mkdtemp
(
dir
=
basetempdir
)
self
.
tempdir_name
=
os
.
path
.
basename
(
self
.
tempdir
)
self
.
base_url
=
'/'
+
self
.
tempdir_name
with
open
(
os
.
path
.
join
(
self
.
tempdir
,
'test'
),
'wb'
)
as
temp
:
temp
.
write
(
self
.
data
)
...
...
@@ -330,7 +331,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
filename
=
os
.
fsdecode
(
support
.
TESTFN_UNDECODABLE
)
+
'.txt'
with
open
(
os
.
path
.
join
(
self
.
tempdir
,
filename
),
'wb'
)
as
f
:
f
.
write
(
support
.
TESTFN_UNDECODABLE
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/'
)
response
=
self
.
request
(
self
.
base_url
+
'/'
)
if
sys
.
platform
==
'darwin'
:
# On Mac OS the HFS+ filesystem replaces bytes that aren't valid
# UTF-8 into a percent-encoded value.
...
...
@@ -344,27 +345,27 @@ class SimpleHTTPServerTestCase(BaseTestCase):
.
encode
(
enc
,
'surrogateescape'
),
body
)
self
.
assertIn
((
'>
%
s<'
%
html
.
escape
(
filename
))
.
encode
(
enc
,
'surrogateescape'
),
body
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/'
+
quotedname
)
response
=
self
.
request
(
self
.
base_url
+
'/'
+
quotedname
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
,
data
=
support
.
TESTFN_UNDECODABLE
)
def
test_get
(
self
):
#constructs the path relative to the root directory of the HTTPServer
response
=
self
.
request
(
self
.
tempdir_name
+
'/test'
)
response
=
self
.
request
(
self
.
base_url
+
'/test'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
,
data
=
self
.
data
)
# check for trailing "/" which should return 404. See Issue17324
response
=
self
.
request
(
self
.
tempdir_name
+
'/test/'
)
response
=
self
.
request
(
self
.
base_url
+
'/test/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
NOT_FOUND
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/'
)
response
=
self
.
request
(
self
.
base_url
+
'/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
)
response
=
self
.
request
(
self
.
tempdir_name
)
response
=
self
.
request
(
self
.
base_url
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
MOVED_PERMANENTLY
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/?hi=2'
)
response
=
self
.
request
(
self
.
base_url
+
'/?hi=2'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
)
response
=
self
.
request
(
self
.
tempdir_name
+
'?hi=1'
)
response
=
self
.
request
(
self
.
base_url
+
'?hi=1'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
MOVED_PERMANENTLY
)
self
.
assertEqual
(
response
.
getheader
(
"Location"
),
self
.
tempdir_name
+
"/?hi=1"
)
self
.
base_url
+
"/?hi=1"
)
response
=
self
.
request
(
'/ThisDoesNotExist'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
NOT_FOUND
)
response
=
self
.
request
(
'/'
+
'ThisDoesNotExist'
+
'/'
)
...
...
@@ -373,7 +374,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
data
=
b
"Dummy index file
\r\n
"
with
open
(
os
.
path
.
join
(
self
.
tempdir_name
,
'index.html'
),
'wb'
)
as
f
:
f
.
write
(
data
)
response
=
self
.
request
(
'/'
+
self
.
tempdir_name
+
'/'
)
response
=
self
.
request
(
self
.
base_url
+
'/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
,
data
)
# chmod() doesn't work as expected on Windows, and filesystem
...
...
@@ -381,14 +382,14 @@ class SimpleHTTPServerTestCase(BaseTestCase):
if
os
.
name
==
'posix'
and
os
.
geteuid
()
!=
0
:
os
.
chmod
(
self
.
tempdir
,
0
)
try
:
response
=
self
.
request
(
self
.
tempdir_name
+
'/'
)
response
=
self
.
request
(
self
.
base_url
+
'/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
NOT_FOUND
)
finally
:
os
.
chmod
(
self
.
tempdir
,
0
o755
)
def
test_head
(
self
):
response
=
self
.
request
(
self
.
tempdir_name
+
'/test'
,
method
=
'HEAD'
)
self
.
base_url
+
'/test'
,
method
=
'HEAD'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
)
self
.
assertEqual
(
response
.
getheader
(
'content-length'
),
str
(
len
(
self
.
data
)))
...
...
@@ -404,6 +405,22 @@ class SimpleHTTPServerTestCase(BaseTestCase):
response
=
self
.
request
(
'/'
,
method
=
'GETs'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
NOT_IMPLEMENTED
)
def
test_path_without_leading_slash
(
self
):
response
=
self
.
request
(
self
.
tempdir_name
+
'/test'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
,
data
=
self
.
data
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/test/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
NOT_FOUND
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
)
response
=
self
.
request
(
self
.
tempdir_name
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
MOVED_PERMANENTLY
)
response
=
self
.
request
(
self
.
tempdir_name
+
'/?hi=2'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
OK
)
response
=
self
.
request
(
self
.
tempdir_name
+
'?hi=1'
)
self
.
check_status_and_reason
(
response
,
HTTPStatus
.
MOVED_PERMANENTLY
)
self
.
assertEqual
(
response
.
getheader
(
"Location"
),
self
.
tempdir_name
+
"/?hi=1"
)
cgi_file1
=
"""
\
#!
%
s
...
...
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