]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return required error when conent length missing on PUT
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 27 Jul 2011 23:04:36 +0000 (16:04 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 27 Jul 2011 23:05:10 +0000 (16:05 -0700)
src/rgw/rgw_common.h
src/rgw/rgw_rest.cc

index dfbecb13c87e4a666d394b0593b8273daac7b3ba..e688fba6f54f328b907ee573994b30766823b0bc 100644 (file)
@@ -100,6 +100,7 @@ extern string rgw_root_bucket;
 #define ERR_INVALID_PART_ORDER  2008
 #define ERR_NO_SUCH_UPLOAD      2009
 #define ERR_REQUEST_TIMEOUT     2010
+#define ERR_LENGTH_REQUIRED     2011
 
 #define ERR_USER_SUSPENDED      2100
 
index 75bf74730c6f1d56c4e5c2a5c5e7b9202ef5d357..d159bc968b5daacdfc20a9d234573a05f998fcb4 100644 (file)
@@ -37,6 +37,7 @@ const static struct rgw_html_errors RGW_HTML_ERRORS[] = {
     { ERR_INVALID_PART, 400, "InvalidPart" },
     { ERR_INVALID_PART_ORDER, 400, "InvalidPartOrder" },
     { ERR_REQUEST_TIMEOUT, 400, "RequestTimeout" },
+    { ERR_LENGTH_REQUIRED, 411, "MissingContentLength" },
     { EACCES, 403, "AccessDenied" },
     { EPERM, 403, "AccessDenied" },
     { ERR_USER_SUSPENDED, 403, "UserSuspended" },
@@ -700,9 +701,12 @@ int RGWHandler_REST::preprocess(struct req_state *s, FCGX_Request *fcgx)
 
   switch (s->op) {
   case OP_PUT:
-    if (!s->length || *s->length == '\0')
+    if (!s->length)
+      ret = -ERR_LENGTH_REQUIRED;
+    else if (*s->length == '\0')
       ret = -EINVAL;
-    s->content_length = atoll(s->length);
+    else
+      s->content_length = atoll(s->length);
     break;
   default:
     break;