rgw_flush_formatter_and_reset(s, s->formatter);
}
+static void get_contype_from_attrs(map<string, bufferlist>& attrs,
+ string& content_type)
+{
+ map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_CONTENT_TYPE);
+ if (iter != attrs.end()) {
+ content_type = iter->second.c_str();
+ }
+}
+
+static void dump_object_metadata(struct req_state * const s,
+ map<string, bufferlist> attrs)
+{
+ map<string, string> response_attrs;
+ map<string, string>::const_iterator riter;
+ map<string, bufferlist>::iterator iter;
+
+ for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
+ const char *name = iter->first.c_str();
+ map<string, string>::const_iterator aiter = rgw_to_http_attrs.find(name);
+
+ if (aiter != rgw_to_http_attrs.end() &&
+ aiter->first.compare(RGW_ATTR_CONTENT_TYPE) != 0) {
+ /* Filter out Content-Type. It must be treated separately. */
+ response_attrs[aiter->second] = iter->second.c_str();
+ } else if (strncmp(name, RGW_ATTR_META_PREFIX, sizeof(RGW_ATTR_META_PREFIX)-1) == 0) {
+ name += sizeof(RGW_ATTR_META_PREFIX) - 1;
+ s->cio->print("X-Object-Meta-%s: %s\r\n", name, iter->second.c_str());
+ }
+ }
+
+ for (riter = response_attrs.begin(); riter != response_attrs.end(); ++riter) {
+ s->cio->print("%s: %s\r\n", riter->first.c_str(), riter->second.c_str());
+ }
+}
+
int RGWCopyObj_ObjStore_SWIFT::init_dest_policy()
{
dest_policy.create_default(s->user.user_id, s->user.display_name);
int RGWGetObj_ObjStore_SWIFT::send_response_data(bufferlist& bl, off_t bl_ofs, off_t bl_len)
{
- const char *content_type = NULL;
- map<string, string> response_attrs;
- map<string, string>::iterator riter;
+ string content_type;
if (sent_header)
goto send_data;
}
}
- for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- const char *name = iter->first.c_str();
- map<string, string>::iterator aiter = rgw_to_http_attrs.find(name);
- if (aiter != rgw_to_http_attrs.end()) {
- if (aiter->first.compare(RGW_ATTR_CONTENT_TYPE) == 0) { // special handling for content_type
- content_type = iter->second.c_str();
- continue;
- }
- response_attrs[aiter->second] = iter->second.c_str();
- } else {
- if (strncmp(name, RGW_ATTR_META_PREFIX, sizeof(RGW_ATTR_META_PREFIX)-1) == 0) {
- name += sizeof(RGW_ATTR_META_PREFIX) - 1;
- s->cio->print("X-Object-Meta-%s: %s\r\n", name, iter->second.c_str());
- }
- }
- }
+ get_contype_from_attrs(attrs, content_type);
+ dump_object_metadata(s, attrs);
}
set_req_state_err(s, (partial_content && !ret) ? STATUS_PARTIAL_CONTENT : ret);
dump_errno(s);
-
- for (riter = response_attrs.begin(); riter != response_attrs.end(); ++riter) {
- s->cio->print("%s: %s\r\n", riter->first.c_str(), riter->second.c_str());
- }
-
- if (!content_type)
- content_type = "binary/octet-stream";
- end_header(s, this, content_type);
+ end_header(s, this, !content_type.empty() ? content_type.c_str() : "binary/octet-stream");
sent_header = true;