mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 10:42:58 -03:00
Merge pull request #1399 from easyteacher/develop
Make last_modified and if_date timezone-aware (Fix #1398)
This commit is contained in:
commit
1b5b6a6b71
1 changed files with 4 additions and 2 deletions
|
@ -25,7 +25,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from flask import Response, request, render_template, make_response, abort
|
from flask import Response, request, render_template, make_response, abort
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
from werkzeug.http import parse_date, http_date
|
from werkzeug.http import parse_date, http_date
|
||||||
|
@ -127,7 +127,7 @@ class ShareModeWeb(SendBaseModeWeb):
|
||||||
|
|
||||||
self.download_etag = None
|
self.download_etag = None
|
||||||
self.gzip_etag = None
|
self.gzip_etag = None
|
||||||
self.last_modified = datetime.utcnow()
|
self.last_modified = datetime.now(tz=timezone.utc)
|
||||||
|
|
||||||
def define_routes(self):
|
def define_routes(self):
|
||||||
"""
|
"""
|
||||||
|
@ -285,6 +285,8 @@ class ShareModeWeb(SendBaseModeWeb):
|
||||||
if_unmod = request.headers.get("If-Unmodified-Since")
|
if_unmod = request.headers.get("If-Unmodified-Since")
|
||||||
if if_unmod:
|
if if_unmod:
|
||||||
if_date = parse_date(if_unmod)
|
if_date = parse_date(if_unmod)
|
||||||
|
if if_date and not if_date.tzinfo:
|
||||||
|
if_date = if_date.replace(tzinfo=timezone.utc) # Compatible with Flask < 2.0.0
|
||||||
if if_date and if_date > last_modified:
|
if if_date and if_date > last_modified:
|
||||||
abort(412)
|
abort(412)
|
||||||
elif range_header is None:
|
elif range_header is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue