dump_header(s, "Accept-Ranges", "bytes");
}
-void dump_etag(struct req_state* const s, const boost::string_ref& etag)
+void dump_etag(struct req_state* const s,
+ const boost::string_ref& etag,
+ const bool quoted)
{
if (etag.empty()) {
return;
}
- if (s->prot_flags & RGW_REST_SWIFT) {
+ if (s->prot_flags & RGW_REST_SWIFT && ! quoted) {
return dump_header(s, "etag", etag);
} else {
- /* We need two extra bytes for quotes. */
- char buf[etag.size() + 2 + 1];
- const auto len = snprintf(buf, sizeof(buf), "\"%s\"", etag.data());
-
- return dump_header(s, "ETag", boost::string_ref(buf, len));
+ return dump_header_quoted(s, "ETag", etag);
}
}
-void dump_etag(struct req_state* const s, ceph::buffer::list& bl_etag)
+void dump_etag(struct req_state* const s,
+ ceph::buffer::list& bl_etag,
+ const bool quoted)
{
- return dump_etag(s, boost::string_ref(bl_etag.c_str(), bl_etag.length()));
+ return dump_etag(s, boost::string_ref(bl_etag.c_str(), bl_etag.length()),
+ quoted);
}
void dump_pair(struct req_state* const s,
}
}
} else {
- dump_header(s, "Location", "\"" + s->info.request_uri + "\"");
+ dump_header_quoted(s, "Location", s->info.request_uri);
}
}
Args&&... args) {
char full_name_buf[name_prefix.size() + name.size() + 1];
const auto len = snprintf(full_name_buf, sizeof(full_name_buf), "%.*s%.*s",
- name_prefix.length(), name_prefix.data(),
- name.length(), name.data());
+ static_cast<int>(name_prefix.length()),
+ name_prefix.data(),
+ static_cast<int>(name.length()),
+ name.data());
boost::string_ref full_name(full_name_buf, len);
return dump_header(s, std::move(full_name), std::forward<Args>(args)...);
}
+
+template <class... Args>
+static inline void dump_header_quoted(struct req_state* s,
+ const boost::string_ref& name,
+ const boost::string_ref& val) {
+ /* We need two extra bytes for quotes. */
+ char qvalbuf[val.size() + 2 + 1];
+ const auto len = snprintf(qvalbuf, sizeof(qvalbuf), "\"%.*s\"",
+ static_cast<int>(val.length()), val.data());
+ return dump_header(s, name, boost::string_ref(qvalbuf, len));
+}
+
extern void dump_content_length(struct req_state *s, uint64_t len);
-extern void dump_etag(struct req_state *s, const boost::string_ref& etag);
-extern void dump_etag(struct req_state *s, ceph::buffer::list& bl_etag);
+extern void dump_etag(struct req_state *s,
+ const boost::string_ref& etag,
+ bool quoted = false);
+extern void dump_etag(struct req_state *s,
+ ceph::buffer::list& bl_etag,
+ bool quoted = false);
extern void dump_epoch_header(struct req_state *s, const char *name, real_time t);
extern void dump_time_header(struct req_state *s, const char *name, real_time t);
extern void dump_last_modified(struct req_state *s, real_time t);
op_ret = STATUS_CREATED;
}
- if (!lo_etag.empty()) {
+ if (! lo_etag.empty()) {
/* Static Large Object of Swift API has two etags represented by
* following members:
* - etag - for the manifest itself (it will be stored in xattrs),
* In response for PUT request we have to expose the second one.
* The first one may be obtained by GET with "multipart-manifest=get"
* in query string on a given SLO. */
- dump_etag(s, ("\"" + lo_etag + "\""));
+ dump_etag(s, lo_etag, true /* quoted */);
} else {
dump_etag(s, etag);
}
}
if (! op_ret) {
- if (!lo_etag.empty()) {
- dump_etag(s, ("\"" + lo_etag + "\""));
+ if (! lo_etag.empty()) {
+ dump_etag(s, lo_etag, true /* quoted */);
} else {
auto iter = attrs.find(RGW_ATTR_ETAG);
if (iter != attrs.end()) {