]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_cr_rest: send content length on raw requests
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 27 Mar 2017 13:06:23 +0000 (15:06 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:03:10 +0000 (08:03 -0700)
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_cr_rest.h

index 165b4fa85a6f52a6d873750b06a3100173f6302f..812e3f084515d030e20ae5d26125a54c77b04f79 100644 (file)
@@ -94,17 +94,17 @@ class RGWSendRawRESTResourceCR: public RGWSimpleCoroutine {
   param_vec_t params;
   T *result;
   bufferlist input_bl;
-
+  bool send_content_length=false;
   boost::intrusive_ptr<RGWRESTSendResource> http_op;
 
  public:
  RGWSendRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
                           RGWHTTPManager *_http_manager,
                           const string& _method, const string& _path,
-                          rgw_http_param_pair *_params, bufferlist& _input, T *_result)
+                          rgw_http_param_pair *_params, bufferlist& _input, T *_result, bool _send_content_length)
    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
     method(_method), path(_path), params(make_param_list(_params)), result(_result),
-    input_bl(_input)
+    input_bl(_input), send_content_length(_send_content_length)
     {}
 
  RGWSendRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
@@ -126,8 +126,15 @@ class RGWSendRawRESTResourceCR: public RGWSimpleCoroutine {
   }
 
   int send_request() override {
+    param_vec_t p;
+    if (send_content_length){
+      lsubdout(cct, rgw, 0) << "abhi: sending content length of " << input_bl.length() << dendl;
+      string content_length = to_string(input_bl.length());
+      p.push_back(param_pair_t("CONTENT_LENGTH",content_length));
+    }
+
     auto op = boost::intrusive_ptr<RGWRESTSendResource>(
-        new RGWRESTSendResource(conn, method, path, params, NULL, http_manager));
+        new RGWRESTSendResource(conn, method, path, params, &p, http_manager));
 
     op->set_user_info((void *)stack);
 
@@ -209,7 +216,7 @@ class RGWPutRawRESTResourceCR: public RGWSendRawRESTResourceCR <T> {
                           RGWHTTPManager *_http_manager,
                           const string& _path,
                           rgw_http_param_pair *_params, bufferlist& _input, T *_result)
-    : RGWSendRawRESTResourceCR<T>(_cct, _conn, _http_manager, "PUT", _path, _params, _input, _result){}
+    : RGWSendRawRESTResourceCR<T>(_cct, _conn, _http_manager, "PUT", _path, _params, _input, _result, true){}
 
 };
 
@@ -222,8 +229,8 @@ public:
                         const string& _path,
                         rgw_http_param_pair *_params, S& _input, T *_result)
     : RGWSendRESTResourceCR<S, T>(_cct, _conn, _http_manager,
-                            "PUT", _path,
-                            _params, _input, _result) {}
+                                  "PUT", _path,
+                                  _params, _input, _result) {}
 };
 
 class RGWDeleteRESTResourceCR : public RGWSimpleCoroutine {