The current code emits a newline after swift errors, but fails
to account for it when it calculates 'content-length'. This results in
some clients (go github.com/ncw/swift) producing complaints about the
unsolicited newline such as this,
Unsolicited response received on idle HTTP channel starting with "\n"; err=<nil>
This logic eliminates the newline on flush. This makes the content length
calculation correct and eliminates the stray newline.
There was already existing separator logic in the rgw plain formatter
that can emit a newline at the correct point. It had been checking
"len" to decide if previous data had been emitted, but that's reset to 0
by flush(). So, this logic adds a new per-instance variable to separately
track state that it emitted a previous item (and should emit a newline).
Fixes: http://tracker.ceph.com/issues/18473
Signed-off-by: Marcus Watts <mwatts@redhat.com>
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit
5f229d6a33eae4906f22cdb90941835e47ee9f02)
: buf(NULL),
len(0),
max_len(0),
+ wrote_something(false),
min_stack_level(0),
use_kv(ukv)
{
return;
if (len) {
- os << buf << "\n";
+ os << buf;
os.flush();
}
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);
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);
std::list<struct plain_stack_entry> stack;
size_t min_stack_level;
bool use_kv;
+ bool wrote_something;
};