]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/RGWRESTConn: Define a wrapper to send PUT/POST stream request
authorSoumya Koduri <skoduri@redhat.com>
Wed, 23 Jun 2021 15:46:24 +0000 (21:16 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 18 Nov 2021 07:22:48 +0000 (12:52 +0530)
Similar to "get_resource()", add an API "send_resource()" to send
PUT/POST/DELETE Stream request on RGWRestConn

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/rgw_rest_client.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index 4ffdb2cfe8ebc0f7558dd876561f82543171b147..7214babb9b9c8a66ea32860b13d9968e06a7ffec 100644 (file)
@@ -219,6 +219,14 @@ public:
                param_vec_t *_params, std::optional<std::string> _api_name) : RGWRESTStreamRWRequest(_cct, "HEAD", _url, _cb, _headers, _params, _api_name) {}
 };
 
+class RGWRESTStreamSendRequest : public RGWRESTStreamRWRequest {
+public:
+  RGWRESTStreamSendRequest(CephContext *_cct, const string& method, const string& _url,
+                           ReceiveCB *_cb, param_vec_t *_headers, param_vec_t *_params,
+                           std::optional<std::string> _api_name,
+                           HostStyle _host_style = PathStyle) : RGWRESTStreamRWRequest(_cct, method, _url, _cb, _headers, _params, _api_name, _host_style) {}
+};
+
 class RGWRESTStreamS3PutObj : public RGWHTTPStreamRWRequest {
   std::optional<std::string> api_name;
   HostStyle host_style;
index ff966d6ff3f76e074369f9197a2e3c9b10f82135..726bc58a5aaa870c768dbf2259fce97c2fa6f132 100644 (file)
@@ -376,6 +376,42 @@ int RGWRESTConn::get_resource(const DoutPrefixProvider *dpp,
   return req.complete_request(y);
 }
 
+int RGWRESTConn::send_resource(const DoutPrefixProvider *dpp, const string& method,
+                        const string& resource, rgw_http_param_pair *extra_params,
+                               map<string, string> *extra_headers, bufferlist& bl,
+                        bufferlist *send_data, RGWHTTPManager *mgr, optional_yield y)
+{
+  string url;
+  int ret = get_url(url);
+  if (ret < 0)
+    return ret;
+
+  param_vec_t params;
+
+  if (extra_params) {
+    params = make_param_list(extra_params);
+  }
+
+  populate_params(params, nullptr, self_zone_group);
+
+  RGWStreamIntoBufferlist cb(bl);
+
+  RGWRESTStreamSendRequest req(cct, method, url, &cb, NULL, &params, api_name, host_style);
+
+  map<string, string> headers;
+  if (extra_headers) {
+    headers.insert(extra_headers->begin(), extra_headers->end());
+  }
+
+  ret = req.send_request(dpp, &key, headers, resource, mgr, send_data);
+  if (ret < 0) {
+    ldpp_dout(dpp, 5) << __func__ << ": send_request() resource=" << resource << " returned ret=" << ret << dendl;
+    return ret;
+  }
+
+  return req.complete_request(y);
+}
+
 RGWRESTReadResource::RGWRESTReadResource(RGWRESTConn *_conn,
                                          const string& _resource,
                                         const rgw_http_param_pair *pp,
index e0e1b12abe5d7e5f350a1e69eb8f2331845f67e2..0dfd0c7415c173d1f6cfac252f632d1e4a4a3286 100644 (file)
@@ -200,6 +200,16 @@ public:
                    RGWHTTPManager *mgr,
                    optional_yield y);
 
+  int send_resource(const DoutPrefixProvider *dpp,
+                   const string& method,
+                   const string& resource,
+                          rgw_http_param_pair *extra_params,
+                   map<string, string>* extra_headers,
+                   bufferlist& bl,
+                   bufferlist *send_data,
+                   RGWHTTPManager *mgr,
+                   optional_yield y);
+
   template <class T>
   int get_json_resource(const DoutPrefixProvider *dpp, const std::string& resource, param_vec_t *params,
                         bufferlist *in_data, optional_yield y, T& t);