Skip to content

Commit af50210

Browse files
Merge pull request #280 from ESP32Async/issue/279
Correctly support form POST with text/plain content type
2 parents c5b8b2c + e5dcb52 commit af50210

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/WebRequest.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include "literals.h"
88
#include <cstring>
99

10-
#define __is_param_char(c) ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '='))
10+
static inline bool isParamChar(char c) {
11+
return ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '='));
12+
}
1113

1214
static void doNotDelete(AsyncWebServerRequest *) {}
1315

@@ -183,9 +185,12 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len) {
183185
if (_parsedLength == 0) {
184186
if (_contentType.startsWith(T_app_xform_urlencoded)) {
185187
_isPlainPost = true;
186-
} else if (_contentType == T_text_plain && __is_param_char(((char *)buf)[0])) {
188+
} else if (_contentType == T_text_plain && isParamChar(((char *)buf)[0])) {
187189
size_t i = 0;
188-
while (i < len && __is_param_char(((char *)buf)[i++]));
190+
char ch;
191+
do {
192+
ch = ((char *)buf)[i];
193+
} while (i++ < len && isParamChar(ch));
189194
if (i < len && ((char *)buf)[i - 1] == '=') {
190195
_isPlainPost = true;
191196
}

0 commit comments

Comments
 (0)