Memory-bounded streaming builder for /controller. Produces the JSON payload one small unit at a time into a fixed 3KB buffer, so a chunked HTTP response can drain it as the TCP send window allows — no growing cbuf in the async response stream.

This commit is contained in:
cjkas 2026-04-21 14:56:20 +02:00
parent f51e90bb7c
commit 6365f16850
4 changed files with 270 additions and 31 deletions

View file

@ -52,6 +52,11 @@ class JsonFormatter {
void addElem(const char *name, const char *val);
void addElem(const char* name, uint64_t lval);
};
class BufferedJsonFormatter : public JsonFormatter {
public:
void setBuffer(char *b, size_t sz);
size_t length() const;
};
class AsyncJsonResp : public JsonFormatter {
protected:
void _safecat(const char *val, bool escape = false) override;