aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/filebackend/SwiftFileBackend.php
diff options
context:
space:
mode:
authorkalle <kalle@kodapan.se>2021-04-20 09:17:41 +0200
committerkalle <karl.wettin@wikimedia.se>2021-04-26 17:41:30 +0200
commita646366e7c2e36f5b995ca9efc9558ae56ab4f94 (patch)
treeb12340fd0b672d47e9c6c24a1320344946b9a7d7 /includes/libs/filebackend/SwiftFileBackend.php
parentdb888db7ff4b76203a86bf96a058273fdb340d33 (diff)
downloadmediawikicore-a646366e7c2e36f5b995ca9efc9558ae56ab4f94.tar.gz
mediawikicore-a646366e7c2e36f5b995ca9efc9558ae56ab4f94.zip
Allow x-delete-at and x-delete-after expiry headers
From: https://docs.openstack.org/swift/latest/overview_expiring_objects.html The swift-object-expirer offers scheduled deletion of objects. The Swift client would use the X-Delete-At or X-Delete-After headers during an object PUT or POST and the cluster would automatically quit serving that object at the specified time and would shortly thereafter remove the object from the system. Bug: T280496 Change-Id: I886f3cea51f80d820841f8548941ca02a0a514c3
Diffstat (limited to 'includes/libs/filebackend/SwiftFileBackend.php')
-rw-r--r--includes/libs/filebackend/SwiftFileBackend.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php
index f8e5ad588e21..0911e652a558 100644
--- a/includes/libs/filebackend/SwiftFileBackend.php
+++ b/includes/libs/filebackend/SwiftFileBackend.php
@@ -204,14 +204,19 @@ class SwiftFileBackend extends FileBackendStore {
// Normalize casing, and strip out illegal headers
foreach ( $headers as $name => $value ) {
$name = strtolower( $name );
- if ( !preg_match( '/^(x-)?content-(?!length$)/', $name ) ) {
+ if ( $name === 'x-delete-at' && is_numeric( $value ) ) {
+ // Expects a Unix Epoch date
+ $contentHeaders[$name] = $value;
+ } elseif ( $name === 'x-delete-after' && is_numeric( $value ) ) {
+ // Expects number of minutes time to live.
+ $contentHeaders[$name] = $value;
+ } elseif ( preg_match( '/^(x-)?content-(?!length$)/', $name ) ) {
// Only allow content-* and x-content-* headers (but not content-length)
- continue;
- } elseif ( $name === 'content-type' && !strlen( $value ) ) {
+ $contentHeaders[$name] = $value;
+ } elseif ( $name === 'content-type' && strlen( $value ) ) {
// This header can be set to a value but not unset for sanity
- continue;
+ $contentHeaders[$name] = $value;
}
- $contentHeaders[$name] = $value;
}
// By default, Swift has annoyingly low maximum header value limits
if ( isset( $contentHeaders['content-disposition'] ) ) {