]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: helper to stat remote obj
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 3 Aug 2016 23:01:00 +0000 (16:01 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Oct 2016 17:31:18 +0000 (10:31 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_client.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index 424a956706b44bb457305874a90cc1e42584b51f..98e2b6af0a526e620b121f3ad0a1ca4826cd4629 100644 (file)
@@ -6776,7 +6776,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
 {
   /* source is in a different zonegroup, copy from there */
 
-  RGWRESTStreamReadRequest *in_stream_req;
+  RGWRESTStreamRWRequest *in_stream_req;
   string tag;
   map<string, bufferlist> src_attrs;
   int i;
@@ -6860,7 +6860,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
  
   ret = conn->get_obj(user_id, info, src_obj, pmod, unmod_ptr,
                       dest_mtime_weight.zone_short_id, dest_mtime_weight.pg_ver,
-                      true, &cb, &in_stream_req);
+                      true, true, &cb, &in_stream_req);
   if (ret < 0) {
     goto set_err_state;
   }
index 59df2c6c39b5decf4d55be759ade5c450658d583..6ceeb43f9b646fd40b722f0bb902b7a13960aca9 100644 (file)
@@ -121,5 +121,11 @@ public:
                param_vec_t *_params) : RGWRESTStreamRWRequest(_cct, "GET", _url, _cb, _headers, _params) {}
 };
 
+class RGWRESTStreamHeadRequest : public RGWRESTStreamRWRequest {
+public:
+  RGWRESTStreamHeadRequest(CephContext *_cct, const string& _url, RGWGetDataCB *_cb, param_vec_t *_headers,
+               param_vec_t *_params) : RGWRESTStreamRWRequest(_cct, "HEAD", _url, _cb, _headers, _params) {}
+};
+
 #endif
 
index ead41394f47a33cee9425d44c2de0f8e89f51831..4ed49d1db34be204ed215b0033d5790539c39d78 100644 (file)
@@ -118,7 +118,8 @@ static void set_header(T val, map<string, string>& headers, const string& header
 int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj,
                          const real_time *mod_ptr, const real_time *unmod_ptr,
                          uint32_t mod_zone_id, uint64_t mod_pg_ver,
-                         bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req)
+                         bool prepend_metadata, bool read_data,
+                         RGWGetDataCB *cb, RGWRESTStreamRWRequest **req)
 {
   string url;
   int ret = get_url(url);
@@ -137,7 +138,11 @@ int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw
     const string& instance = obj.get_instance();
     params.push_back(param_pair_t("versionId", instance));
   }
-  *req = new RGWRESTStreamReadRequest(cct, url, cb, NULL, &params);
+  if (read_data) {
+    *req = new RGWRESTStreamReadRequest(cct, url, cb, NULL, &params);
+  } else {
+    *req = new RGWRESTStreamHeadRequest(cct, url, cb, NULL, &params);
+  }
   map<string, string> extra_headers;
   if (info) {
     map<string, string, ltstr_nocase>& orig_map = info->env->get_map();
@@ -166,7 +171,7 @@ int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw
   return (*req)->get_obj(key, extra_headers, obj);
 }
 
-int RGWRESTConn::complete_request(RGWRESTStreamReadRequest *req, string& etag, real_time *mtime, map<string, string>& attrs)
+int RGWRESTConn::complete_request(RGWRESTStreamRWRequest *req, string& etag, real_time *mtime, map<string, string>& attrs)
 {
   int ret = req->complete(etag, mtime, attrs);
   delete req;
index 26229958dc89cc9f322367100f6ebe5623ddc612..1ef6385b20b3dfea4413ca279e5958b92e91849c 100644 (file)
@@ -89,8 +89,9 @@ public:
   int get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj,
               const ceph::real_time *mod_ptr, const ceph::real_time *unmod_ptr,
               uint32_t mod_zone_id, uint64_t mod_pg_ver,
-              bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req);
-  int complete_request(RGWRESTStreamReadRequest *req, string& etag, ceph::real_time *mtime, map<string, string>& attrs);
+              bool prepend_metadata, bool read_data,
+              RGWGetDataCB *cb, RGWRESTStreamRWRequest **req);
+  int complete_request(RGWRESTStreamRWRequest *req, string& etag, ceph::real_time *mtime, map<string, string>& attrs);
 
   int get_resource(const string& resource,
                   param_vec_t *extra_params,