Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
89960404
Unverified
Commit
89960404
authored
May 13, 2023
by
Antonio Morillas
Committed by
GitHub
May 13, 2023
Browse files
Update servers.py
Checks Django version to make sure.
parent
5ea429bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
private_storage/servers.py
View file @
89960404
...
...
@@ -10,6 +10,7 @@ from urllib.parse import quote
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.http
import
FileResponse
,
HttpResponse
,
HttpResponseNotModified
from
django.utils
import
version
from
django.utils.http
import
http_date
from
django.utils.module_loading
import
import_string
from
django.views.static
import
serve
,
was_modified_since
...
...
@@ -61,8 +62,13 @@ class DjangoStreamingServer:
def
serve
(
private_file
):
# Support If-Last-Modified
mtime
=
private_file
.
modified_time
.
timestamp
()
if
not
was_modified_since
(
private_file
.
request
.
META
.
get
(
'HTTP_IF_MODIFIED_SINCE'
),
mtime
):
return
HttpResponseNotModified
()
size
=
private_file
.
size
if
version
.
get_main_version
()
>=
'4.1'
:
was_modified
=
was_modified_since
(
private_file
.
request
.
META
.
get
(
'HTTP_IF_MODIFIED_SINCE'
),
mtime
)
else
:
was_modified
=
was_modified_since
(
private_file
.
request
.
META
.
get
(
'HTTP_IF_MODIFIED_SINCE'
),
mtime
,
size
)
if
not
was_modified
:
return
HttpResponseNotModified
()
# As of Django 1.8, FileResponse triggers 'wsgi.file_wrapper' in Django's WSGIHandler.
# This uses efficient file streaming, such as sendfile() in uWSGI.
...
...
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