From: Radoslaw Zarzynski Date: Wed, 2 Mar 2016 21:00:24 +0000 (+0100) Subject: rgw: add support for overriding Content-Disposition in GET of Swift API. X-Git-Tag: v10.1.0~163^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26f9d694c48d77200563295b4f78bada95e0910e;p=ceph.git rgw: add support for overriding Content-Disposition in GET of Swift API. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 2ea635a205e1..a36484b7faa0 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index d12f86501424..8488288dcfc3 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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(),