]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix signing for some requests
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 27 May 2011 20:35:47 +0000 (13:35 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 27 May 2011 20:35:47 +0000 (13:35 -0700)
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index 9e9b5fb71b123f07c321544821f785145bab67c9..ba2640ab95756804715a39f5a510a02c5b5cb8eb 100644 (file)
@@ -109,13 +109,14 @@ int XMLArgs::parse()
     if (ret >= 0) {
       val_map[nv.get_name()] = nv.get_val();
 
-      if (ret > 0) { /* this might be a sub-resource */
-        if ((nv.get_name().compare("acl") == 0) ||
-            (nv.get_name().compare("location") == 0) ||
-            (nv.get_name().compare("uploads") == 0) ||
-            (nv.get_name().compare("versionid") == 0) ||
-            (nv.get_name().compare("torrent") == 0))
-          sub_resource = nv.get_name();
+      if ((nv.get_name().compare("acl") == 0) ||
+          (nv.get_name().compare("location") == 0) ||
+          (nv.get_name().compare("uploads") == 0) ||
+          (nv.get_name().compare("partNumber") == 0) ||
+          (nv.get_name().compare("uploadId") == 0) ||
+          (nv.get_name().compare("versionid") == 0) ||
+          (nv.get_name().compare("torrent") == 0)) {
+        sub_resources[nv.get_name()] = nv.get_val();
       }
     }
 
index fec011a12ad05fc8672ad5ab002c6150c8886702..68749d481d60332f0ceed95c66d9843c8badee6d 100644 (file)
@@ -119,12 +119,12 @@ class XMLArgs
 {
   string str, empty_str;
   map<string, string> val_map;
-  string sub_resource;
+  map<string, string> sub_resources;
  public:
    XMLArgs() {}
    XMLArgs(string s) : str(s) {}
    /** Set the arguments; as received */
-   void set(string s) { val_map.clear(); sub_resource.clear(); str = s; }
+   void set(string s) { val_map.clear(); sub_resources.clear(); str = s; }
    /** parse the received arguments */
    int parse();
    /** Get the value for a specific argument parameter */
@@ -135,7 +135,7 @@ class XMLArgs
      map<string, string>::iterator iter = val_map.find(name);
      return (iter != val_map.end());
    }
-   string& get_sub_resource() { return sub_resource; }
+   map<string, string>& get_sub_resources() { return sub_resources; }
 };
 
 enum http_op {
index 0286d6f4e2db13e6b29ba795454a04be14b1cfc2..5a26a0e238e0aa7c62fc4e5a773c5991c9d03c96 100644 (file)
@@ -354,11 +354,20 @@ static void get_canon_resource(struct req_state *s, string& dest)
 
   dest.append(s->path_name_url.c_str());
 
-  string& sub = s->args.get_sub_resource();
-  if (sub.size() > 0) {
-    dest.append("?");
-    dest.append(sub);
+  map<string, string>& sub = s->args.get_sub_resources();
+  map<string, string>::iterator iter;
+  for (iter = sub.begin(); iter != sub.end(); ++iter) {
+    if (iter == sub.begin())
+      dest.append("?");
+    else
+      dest.append("&");     
+    dest.append(iter->first);
+    if (!iter->second.empty()) {
+      dest.append("=");
+      dest.append(iter->second);
+    }
   }
+  RGW_LOG(0) << "dest=" << dest << dendl;
 }
 
 /*