]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add support for overriding Content-Disposition in GET of Swift API.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 2 Mar 2016 21:00:24 +0000 (22:00 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 2 Mar 2016 22:41:40 +0000 (23:41 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_common.h
src/rgw/rgw_rest_swift.cc

index 2ea635a205e1f30938564713a1fd75218e26de4d..a36484b7faa0cddd867a59cf6d48864f82592fe6 100644 (file)
@@ -1221,6 +1221,11 @@ struct req_state {
   const char *os_auth_token;
   string swift_user;
   string swift_groups;
+  /* Content-Disposition override for TempURL of Swift API. */
+  struct {
+    string override;
+    string fallback;
+  } content_disp;
 
   string host_id;
 
index d12f8650142434365972d20d303eccd727bf5ad5..8488288dcfc384ab9ceb8c0facfdb6420a51ac9b 100644 (file)
@@ -881,6 +881,20 @@ static void dump_object_metadata(struct req_state * const s,
     }
   }
 
+  /* Handle override and fallback for Content-Disposition HTTP header.
+   * At the moment this will be used only by TempURL of the Swift API. */
+  const auto cditer = rgw_to_http_attrs.find(RGW_ATTR_CONTENT_DISP);
+  if (cditer != std::end(rgw_to_http_attrs)) {
+    const auto& name = cditer->second;
+
+    if (!s->content_disp.override.empty()) {
+      response_attrs[name] = s->content_disp.override;
+    } else if (!s->content_disp.fallback.empty()
+        && response_attrs.find(name) == std::end(response_attrs)) {
+      response_attrs[name] = s->content_disp.fallback;
+    }
+  }
+
   for (riter = response_attrs.begin(); riter != response_attrs.end();
        ++riter) {
     STREAM_IO(s)->print("%s: %s\r\n", riter->first.c_str(),