summaryrefslogtreecommitdiff
path: root/swift/common/request_helpers.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2019-12-06 23:26:37 +0000
committerTim Burke <tim.burke@gmail.com>2020-01-02 15:48:39 -0800
commite8b654f318cfab485a772e19db33cb2fe4c3d858 (patch)
tree4eac1f5bb7277c8b1fa3345d253d38b78e005e7d /swift/common/request_helpers.py
parent7862ec7b8a7c56fffc32e0bfac3665f8b4f198dc (diff)
downloadswift-e8b654f318cfab485a772e19db33cb2fe4c3d858.tar.gz
Have slo tell the object-server that it wants whole manifests
Otherwise, we waste a request on some 416/206 response that won't be helpful. To do this, add a new X-Backend-Ignore-Range-If-Metadata-Present header whose value is a comma-separated list of header names. Middlewares may include this header to tell object-servers to send the whole object (rather than a 206 or 416) if *any* of the metadata are present. Have dlo and symlink use it, too; it won't save us any round-trips, but it should clean up some object-server logging. Change-Id: I4ff2a178d0456e7e37d561109ef57dd0d92cbd4e
Diffstat (limited to 'swift/common/request_helpers.py')
-rw-r--r--swift/common/request_helpers.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/swift/common/request_helpers.py b/swift/common/request_helpers.py
index bdc234c9e..876b8d809 100644
--- a/swift/common/request_helpers.py
+++ b/swift/common/request_helpers.py
@@ -808,3 +808,21 @@ def resolve_etag_is_at_header(req, metadata):
alternate_etag = metadata[name]
break
return alternate_etag
+
+
+def update_ignore_range_header(req, name):
+ """
+ Helper function to update an X-Backend-Ignore-Range-If-Metadata-Present
+ header whose value is a list of header names which, if any are present
+ on an object, mean the object server should respond with a 200 instead
+ of a 206 or 416.
+
+ :param req: a swob Request
+ :param name: name of a header which, if found, indicates the proxy will
+ want the whole object
+ """
+ if ',' in name:
+ # HTTP header names should not have commas but we'll check anyway
+ raise ValueError('Header name must not contain commas')
+ hdr = 'X-Backend-Ignore-Range-If-Metadata-Present'
+ req.headers[hdr] = csv_append(req.headers.get(hdr), name)