fix #18817 http response for status with retain (#18819)

* fix http response for status with retain

* take 2

* add a failsafe when JSONlen reach zero
This commit is contained in:
Barbudor 2023-06-09 09:59:24 +02:00 committed by GitHub
parent fc92dc0995
commit 6aed929e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3064,7 +3064,8 @@ void HandleHttpCommand(void)
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O]) if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
if (cflg) { WSContentSend_P(PSTR(",")); } if (cflg) { WSContentSend_P(PSTR(",")); }
uint32_t JSONlen = len - (JSON - line) -3; uint32_t JSONlen = len - (JSON - line) -3;
WSContentSend(JSON +1, JSONlen); for( ++JSON ; JSONlen && JSON[JSONlen] != '}' ; JSONlen-- );
WSContentSend(JSON, JSONlen);
cflg = true; cflg = true;
} }
} }