]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: swift list containers can return 204
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 26 Apr 2013 04:58:02 +0000 (21:58 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 26 Apr 2013 19:10:14 +0000 (12:10 -0700)
In order to keep compatibility with swift, if a plain formatter
is being used, we should return 204 when there are no containers.

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

index 35bff735dbd3ebe74c7251d0abb5293e6a255801..70d51f484d79b474f9828076079391a257496ed1 100644 (file)
@@ -666,7 +666,7 @@ void RGWListBuckets::execute()
                                 marker, read_count, should_get_stats());
 
     if (!started) {
-      send_response_begin();
+      send_response_begin(buckets.count() > 0);
       started = true;
     }
 
@@ -692,7 +692,7 @@ void RGWListBuckets::execute()
 
 send_end:
   if (!started) {
-    send_response_begin();
+    send_response_begin(false);
   }
   send_response_end();
 }
index f0f773b5ac829b093d94c2b9937fce12c0b94a42..b3e8c86e3f023dcdcd7c88f0b475294e7ac7bbbd 100644 (file)
@@ -140,7 +140,7 @@ public:
   void execute();
 
   virtual int get_params() = 0;
-  virtual void send_response_begin() = 0;
+  virtual void send_response_begin(bool has_buckets) = 0;
   virtual void send_response_data(RGWUserBuckets& buckets) = 0;
   virtual void send_response_end() = 0;
   virtual void send_response() {}
index 6866d17e8aa0b4c8a031378bd6d306b597bf93ad..38fab1bd2c1790f4697f642cd1b2246911af6ba3 100644 (file)
@@ -156,7 +156,7 @@ send_data:
   return 0;
 }
 
-void RGWListBuckets_ObjStore_S3::send_response_begin()
+void RGWListBuckets_ObjStore_S3::send_response_begin(bool has_buckets)
 {
   if (ret)
     set_req_state_err(s, ret);
index 16325978a7aab84885705a86f971e96656a06bda..bf97c1a29932e6af0dfcd93a55d9db93a9452b53 100644 (file)
@@ -26,7 +26,7 @@ public:
   ~RGWListBuckets_ObjStore_S3() {}
 
   int get_params() { return 0; }
-  virtual void send_response_begin();
+  virtual void send_response_begin(bool has_buckets);
   virtual void send_response_data(RGWUserBuckets& buckets);
   virtual void send_response_end();
 };
index 635bd2e7a013b63444410e383ad1267a429ac89c..f656bfb6821e92483dc96886bf0911233cfc7621 100644 (file)
@@ -43,10 +43,14 @@ int RGWListBuckets_ObjStore_SWIFT::get_params()
   return 0;
 }
 
-void RGWListBuckets_ObjStore_SWIFT::send_response_begin()
+void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets)
 {
-  if (ret)
+  if (ret) {
+    set_req_state_err(s, ret);
+  } else if (!has_buckets && s->format == RGW_FORMAT_PLAIN) {
+    ret = STATUS_NO_CONTENT;
     set_req_state_err(s, ret);
+  }
   dump_errno(s);
   end_header(s);
 
index e721f1cd1c183331b27a1d40a18a3e6271fcbed0..e4b6f0bccee1074683c236fd3fae80d12728e800 100644 (file)
@@ -20,7 +20,7 @@ public:
   ~RGWListBuckets_ObjStore_SWIFT() {}
 
   int get_params();
-  void send_response_begin();
+  void send_response_begin(bool has_buckets);
   void send_response_data(RGWUserBuckets& buckets);
   void send_response_end();