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;
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;
}
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));
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;
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; }
};
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; }
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);
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)
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);
};