*pbl = iter->second.data;
return true;
}
+
int RGWPostObj_ObjStore::verify_params()
{
/* check that we have enough memory to store the object
return 0;
}
+int RGWPostObj_ObjStore::get_params()
+{
+ if (s->expect_cont) {
+ /* OK, here it really gets ugly. With POST, the params are embedded in the
+ * request body, so we need to continue before being able to actually look
+ * at them. This diverts from the usual request flow. */
+ dump_continue(s);
+ s->expect_cont = false;
+ }
+
+ std::string req_content_type_str = s->info.env->get("CONTENT_TYPE", "");
+ std::string req_content_type;
+ std::map<std::string, std::string> params;
+ parse_params(req_content_type_str, req_content_type, params);
+
+ if (req_content_type.compare("multipart/form-data") != 0) {
+ err_msg = "Request Content-Type is not multipart/form-data";
+ return -EINVAL;
+ }
+
+ if (s->cct->_conf->subsys.should_gather(ceph_subsys_rgw, 20)) {
+ ldout(s->cct, 20) << "request content_type_str="
+ << req_content_type_str << dendl;
+ ldout(s->cct, 20) << "request content_type params:" << dendl;
+
+ for (const auto& pair : params) {
+ ldout(s->cct, 20) << " " << pair.first << " -> " << pair.second
+ << dendl;
+ }
+ }
+
+ const auto iter = params.find("boundary");
+ if (std::end(params) == iter) {
+ err_msg = "Missing multipart boundary specification";
+ return -EINVAL;
+ }
+
+ /* Create the boundary. */
+ boundary = "--";
+ boundary.append(iter->second);
+
+ return 0;
+}
+
+
int RGWPutACLs_ObjStore::get_params()
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
}
return res;
}
-/*
- * parses params in the format: 'first; param1=foo; param2=bar'
- */
-static void parse_params(const string& params_str, string& first,
- map<string, string>& params)
-{
- size_t pos = params_str.find(';');
- if (pos == string::npos) {
- first = rgw_trim_whitespace(params_str);
- return;
- }
-
- first = rgw_trim_whitespace(params_str.substr(0, pos));
-
- pos++;
-
- while (pos < params_str.size()) {
- size_t end = params_str.find(';', pos);
- if (end == string::npos)
- end = params_str.size();
-
- string param = params_str.substr(pos, end - pos);
-
- size_t eqpos = param.find('=');
- if (eqpos != string::npos) {
- params[rgw_trim_whitespace(param.substr(0, eqpos))] =
- rgw_trim_quotes(param.substr(eqpos + 1));
- } else {
- params[rgw_trim_whitespace(param)] = "";
- }
-
- pos = end + 1;
- }
-}
void RGWPostObj_ObjStore_S3::rebuild_key(string& key)
{
int RGWPostObj_ObjStore_S3::get_params()
{
- // get the part boundary
- string req_content_type_str = s->info.env->get("CONTENT_TYPE", "");
- string req_content_type;
- map<string, string> params;
-
- if (s->expect_cont) {
- /* ok, here it really gets ugly. With POST, the params are embedded in the
- * request body, so we need to continue before being able to actually look
- * at them. This diverts from the usual request flow.
- */
- dump_continue(s);
- s->expect_cont = false;
- }
-
- parse_params(req_content_type_str, req_content_type, params);
-
- if (req_content_type.compare("multipart/form-data") != 0) {
- err_msg = "Request Content-Type is not multipart/form-data";
- return -EINVAL;
- }
-
- if (s->cct->_conf->subsys.should_gather(ceph_subsys_rgw, 20)) {
- ldout(s->cct, 20) << "request content_type_str="
- << req_content_type_str << dendl;
- ldout(s->cct, 20) << "request content_type params:" << dendl;
- map<string, string>::iterator iter;
- for (iter = params.begin(); iter != params.end(); ++iter) {
- ldout(s->cct, 20) << " " << iter->first << " -> " << iter->second
- << dendl;
- }
+ op_ret = RGWPostObj_ObjStore::get_params();
+ if (op_ret < 0) {
+ return op_ret;
}
ldout(s->cct, 20) << "adding bucket to policy env: " << s->bucket.name
<< dendl;
env.add_var("bucket", s->bucket.name);
- map<string, string>::iterator iter = params.find("boundary");
- if (iter == params.end()) {
- err_msg = "Missing multipart boundary specification";
- return -EINVAL;
- }
-
- // create the boundary
- boundary = "--";
- boundary.append(iter->second);
-
bool done;
do {
struct post_form_part part;
ldout(s->cct, 20) << "val=" << piter->second.val << dendl;
ldout(s->cct, 20) << "params:" << dendl;
map<string, string>& params = piter->second.params;
- for (iter = params.begin(); iter != params.end(); ++iter) {
- ldout(s->cct, 20) << " " << iter->first << " -> " << iter->second
- << dendl;
+ for (const auto& pair : params) {
+ ldout(s->cct, 20) << " " << pair.first << " -> " << pair.second
+ << dendl;
}
}
}