client/Response: add constant MAX_BINARY_SIZE

Use the same chunk size for all binary commands.
This commit is contained in:
Max Kellermann
2019-08-12 20:10:37 +02:00
parent 989790e7f1
commit 4f61cd0b93
3 changed files with 6 additions and 3 deletions

View File

@@ -59,6 +59,8 @@ Response::Format(const char *fmt, ...) noexcept
bool
Response::WriteBinary(ConstBuffer<void> payload) noexcept
{
assert(payload.size <= MAX_BINARY_SIZE);
return Format("binary: %zu\n", payload.size) &&
Write(payload.data, payload.size) &&
Write("\n");

View File

@@ -77,6 +77,8 @@ public:
bool FormatV(const char *fmt, va_list args) noexcept;
bool Format(const char *fmt, ...) noexcept;
static constexpr size_t MAX_BINARY_SIZE = 8192;
/**
* Write a binary chunk; this writes the "binary" line, the
* given chunk and the trailing newline.