| 410 | } |
| 411 | |
| 412 | bool WebServer::_parseForm(NetworkClient &client, const String &boundary, uint32_t len) { |
| 413 | (void)len; |
| 414 | log_v("Parse Form: Boundary: %s Length: %" PRIu32, boundary.c_str(), len); |
| 415 | String line; |
| 416 | int retry = 0; |
| 417 | do { |
| 418 | line = client.readStringUntil('\r'); |
| 419 | ++retry; |
| 420 | } while (line.length() == 0 && retry < 3); |
| 421 | |
| 422 | client.readStringUntil('\n'); |
| 423 | //start reading the form |
| 424 | if (line == ("--" + boundary)) { |
| 425 | if (_postArgs) { |
| 426 | delete[] _postArgs; |
| 427 | } |
| 428 | _postArgs = new RequestArgument[WEBSERVER_MAX_POST_ARGS]; |
| 429 | _postArgsLen = 0; |
| 430 | while (1) { |
| 431 | String argName; |
| 432 | String argValue; |
| 433 | String argType; |
| 434 | String argFilename; |
| 435 | bool argIsFile = false; |
| 436 | |
| 437 | line = client.readStringUntil('\r'); |
| 438 | client.readStringUntil('\n'); |
| 439 | if (line.length() > (size_t)19 && line.substring(0, 19).equalsIgnoreCase(F("Content-Disposition"))) { |
| 440 | int nameStart = line.indexOf('='); |
| 441 | if (nameStart != -1) { |
| 442 | argName = line.substring(nameStart + 2); |
| 443 | nameStart = argName.indexOf('='); |
| 444 | if (nameStart == -1) { |
| 445 | argName = argName.substring(0, argName.length() - 1); |
| 446 | } else { |
| 447 | argFilename = argName.substring(nameStart + 2, argName.length() - 1); |
| 448 | argName = argName.substring(0, argName.indexOf('"')); |
| 449 | argIsFile = true; |
| 450 | log_v("PostArg FileName: %s", argFilename.c_str()); |
| 451 | //use GET to set the filename if uploading using blob |
| 452 | if (argFilename == F("blob") && hasArg(FPSTR(filename))) { |
| 453 | argFilename = arg(FPSTR(filename)); |
| 454 | } |
| 455 | } |
| 456 | log_v("PostArg Name: %s", argName.c_str()); |
| 457 | using namespace mime; |
| 458 | argType = FPSTR(mimeTable[txt].mimeType); |
| 459 | line = client.readStringUntil('\r'); |
| 460 | client.readStringUntil('\n'); |
| 461 | while (line.length() > 0) { |
| 462 | if (line.length() > (size_t)12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))) { |
| 463 | argType = line.substring(line.indexOf(':') + 2); |
| 464 | } |
| 465 | //skip over any other headers |
| 466 | line = client.readStringUntil('\r'); |
| 467 | client.readStringUntil('\n'); |
| 468 | } |
| 469 | log_v("PostArg Type: %s", argType.c_str()); |
nothing calls this directly
no test coverage detected