]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add support for chunked upload
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 3 Nov 2011 18:24:57 +0000 (11:24 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 3 Nov 2011 18:29:32 +0000 (11:29 -0700)
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h
src/rgw/rgw_rest_swift.cc

index bf435cabba337eb599f6876e7749abf6ed95930c..5ba7ca2cc4a5fc90452ec7d961a15aa5bc34d461 100644 (file)
@@ -734,7 +734,7 @@ void RGWPutObj::execute()
     } while ( len > 0);
     drain_pending(pending);
 
-    if ((uint64_t)ofs != s->content_length) {
+    if (!chunked_upload && (uint64_t)ofs != s->content_length) {
       ret = -ERR_REQUEST_TIMEOUT;
       goto done_err;
     }
index 4e935855221a1a0a649665416a04ea0e37186a6b..6ffe2eaab8dd077f06dbb9a0e4689e2ecd0cc8e8 100644 (file)
@@ -237,6 +237,7 @@ protected:
   const char *supplied_md5_b64;
   const char *supplied_etag;
   string etag;
+  bool chunked_upload;
 
 public:
   RGWPutObj() {}
@@ -249,6 +250,7 @@ public:
     supplied_md5_b64 = NULL;
     supplied_etag = NULL;
     etag = "";
+    chunked_upload = false;
   }
   int verify_permission();
   void execute();
index ec3733efde903668896861493b0294c21934c716..b7cc69c1a032fd144f73dffeafcfeecbe0a5153a 100644 (file)
@@ -793,9 +793,7 @@ int RGWHandler_REST::preprocess(struct req_state *s, FCGX_Request *fcgx)
   switch (s->op) {
   case OP_PUT:
     if (s->object && !s->args.sub_resource_exists("acl")) {
-      if (!s->length)
-        ret = -ERR_LENGTH_REQUIRED;
-      else if (*s->length == '\0')
+      if (s->length && *s->length == '\0')
         ret = -EINVAL;
     }
     if (s->length)
index 9203f412d5e3730e051f0a3dacd7a3006f159061..d174daa1b8f47f14d15c939ff9cb307b5e156315 100644 (file)
@@ -197,6 +197,14 @@ void RGWDeleteBucket_REST_S3::send_response()
   end_header(s);
 }
 
+int RGWPutObj_REST_S3::get_params()
+{
+  if (!s->length)
+    return -ERR_LENGTH_REQUIRED;
+
+  return RGWPutObj_REST::get_params();
+}
+
 void RGWPutObj_REST_S3::send_response()
 {
   if (ret) {
@@ -718,6 +726,7 @@ int RGWHandler_REST_S3::authorize()
   dout(15) << "b64=" << b64 << dendl;
   dout(15) << "auth_sign=" << auth_sign << dendl;
   dout(15) << "compare=" << auth_sign.compare(b64) << dendl;
+
   if (auth_sign.compare(b64) != 0)
     return -EPERM;
 
index a2609519bf0a69cd0336ecb215d1561d132d9745..85b9e9cdebe9e664d92e7153161855d9a820f45d 100644 (file)
@@ -56,6 +56,7 @@ public:
   RGWPutObj_REST_S3() {}
   ~RGWPutObj_REST_S3() {}
 
+  int get_params();
   void send_response();
 };
 
index 99877bdfeb2441931a2d9db65585566eb23e619e..689d414adafa3a7bc8d39be5e87f630afacfc60a 100644 (file)
@@ -261,6 +261,16 @@ int RGWPutObj_REST_SWIFT::get_params()
   if (s->has_bad_meta)
     return -EINVAL;
 
+  if (!s->length) {
+    const char *encoding = s->env->get("HTTP_TRANSFER_ENCODING");
+dout(0) << "encoding=" << (void *)encoding << dendl;
+    if (strcmp(encoding, "chunked") != 0)
+      return -ERR_LENGTH_REQUIRED;
+dout(0) << "encoding=" << encoding << dendl;
+
+    chunked_upload = true;
+  }
+
   supplied_etag = s->env->get("HTTP_ETAG");
   return RGWPutObj_REST::get_params();
 }