]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add support for HTTP_X_AMZ_DECODED_CONTENT_LENGTH.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Sat, 29 Apr 2017 19:12:19 +0000 (21:12 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 7 Jun 2017 10:43:18 +0000 (12:43 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth_s3.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h

index d614de3f44b061ab087c9718ddebaa6e25fe1506..c70e3e72ea95cb68acef907edbf40dbf2acbf8a2 100644 (file)
@@ -1021,6 +1021,21 @@ size_t AWSv4ComplMulti::recv_body(char* const buf, const size_t buf_max)
 
 void AWSv4ComplMulti::modify_request_state(req_state* const s_rw)
 {
+  const char* const decoded_length = \
+    s_rw->info.env->get("HTTP_X_AMZ_DECODED_CONTENT_LENGTH");
+
+  if (!decoded_length) {
+    throw -EINVAL;
+  } else {
+    s_rw->length = decoded_length;
+    s_rw->content_length = parse_content_length(decoded_length);
+
+    if (s_rw->content_length < 0) {
+      ldout(cct, 10) << "negative AWSv4's content length, aborting" << dendl;
+      throw -EINVAL;
+    }
+  }
+
   /* Install the filter over rgw::io::RestfulClient. */
   AWS_AUTHv4_IO(s_rw)->add_filter(
     std::static_pointer_cast<io_base_t>(shared_from_this()));
index 0a2a565dd931514b3c787460f1df625f7f699641..506c1cf5f018060c18dc4e92a87218ea7fb7efa6 100644 (file)
@@ -3271,14 +3271,10 @@ void RGWPutObj::execute()
     }
   }
 
-#if 0
-  if (!chunked_upload &&
-      ofs != s->content_length &&
-      !s->aws4_auth_streaming_mode) {
+  if (!chunked_upload && ofs != s->content_length) {
     op_ret = -ERR_REQUEST_TIMEOUT;
     goto done;
   }
-#endif
   s->obj_size = ofs;
 
   perfcounter->inc(l_rgw_put_b, s->obj_size);
index 4eb45aeb2d77d2a2ee7c2494819cf3663c65636e..8a4fa90a1973061dadb966ceb00a10453065bde8 100644 (file)
@@ -2035,7 +2035,7 @@ RGWRESTMgr::~RGWRESTMgr()
   delete default_mgr;
 }
 
-static int64_t parse_content_length(const char *content_length)
+int64_t parse_content_length(const char *content_length)
 {
   int64_t len = -1;
 
index 2d24eed9475a992d96d876096a9fc748e19b6a13..11c951e38b3038adf763750a9b2638811ab4fa36 100644 (file)
@@ -687,6 +687,7 @@ static inline void dump_header_if_nonempty(struct req_state* s,
 }
 
 extern void dump_content_length(struct req_state *s, uint64_t len);
+extern int64_t parse_content_length(const char *content_length);
 extern void dump_etag(struct req_state *s,
                       const boost::string_ref& etag,
                       bool quoted = false);