From 41376fca5d9e0dc91e30e6ab8ca2e53b3ae1a8a3 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: 2025年11月24日 13:14:23 -0800 Subject: [PATCH] trivial: Use swob date-header helpers more Related-Change: Ia7c619fe563ab89ff5b1beb03219e763a8798cc9 Change-Id: I91723b349df5cec409ef000f0a397e180a9de7a2 Signed-off-by: Tim Burke --- swift/common/middleware/tempurl.py | 10 +++++----- swift/common/middleware/versioned_writes/legacy.py | 4 ++-- .../middleware/versioned_writes/object_versioning.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/swift/common/middleware/tempurl.py b/swift/common/middleware/tempurl.py index 0d1ff269d4..2e119e0b6b 100644 --- a/swift/common/middleware/tempurl.py +++ b/swift/common/middleware/tempurl.py @@ -300,7 +300,7 @@ __all__ = ['TempURL', 'filter_factory', from calendar import timegm from os.path import basename -from time import time, strftime, strptime, gmtime +from time import time, strptime from ipaddress import ip_address, ip_network from urllib.parse import parse_qs, urlencode @@ -311,7 +311,7 @@ from swift.common.http import is_success from swift.common.digest import get_allowed_digests, \ extract_digest_and_algorithm, DEFAULT_ALLOWED_DIGESTS, get_hmac from swift.common.swob import header_to_environ_key, HTTPUnauthorized, \ - HTTPBadRequest, wsgi_to_str + HTTPBadRequest, wsgi_to_str, date_header_format from swift.common.utils import split_path, \ streq_const_time, quote, get_logger, close_if_possible from swift.common.registry import register_swift_info, register_sensitive_param @@ -688,9 +688,9 @@ class TempURL(object): out_headers.append(('Content-Disposition', value)) # include Expires header for better cache-control - out_headers.append(('Expires', strftime( - "%a, %d %b %Y %H:%M:%S GMT", - gmtime(temp_url_expires)))) + out_headers.append(( + 'Expires', + date_header_format(temp_url_expires))) ctx._response_headers = out_headers start_response( ctx._response_status, diff --git a/swift/common/middleware/versioned_writes/legacy.py b/swift/common/middleware/versioned_writes/legacy.py index e2be1a0ace..047490f95a 100644 --- a/swift/common/middleware/versioned_writes/legacy.py +++ b/swift/common/middleware/versioned_writes/legacy.py @@ -242,7 +242,7 @@ from swift.common.http import ( is_success, is_client_error, HTTP_NOT_FOUND) from swift.common.swob import HTTPPreconditionFailed, HTTPServiceUnavailable, \ HTTPServerError, HTTPBadRequest, str_to_wsgi, bytes_to_wsgi, wsgi_quote, \ - wsgi_unquote + wsgi_unquote, DATE_HEADER_FORMAT_STRING from swift.common.exceptions import ( ListingIterNotFound, ListingIterError) @@ -461,7 +461,7 @@ class VersionedWritesContext(WSGIContext): 'x-timestamp', calendar.timegm(time.strptime( get_resp.headers['last-modified'], - '%a, %d %b %Y %H:%M:%S GMT'))) + DATE_HEADER_FORMAT_STRING))) vers_obj_name = self._build_versions_object_name( object_name, ts_source) diff --git a/swift/common/middleware/versioned_writes/object_versioning.py b/swift/common/middleware/versioned_writes/object_versioning.py index 2a29d25ebc..b2de5c9b5b 100644 --- a/swift/common/middleware/versioned_writes/object_versioning.py +++ b/swift/common/middleware/versioned_writes/object_versioning.py @@ -164,7 +164,7 @@ from swift.common.swob import HTTPPreconditionFailed, HTTPServiceUnavailable, \ HTTPBadRequest, str_to_wsgi, bytes_to_wsgi, wsgi_quote, \ wsgi_to_str, wsgi_unquote, Request, HTTPNotFound, HTTPException, \ HTTPRequestEntityTooLarge, HTTPInternalServerError, HTTPNotAcceptable, \ - HTTPConflict, HTTPLengthRequired + HTTPConflict, HTTPLengthRequired, DATE_HEADER_FORMAT_STRING from swift.common.storage_policy import POLICIES from swift.common.utils import get_logger, Timestamp, drain_and_close, \ config_true_value, close_if_possible, closing_if_possible, \ @@ -449,7 +449,7 @@ class ObjectContext(ObjectVersioningContext): 'x-timestamp', calendar.timegm(time.strptime( get_resp.headers['last-modified'], - '%a, %d %b %Y %H:%M:%S GMT'))) + DATE_HEADER_FORMAT_STRING))) vers_obj_name = self._build_versions_object_name( object_name, ts_source)

AltStyle によって変換されたページ (->オリジナル) /