diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-10 14:27:36 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-10 14:28:03 -0700 |
commit | db0c250f38e61269ee711c3a2cf73dce7fc750ad (patch) | |
tree | e8febb9589a1c1ba0624cb6dcc4185e9d43952bb | |
parent | 566315c47ff0cb2964f5993533af2c1d8d3dcc0b (diff) | |
download | ceph-db0c250f38e61269ee711c3a2cf73dce7fc750ad.tar.gz |
rgw: send meta headers with remote PUT request
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_rados.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest_client.cc | 23 | ||||
-rw-r--r-- | src/rgw/rgw_rest_client.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_rest_conn.cc | 5 | ||||
-rw-r--r-- | src/rgw/rgw_rest_conn.h | 3 |
5 files changed, 28 insertions, 9 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b0ede4ff9df..0583ba014bc 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1953,7 +1953,7 @@ int RGWRados::copy_obj(void *ctx, RGWRESTStreamRequest *out_stream_req; - int ret = rest_conn->put_obj_init(user_id, dest_obj, astate->size, &out_stream_req); + int ret = rest_conn->put_obj_init(user_id, dest_obj, astate->size, attrset, &out_stream_req); if (ret < 0) return ret; diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index 1a85aa5c764..c7e11a95841 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -281,10 +281,10 @@ int RGWRESTStreamRequest::add_output_data(bufferlist& bl) lock.Unlock(); bool done; - return process_request(handle, &done); + return process_request(handle, false, &done); } -int RGWRESTStreamRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size) +int RGWRESTStreamRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map<string, bufferlist>& attrs) { string resource = obj.bucket.name + "/" + obj.object; string new_url = url; @@ -318,6 +318,19 @@ int RGWRESTStreamRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t } map<string, string>& m = new_env.get_map(); + map<string, bufferlist>::iterator bliter; + + /* merge send headers */ + for (bliter = attrs.begin(); bliter != attrs.end(); ++bliter) { + bufferlist& bl = bliter->second; + const string& name = bliter->first; + string val(bl.c_str(), bl.length()); + if (name.compare(0, sizeof(RGW_ATTR_META_PREFIX) - 1, RGW_ATTR_META_PREFIX) == 0) { + string header_name = RGW_AMZ_META_PREFIX; + header_name.append(name.substr(sizeof(RGW_ATTR_META_PREFIX) - 1)); + m[header_name] = val; + } + } map<string, string>::iterator iter; for (iter = m.begin(); iter != m.end(); ++iter) { headers.push_back(make_pair<string, string>(iter->first, iter->second)); @@ -361,12 +374,14 @@ int RGWRESTStreamRequest::send_data(void *ptr, size_t len) sent += send_len; lock.Lock(); - pending_send.pop_front(); + bufferlist new_bl; if (bl.length() > send_len) { bufferptr bp(bl.c_str() + send_len, bl.length() - send_len); - bufferlist new_bl; new_bl.append(bp); + } + pending_send.pop_front(); /* need to do this after we copy data from bl */ + if (new_bl.length()) { pending_send.push_front(new_bl); } iter = next_iter; diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index 48a0bf04a1d..f3f9f7ff91c 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -46,6 +46,8 @@ public: int execute(RGWAccessKey& key, const char *method, const char *resource); int forward_request(RGWAccessKey& key, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl); + + map<string, string>& get_out_headers() { return out_headers; } }; @@ -62,7 +64,7 @@ public: list<pair<string, string> > *_params) : RGWRESTSimpleRequest(_cct, _url, _headers, _params), lock("RGWRESTStreamRequest"), handle(NULL), cb(NULL) {} ~RGWRESTStreamRequest(); - int put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size); + int put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map<string, bufferlist>& attrs); int complete(); RGWGetDataCB *get_out_cb() { return cb; } diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index cba8548d3b4..8dc2c502d53 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -46,7 +46,8 @@ public: StreamObjData(rgw_obj& _obj) : obj(_obj) {} }; -int RGWRegionConnection::put_obj_init(const string& uid, rgw_obj& obj, uint64_t obj_size, RGWRESTStreamRequest **req) +int RGWRegionConnection::put_obj_init(const string& uid, rgw_obj& obj, uint64_t obj_size, + map<string, bufferlist>& attrs, RGWRESTStreamRequest **req) { string url; int ret = get_url(url); @@ -57,7 +58,7 @@ int RGWRegionConnection::put_obj_init(const string& uid, rgw_obj& obj, uint64_t params.push_back(make_pair<string, string>(RGW_SYS_PARAM_PREFIX "uid", uid)); params.push_back(make_pair<string, string>(RGW_SYS_PARAM_PREFIX "region", region)); *req = new RGWRESTStreamRequest(cct, url, NULL, ¶ms); - return (*req)->put_obj_init(key, obj, obj_size); + return (*req)->put_obj_init(key, obj, obj_size, attrs); } int RGWRegionConnection::complete_request(RGWRESTStreamRequest *req) diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index 1554e513db1..5119cdc250e 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -24,7 +24,8 @@ public: int forward(const string& uid, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl); /* async request */ - int put_obj_init(const string& uid, rgw_obj& obj, uint64_t obj_size, RGWRESTStreamRequest **req); + int put_obj_init(const string& uid, rgw_obj& obj, uint64_t obj_size, + map<string, bufferlist>& attrs, RGWRESTStreamRequest **req); int complete_request(RGWRESTStreamRequest *req); }; |