mirror of
https://github.com/ceph/ceph
synced 2024-12-17 17:05:42 +00:00
rgw: Swift API. The second way of specifying desirable response format.
OpenStack Object Storage API v1 defines two ways for the client to tell which response format it understands. Until now RGW looked at query variable 'format' only. This commit implements the second way of setting the format by providing 'Accept' HTTP-header with the desirable response mime-type. Backport: hammer Fixes: #10746 Reviewed-by: Yehuda Sadeh <yehuda@redhat.com> Signed-off-by: Dmytro Iurchenko <diurchenko@mirantis.com>
This commit is contained in:
parent
8cd480d0d2
commit
6898f0b27f
@ -1086,6 +1086,21 @@ int RGWHandler_ObjStore::allocate_formatter(struct req_state *s, int default_typ
|
||||
s->format = RGW_FORMAT_XML;
|
||||
} else if (format_str.compare("json") == 0) {
|
||||
s->format = RGW_FORMAT_JSON;
|
||||
} else {
|
||||
const char *accept = s->info.env->get("HTTP_ACCEPT");
|
||||
if (accept) {
|
||||
char format_buf[64];
|
||||
unsigned int i = 0;
|
||||
for (; i < sizeof(format_buf) - 1 && accept[i] && accept[i] != ';'; ++i) {
|
||||
format_buf[i] = accept[i];
|
||||
}
|
||||
format_buf[i] = 0;
|
||||
if ((strcmp(format_buf, "text/xml") == 0) || (strcmp(format_buf, "application/xml") == 0)) {
|
||||
s->format = RGW_FORMAT_XML;
|
||||
} else if (strcmp(format_buf, "application/json") == 0) {
|
||||
s->format = RGW_FORMAT_JSON;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user