summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2012-10-03 17:36:50 -0700
committerYehuda Sadeh <yehuda@inktank.com>2012-10-23 10:43:09 -0700
commitd6d3bf060e4444e6a2eadfee31d2a004dbb29a14 (patch)
tree87d5b8b2e574fc052d6c048d3bbeab959cbbdf60
parent9f9bc77f341497befe8f4cbeed54740432aea533 (diff)
downloadceph-d6d3bf060e4444e6a2eadfee31d2a004dbb29a14.tar.gz
rgw: handle content_type, meta
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_common.h4
-rw-r--r--src/rgw/rgw_op.cc9
-rw-r--r--src/rgw/rgw_op.h2
-rw-r--r--src/rgw/rgw_rest_s3.cc28
-rw-r--r--src/rgw/rgw_rest_s3.h2
5 files changed, 34 insertions, 11 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index f4a02eedcf4..1349a614061 100644
--- a/src/rgw/rgw_common.h
+++ b/src/rgw/rgw_common.h
@@ -39,10 +39,12 @@ using ceph::crypto::MD5;
#define RGW_ATTR_PREFIX "user.rgw."
+#define RGW_AMZ_META_PREFIX "x-amz-meta-"
+
#define RGW_ATTR_ACL RGW_ATTR_PREFIX "acl"
#define RGW_ATTR_ETAG RGW_ATTR_PREFIX "etag"
#define RGW_ATTR_BUCKETS RGW_ATTR_PREFIX "buckets"
-#define RGW_ATTR_META_PREFIX RGW_ATTR_PREFIX "x-amz-meta-"
+#define RGW_ATTR_META_PREFIX RGW_ATTR_PREFIX RGW_AMZ_META_PREFIX
#define RGW_ATTR_CONTENT_TYPE RGW_ATTR_PREFIX "content_type"
#define RGW_ATTR_CACHE_CONTROL RGW_ATTR_PREFIX "cache_control"
#define RGW_ATTR_CONTENT_DISP RGW_ATTR_PREFIX "content_disposition"
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index 6e1d3c7759b..9111c5f2998 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -1313,7 +1313,6 @@ void RGWPostObj::execute()
unsigned char m[CEPH_CRYPTO_MD5_DIGESTSIZE];
MD5 hash;
bufferlist bl, aclbl;
- map<string, bufferlist> attrs;
int len;
ret = verify_params();
@@ -1371,10 +1370,10 @@ void RGWPostObj::execute()
attrs[RGW_ATTR_ETAG] = bl;
attrs[RGW_ATTR_ACL] = aclbl;
- if (form_param.count("Content-Type")) {
- bl.clear();
- bl.append(form_param["Content-Type"].c_str(), form_param["Content-Type"].size() + 1);
- attrs[RGW_ATTR_CONTENT_TYPE] = bl;
+ if (content_type.size()) {
+ bufferlist ct_bl;
+ ct_bl.append(content_type.c_str(), content_type.size() + 1);
+ attrs[RGW_ATTR_CONTENT_TYPE] = ct_bl;
}
ret = processor->complete(etag, attrs);
diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h
index 3d4d8ed4e01..41b64e1a391 100644
--- a/src/rgw/rgw_op.h
+++ b/src/rgw/rgw_op.h
@@ -318,8 +318,10 @@ protected:
string etag;
string boundary;
bool data_pending;
+ string content_type;
RGWAccessControlPolicy policy;
map<string, string> form_param;
+ map<string, bufferlist> attrs;
public:
RGWPostObj() {}
diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc
index 4fef81284af..bda514e14cd 100644
--- a/src/rgw/rgw_rest_s3.cc
+++ b/src/rgw/rgw_rest_s3.cc
@@ -645,7 +645,7 @@ int RGWPostObj_ObjStore_S3::read_form_part_header(struct post_form_part *part,
bool RGWPostObj_ObjStore_S3::part_str(const string& name, string *val)
{
- map<string, struct post_form_part>::iterator iter = parts.find(name);
+ map<string, struct post_form_part, ltstr_nocase>::iterator iter = parts.find(name);
if (iter == parts.end())
return false;
@@ -732,9 +732,30 @@ int RGWPostObj_ObjStore_S3::get_params()
if (!part_str("key", &s->object_str))
return -EINVAL;
+ part_str("Content-Type", &content_type);
+
+ map<string, struct post_form_part, ltstr_nocase>::iterator piter = parts.upper_bound(RGW_AMZ_META_PREFIX);
+ for (; piter != parts.end(); ++piter) {
+ string n = piter->first;
+ if (strncasecmp(n.c_str(), RGW_AMZ_META_PREFIX, sizeof(RGW_AMZ_META_PREFIX) - 1) != 0)
+ break;
+
+ string attr_name = RGW_ATTR_PREFIX;
+ attr_name.append(n);
+
+ /* need to null terminate it */
+ bufferlist& data = piter->second.data;
+ string str = string(data.c_str(), data.length());
+
+ bufferlist attr_bl;
+ attr_bl.append(str.c_str(), str.size() + 1);
+
+ attrs[attr_name] = attr_bl;
+ }
+
string canned_acl;
part_str("acl", &canned_acl);
-
+
RGWAccessControlPolicy_S3 s3policy(s->cct);
ldout(s->cct, 20) << "canned_acl=" << canned_acl << dendl;
if (!s3policy.create_canned(s->user.user_id, "", canned_acl))
@@ -812,8 +833,7 @@ void RGWPostObj_ObjStore_S3::send_response()
status_int = 200;
dump_errno(s, status_int);
- }
- else {
+ } else {
dump_errno(s);
if (ret < 0)
return;
diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h
index 8e76e536124..964e1d9722a 100644
--- a/src/rgw/rgw_rest_s3.h
+++ b/src/rgw/rgw_rest_s3.h
@@ -95,7 +95,7 @@ struct post_form_part {
struct ltstr_nocase
{
- bool operator()(const string& s1, const string& s2) const
+ bool operator()(const string& s1, const string& s2)
{
return strcasecmp(s1.c_str(), s2.c_str()) < 0;
}