mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-09-20 16:42:11 +02:00
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:
parent
f51e90bb7c
commit
6365f16850
4 changed files with 270 additions and 31 deletions
|
|
@ -35,6 +35,17 @@ void JsonSockEvent::_safecat(const char *val, bool escape) {
|
|||
else strcat(this->buff, val);
|
||||
if(escape) strcat(this->buff, "\"");
|
||||
}
|
||||
void BufferedJsonFormatter::setBuffer(char *b, size_t sz) {
|
||||
this->buff = b;
|
||||
this->buffSize = sz;
|
||||
this->buff[0] = 0;
|
||||
this->_nocomma = true;
|
||||
this->_objects = 0;
|
||||
this->_arrays = 0;
|
||||
}
|
||||
size_t BufferedJsonFormatter::length() const {
|
||||
return strlen(this->buff);
|
||||
}
|
||||
void AsyncJsonResp::beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize) {
|
||||
this->_request = request;
|
||||
this->buff = buff;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue