Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
fcc8de05
Kaydet (Commit)
fcc8de05
authored
Agu 16, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[py3] Ported django.core.servers.
üst
8c356acf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
basehttp.py
django/core/servers/basehttp.py
+5
-3
tests.py
tests/regressiontests/builtin_server/tests.py
+14
-10
No files found.
django/core/servers/basehttp.py
Dosyayı görüntüle @
fcc8de05
...
...
@@ -7,6 +7,8 @@ This is a simple server for use in testing or debugging Django apps. It hasn't
been reviewed for security issues. DON'T USE IT FOR PRODUCTION USE!
"""
from
__future__
import
unicode_literals
import
os
import
socket
import
sys
...
...
@@ -71,12 +73,12 @@ class WSGIServerException(Exception):
class
ServerHandler
(
simple_server
.
ServerHandler
,
object
):
error_status
=
"500 INTERNAL SERVER ERROR"
error_status
=
str
(
"500 INTERNAL SERVER ERROR"
)
def
write
(
self
,
data
):
"""'write()' callable as specified by PEP 333"""
"""'write()' callable as specified by PEP 333
3
"""
assert
isinstance
(
data
,
str
),
"write() argument must be
string"
assert
isinstance
(
data
,
bytes
),
"write() argument must be byte
string"
if
not
self
.
status
:
raise
AssertionError
(
"write() before start_response()"
)
...
...
tests/regressiontests/builtin_server/tests.py
Dosyayı görüntüle @
fcc8de05
from
__future__
import
unicode_literals
from
io
import
BytesIO
from
django.core.servers.basehttp
import
ServerHandler
from
django.utils.six
import
StringIO
from
django.utils.unittest
import
TestCase
#
...
...
@@ -23,12 +26,12 @@ class FileWrapperHandler(ServerHandler):
return
True
def
wsgi_app
(
environ
,
start_response
):
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
'Hello World!'
]
start_response
(
str
(
'200 OK'
),
[(
str
(
'Content-Type'
),
str
(
'text/plain'
)
)])
return
[
b
'Hello World!'
]
def
wsgi_app_file_wrapper
(
environ
,
start_response
):
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
return
environ
[
'wsgi.file_wrapper'
](
StringIO
(
'foo'
))
start_response
(
str
(
'200 OK'
),
[(
str
(
'Content-Type'
),
str
(
'text/plain'
)
)])
return
environ
[
'wsgi.file_wrapper'
](
BytesIO
(
b
'foo'
))
class
WSGIFileWrapperTests
(
TestCase
):
"""
...
...
@@ -37,15 +40,16 @@ class WSGIFileWrapperTests(TestCase):
def
test_file_wrapper_uses_sendfile
(
self
):
env
=
{
'SERVER_PROTOCOL'
:
'HTTP/1.0'
}
err
=
StringIO
()
handler
=
FileWrapperHandler
(
None
,
StringIO
(),
err
,
env
)
handler
=
FileWrapperHandler
(
None
,
BytesIO
(),
BytesIO
(),
env
)
handler
.
run
(
wsgi_app_file_wrapper
)
self
.
assertTrue
(
handler
.
_used_sendfile
)
self
.
assertEqual
(
handler
.
stdout
.
getvalue
(),
b
''
)
self
.
assertEqual
(
handler
.
stderr
.
getvalue
(),
b
''
)
def
test_file_wrapper_no_sendfile
(
self
):
env
=
{
'SERVER_PROTOCOL'
:
'HTTP/1.0'
}
err
=
StringIO
()
handler
=
FileWrapperHandler
(
None
,
StringIO
(),
err
,
env
)
handler
=
FileWrapperHandler
(
None
,
BytesIO
(),
BytesIO
(),
env
)
handler
.
run
(
wsgi_app
)
self
.
assertFalse
(
handler
.
_used_sendfile
)
self
.
assertEqual
(
handler
.
stdout
.
getvalue
()
.
splitlines
()[
-
1
],
'Hello World!'
)
self
.
assertEqual
(
handler
.
stdout
.
getvalue
()
.
splitlines
()[
-
1
],
b
'Hello World!'
)
self
.
assertEqual
(
handler
.
stderr
.
getvalue
(),
b
''
)
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