8000 Prevents exception when parsing HTTP POST message without a body · sachin0x18/esp32-snippets@472d151 · GitHub
[go: up one dir, main page]

Skip to content

Commit 472d151

Browse files
committed
Prevents exception when parsing HTTP POST message without a body
1 parent d38b15e commit 472d151

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cpp_utils/HttpParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ void HttpParser::parse(Socket s) {
220220
} else {
221221
uint8_t data[512];
222222
int rc = s.receive(data, sizeof(data));
223-
m_body = std::string((char *)data, rc);
223+
if (rc > 0) {
224+
m_body = std::string((char *)data, rc);
225+
}
224226
}
225227
ESP_LOGD(LOG_TAG, "<< parse: Size of body: %d", m_body.length());
226228
} // parse

0 commit comments

Comments
 (0)
0