From 656215cadbba3ed257da0098b496142d4b4f8e9f Mon Sep 17 00:00:00 2001 From: SilvestreArduino Date: Thu, 26 Dec 2024 10:58:30 +0100 Subject: [PATCH 1/2] Fix WebRequest.cpp to prevent exception --- src/WebRequest.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp index bbce5ca4c..2ca2833b2 100644 --- a/src/WebRequest.cpp +++ b/src/WebRequest.cpp @@ -178,13 +178,30 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){ } } -void AsyncWebServerRequest::_removeNotInterestingHeaders(){ - if (_interestingHeaders.containsIgnoreCase("ANY")) return; // nothing to do - for(const auto& header: _headers){ - if(!_interestingHeaders.containsIgnoreCase(header->name().c_str())){ - _headers.remove(header); - } - } +// Changes by Copilot +// void AsyncWebServerRequest::_removeNotInterestingHeaders(){ +// if (_interestingHeaders.containsIgnoreCase("ANY")) return; // nothing to do +// for(const auto& header: _headers){ +// if(!_interestingHeaders.containsIgnoreCase(header->name().c_str())){ +// _headers.remove(header); +// } +// } +// } +void AsyncWebServerRequest::_removeNotInterestingHeaders() { + if (_interestingHeaders.containsIgnoreCase("ANY")) return; // nothing to do + + // Create a new container to store the headers that we want to keep + std::vector newHeaders; + for (auto& header : _headers) { + if (header != nullptr && _interestingHeaders.containsIgnoreCase(header->name().c_str())) { + newHeaders.push_back(header); // Keep this header + } + } + // Replace the original _headers container with the new container + _headers.free(); + for (auto& header : newHeaders) { + _headers.add(header); + } } void AsyncWebServerRequest::_onPoll(){ From cdbe2ebf354b74541414595e96c4105e7473dce3 Mon Sep 17 00:00:00 2001 From: SilvestreArduino Date: Thu, 26 Dec 2024 11:18:18 +0100 Subject: [PATCH 2/2] Updated README.md to document local modifications --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d6dd3206a..ed2344186 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ To use this library you might need to have the latest git versions of [ESP8266]( For ESP32 it requires [AsyncTCP](https://github.com/me-no-dev/AsyncTCP) to work To use this library you might need to have the latest git versions of [ESP32](https://github.com/espressif/arduino-esp32) Arduino Core +Local modified WebRequest.cpp to prevent exception that reboots ESP32 + ## Table of contents - [ESPAsyncWebServer](#espasyncwebserver) - [Table of contents](#table-of-contents)