]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: system user get obj returns JSON encoded metadata
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 17 Jun 2013 21:46:32 +0000 (14:46 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 17 Jun 2013 21:46:32 +0000 (14:46 -0700)
instead of binary encoded metadata

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_s3.cc

index d6ba18a55a296fe599c0cd89d447bd448a0ffb57..f45e1980f2abaf26ccdac7f7fde4e17c8c303bc4 100644 (file)
@@ -2320,14 +2320,14 @@ int RGWRados::copy_obj(void *ctx,
 
     bufferlist& extra_data_bl = processor.get_extra_data();
     if (extra_data_bl.length()) {
-      bufferlist::iterator iter = extra_data_bl.begin();
-      try {
-        ::decode(src_attrs, iter);
-      } catch (buffer::error& err) {
-        ldout(cct, 0) << "ERROR: failed to decode extra metadata info" << dendl;
-        return -EIO;
+      JSONParser jp;
+      if (!jp.parse(extra_data_bl.c_str(), extra_data_bl.length())) {
+        ldout(cct, 0) << "failed to parse response extra data. len=" << extra_data_bl.length() << " data=" << extra_data_bl.c_str() << dendl;
+        return -EINVAL;
       }
 
+      JSONDecoder::decode_json("attrs", src_attrs, &jp);
+
       src_attrs.erase(RGW_ATTR_MANIFEST); // not interested in original object layout
     }
 
index 8a67095bc278076afb4d10721f88e9d3fd0754ae..8912c0f5dab7b5c99a29ecea65e4efe8f972c681 100644 (file)
@@ -87,7 +87,15 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs, off_
 
   if (s->system_request &&
       s->info.args.exists(RGW_SYS_PARAM_PREFIX "prepend-metadata")) {
-    ::encode(attrs, metadata_bl);
+
+    /* JSON encode object metadata */
+    JSONFormatter jf;
+    jf.open_object_section("obj_metadata");
+    encode_json("attrs", attrs, &jf);
+    jf.close_section();
+    stringstream ss;
+    jf.flush(ss);
+    metadata_bl.append(ss.str());
     s->cio->print("Rgwx-Embedded-Metadata-Len: %lld\r\n", (long long)metadata_bl.length());
     total_len += metadata_bl.length();
   }