mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-01 14:22:12 +01:00
Step 4a of docs/SECURITY_PLAN.md. Port 80 keeps the eleven HTTP routes of ADR 0006 and the socket at /ws; everything else moved to protocol 2. - Port 8081 (ApiRoutes) and the socket on 8080 (SocketEmitter) are gone. Protocol 2 owns its frame buffer and loop-task check. - Port 80 drops every route the old web UI called: reads, edits, settings, scans, reboot, /shades.cfg, /discovery. HttpRoutes.cpp holds what stays. - ModelSnapshot, SnapshotSlots and the read documents are gone. The item snapshot types stay, as ItemSnapshot, for events, MQTT and the command replies. - Model edits reply only to their protocol 2 op: requestResult goes. - The settings' toJSON writers, used only by the settings routes, go. - The _espsomfy_rts._tcp mDNS record moves to port 80, with path=/ws. - The memory event reports the loop-rate window it closes. - A deleted room no longer re-publishes its retained MQTT topics. - e2e: the heap check reads the sync's status; the sync is checked on its own instead of against /controller. - README gets an API and ports section. BREAKING CHANGE: ports 8081 and 8080 and the old HTTP routes are gone. Home Assistant needs integration 3.0.0 or newer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include "WResp.h"
|
|
|
|
void AsyncJsonResp::beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize) {
|
|
this->_request = request;
|
|
this->buff = buff;
|
|
this->buffSize = buffSize;
|
|
this->buff[0] = 0x00;
|
|
this->_len = 0;
|
|
this->_nocomma = true;
|
|
this->_headersSent = false;
|
|
this->_overflow = false;
|
|
this->_stream = request->beginResponseStream("application/json");
|
|
}
|
|
void AsyncJsonResp::endResponse() {
|
|
if(this->_len) this->flush();
|
|
if(this->_request && this->_stream) {
|
|
this->_request->send(this->_stream);
|
|
}
|
|
}
|
|
void AsyncJsonResp::flush() {
|
|
if(this->_stream && this->_len > 0) {
|
|
this->_stream->write((const uint8_t *)this->buff, this->_len);
|
|
this->buff[0] = 0x00;
|
|
this->_len = 0;
|
|
}
|
|
}
|
|
void AsyncJsonResp::_safecat(const char *val, bool escape) {
|
|
const size_t vlen = escape ? this->calcEscapedLength(val) + 2 : strlen(val);
|
|
if(vlen + this->_len >= this->buffSize) {
|
|
this->flush();
|
|
if(vlen + this->_len >= this->buffSize) {
|
|
// Bigger than the whole buffer so stream it straight out.
|
|
if(!this->_stream) {
|
|
this->_overflow = true;
|
|
return;
|
|
}
|
|
if(!escape) {
|
|
this->_stream->print(val);
|
|
return;
|
|
}
|
|
char esc[7];
|
|
this->_stream->print("\"");
|
|
for(size_t i = 0; val[i]; i++) {
|
|
escapeChar(val[i], esc);
|
|
this->_stream->print(esc);
|
|
}
|
|
this->_stream->print("\"");
|
|
return;
|
|
}
|
|
}
|
|
this->_appendAt(val, escape, vlen);
|
|
}
|