Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

WebRequest.cpp modifications to prevent exception that reboot ESP32 #1456

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 24 additions & 7 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AsyncWebHeader*> 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(){
Expand Down