| 417 | } |
| 418 | |
| 419 | void WebServer::handleClient() { |
| 420 | if (_currentStatus == HC_NONE) { |
| 421 | _currentClient = _server.accept(); |
| 422 | if (!_currentClient) { |
| 423 | if (_nullDelay) { |
| 424 | delay(1); |
| 425 | } |
| 426 | return; |
| 427 | } |
| 428 | |
| 429 | log_v("New client: client.localIP()=%s", _currentClient.localIP().toString().c_str()); |
| 430 | |
| 431 | _currentStatus = HC_WAIT_READ; |
| 432 | _statusChange = millis(); |
| 433 | } |
| 434 | |
| 435 | bool keepCurrentClient = false; |
| 436 | bool callYield = false; |
| 437 | |
| 438 | if (_currentClient.connected()) { |
| 439 | switch (_currentStatus) { |
| 440 | case HC_NONE: |
| 441 | // No-op to avoid C++ compiler warning |
| 442 | break; |
| 443 | case HC_WAIT_READ: |
| 444 | // Wait for data from client to become available |
| 445 | if (_currentClient.available()) { |
| 446 | _currentClient.setTimeout(HTTP_MAX_SEND_WAIT); /* / 1000 removed, WifiClient setTimeout changed to ms */ |
| 447 | if (_parseRequest(_currentClient)) { |
| 448 | _contentLength = CONTENT_LENGTH_NOT_SET; |
| 449 | _responseCode = 0; |
| 450 | _clearResponseHeaders(); |
| 451 | |
| 452 | // Run server-level middlewares |
| 453 | if (_chain) { |
| 454 | _chain->runChain(*this, [this]() { |
| 455 | return _handleRequest(); |
| 456 | }); |
| 457 | } else { |
| 458 | _handleRequest(); |
| 459 | } |
| 460 | |
| 461 | if (_currentClient.isSSE()) { |
| 462 | _currentStatus = HC_WAIT_CLOSE; |
| 463 | _statusChange = millis(); |
| 464 | keepCurrentClient = true; |
| 465 | } |
| 466 | // Fix for issue with Chrome based browsers: https://github.com/espressif/arduino-esp32/issues/3652 |
| 467 | // if (_currentClient.connected()) { |
| 468 | // _currentStatus = HC_WAIT_CLOSE; |
| 469 | // _statusChange = millis(); |
| 470 | // keepCurrentClient = true; |
| 471 | // } |
| 472 | } |
| 473 | } else { // !_currentClient.available() |
| 474 | if (millis() - _statusChange <= HTTP_MAX_DATA_WAIT) { |
| 475 | keepCurrentClient = true; |
| 476 | } |
nothing calls this directly
no test coverage detected