summaryrefslogtreecommitdiff
path: root/swift/common/request_helpers.py
diff options
context:
space:
mode:
authoranc <alistair.coles@hp.com>2014-03-10 11:46:58 +0000
committerSamuel Merritt <sam@swiftstack.com>2014-08-01 16:41:33 -0700
commit4286f36a60446e322f23a329416be3ed67db1149 (patch)
tree79210705e13b00e59807d46dde52e41352581ccf /swift/common/request_helpers.py
parent3e78432cb1b37425e72c981690bcbcdf3138b5d8 (diff)
downloadswift-4286f36a60446e322f23a329416be3ed67db1149.tar.gz
Enable object system metadata on PUTs
This patch takes a first step towards support for object system metadata by enabling headers in the x-object-sysmeta- namespace to be persisted when objects are PUT. This should be useful for other pending patches such as on demand migration and server side encryption (https://review.openstack.org/#/c/64430/ and https://review.openstack.org/#/c/76578/1). The x-object-sysmeta- namespace is already reserved/protected by the gatekeeper and passed through the proxy. This patch modifies the object server to persist these headers alongside user metadata when an object is PUT. This patch will preserve existing object system metadata and ignore any new system metadata when handling object POSTs, including POST-as-copy operations. Support for modification of object system metadata with a POST request requires further work as discussed in the blueprint. This patch will preserve existing object system metadata and update it with new system metadata when copying an object. A new probe test is added which makes use of the BrainSplitter class that has been moved from test_container_merge_policy_index.py to a new module brain.py. blueprint object-system-metadata Change-Id: If716bc15730b7322266ebff4ab8dd31e78e4b962
Diffstat (limited to 'swift/common/request_helpers.py')
-rw-r--r--swift/common/request_helpers.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/swift/common/request_helpers.py b/swift/common/request_helpers.py
index c7677c11e..5ee246e55 100644
--- a/swift/common/request_helpers.py
+++ b/swift/common/request_helpers.py
@@ -225,6 +225,21 @@ def remove_items(headers, condition):
return removed
+def copy_header_subset(from_r, to_r, condition):
+ """
+ Will copy desired subset of headers from from_r to to_r.
+
+ :param from_r: a swob Request or Response
+ :param to_r: a swob Request or Response
+ :param condition: a function that will be passed the header key as a
+ single argument and should return True if the header
+ is to be copied.
+ """
+ for k, v in from_r.headers.items():
+ if condition(k):
+ to_r.headers[k] = v
+
+
def close_if_possible(maybe_closable):
close_method = getattr(maybe_closable, 'close', None)
if callable(close_method):