Skip to content

Commit 30c309c

Browse files
committed
Simplify and generalize the body parsing.
1 parent 020042e commit 30c309c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

libraries/WebServer/examples/UploadHugeFile/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This project is an example of an HTTP server designed to facilitate the transfer
55
### Example cURL Command
66

77
```bash
8-
curl -X PUT -H "Content-Type: application/octet-stream" -T ./my-file.mp3 http://esp-ip/upload/my-file.mp3
8+
curl -X PUT -T ./my-file.mp3 http://esp-ip/upload/my-file.mp3
99
```
1010

1111
## Resources

libraries/WebServer/src/Parsing.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ bool WebServer::_parseRequest(WiFiClient& client) {
136136
String headerName;
137137
String headerValue;
138138
bool isForm = false;
139-
bool isRaw = false;
140139
bool isEncoded = false;
141140
//parse headers
142141
while(1){
@@ -159,8 +158,6 @@ bool WebServer::_parseRequest(WiFiClient& client) {
159158
using namespace mime;
160159
if (headerValue.startsWith(FPSTR(mimeTable[txt].mimeType))){
161160
isForm = false;
162-
} else if (headerValue.startsWith(FPSTR(mimeTable[none].mimeType))){
163-
isRaw = true;
164161
} else if (headerValue.startsWith(F("application/x-www-form-urlencoded"))){
165162
isForm = false;
166163
isEncoded = true;
@@ -176,7 +173,7 @@ bool WebServer::_parseRequest(WiFiClient& client) {
176173
}
177174
}
178175

179-
if (isRaw && _currentHandler && _currentHandler->canRaw(_currentUri)){
176+
if (!isForm && _currentHandler && _currentHandler->canRaw(_currentUri)){
180177
log_v("Parse raw");
181178
_currentRaw.reset(new HTTPRaw());
182179
_currentRaw->status = RAW_START;

0 commit comments

Comments
 (0)