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
a9189d27
Kaydet (Commit)
a9189d27
authored
Nis 25, 2018
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29353 -- Made StaticFilesHandler return a 404 response when settings.DEBUG is False
üst
c591bc3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
handlers.py
django/contrib/staticfiles/handlers.py
+2
-0
test_management.py
tests/staticfiles_tests/test_management.py
+13
-1
No files found.
django/contrib/staticfiles/handlers.py
Dosyayı görüntüle @
a9189d27
...
...
@@ -4,6 +4,7 @@ from urllib.request import url2pathname
from
django.conf
import
settings
from
django.contrib.staticfiles
import
utils
from
django.contrib.staticfiles.views
import
serve
from
django.core.handlers.exception
import
response_for_exception
from
django.core.handlers.wsgi
import
WSGIHandler
,
get_path_info
...
...
@@ -59,6 +60,7 @@ class StaticFilesHandler(WSGIHandler):
if
settings
.
DEBUG
:
from
django.views
import
debug
return
debug
.
technical_404_response
(
request
,
e
)
return
response_for_exception
(
request
,
e
)
return
super
()
.
get_response
(
request
)
def
__call__
(
self
,
environ
,
start_response
):
...
...
tests/staticfiles_tests/test_management.py
Dosyayı görüntüle @
a9189d27
...
...
@@ -16,7 +16,7 @@ from django.contrib.staticfiles.management.commands import (
)
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.management
import
CommandError
,
call_command
from
django.test
import
override_settings
from
django.test
import
RequestFactory
,
override_settings
from
django.test.utils
import
extend_sys_path
from
django.utils
import
timezone
from
django.utils._os
import
symlinks_supported
...
...
@@ -44,6 +44,18 @@ class TestRunserver(StaticFilesTestCase):
command
.
get_handler
(
use_static_handler
=
True
,
insecure_serving
=
True
)
self
.
assertEqual
(
mocked
.
call_count
,
1
)
def
test_404_response
(
self
):
command
=
runserver
.
Command
()
handler
=
command
.
get_handler
(
use_static_handler
=
True
,
insecure_serving
=
True
)
missing_static_file
=
os
.
path
.
join
(
settings
.
STATIC_URL
,
'unknown.css'
)
req
=
RequestFactory
()
.
get
(
missing_static_file
)
with
override_settings
(
DEBUG
=
False
):
response
=
handler
.
get_response
(
req
)
self
.
assertEqual
(
response
.
status_code
,
404
)
with
override_settings
(
DEBUG
=
True
):
response
=
handler
.
get_response
(
req
)
self
.
assertEqual
(
response
.
status_code
,
404
)
class
TestFindStatic
(
TestDefaults
,
CollectionTestCase
):
"""
...
...
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