Skip to content

Commit

Permalink
Merge pull request #13224 from smithfarm/wip-18780-kraken
Browse files Browse the repository at this point in the history
kraken: rgw: Swift API: spurious newline after http body causes weird errors

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
  • Loading branch information
smithfarm committed Jun 20, 2017
2 parents 2f4a775 + d1ec595 commit 7706a38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rgw/rgw_formats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ RGWFormatter_Plain::RGWFormatter_Plain(const bool ukv)
: buf(NULL),
len(0),
max_len(0),
wrote_something(false),
min_stack_level(0),
use_kv(ukv)
{
Expand All @@ -44,7 +45,7 @@ void RGWFormatter_Plain::flush(ostream& os)
return;

if (len) {
os << buf << "\n";
os << buf;
os.flush();
}

Expand Down Expand Up @@ -159,13 +160,14 @@ void RGWFormatter_Plain::dump_format_va(const char *name, const char *ns, bool q
vsnprintf(buf, LARGE_SIZE, fmt, ap);

const char *eol;
if (len) {
if (wrote_something) {
if (use_kv && entry.is_array && entry.size > 1)
eol = ", ";
else
eol = "\n";
} else
eol = "";
wrote_something = true;

if (use_kv && !entry.is_array)
write_data("%s%s: %s", eol, name, buf);
Expand Down Expand Up @@ -271,10 +273,11 @@ void RGWFormatter_Plain::dump_value_int(const char *name, const char *fmt, ...)
va_end(ap);

const char *eol;
if (len)
if (wrote_something) {
eol = "\n";
else
} else
eol = "";
wrote_something = true;

if (use_kv && !entry.is_array)
write_data("%s%s: %s", eol, name, buf);
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class RGWFormatter_Plain : public Formatter {
std::list<struct plain_stack_entry> stack;
size_t min_stack_level;
bool use_kv;
bool wrote_something;
};


Expand Down

0 comments on commit 7706a38

Please sign in to comment.