* Removed unnecessary memmove from chunked response generation.
* Added simple template processor to AsyncFileResponse.
Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.
Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.
Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
# Conflicts:
# src/WebResponses.cpp
* Add support for a MultiMessage where the buffer is shared between WS messages to multiple clients.
Add ability to create a WS buffer directly and write to it, saving duplication of message in RAM, then send it. example below is an arduinoJson message.
```cpp
void sendDataWs(AsyncWebSocketClient * client)
{
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["a"] = "abc";
root["b"] = "abcd";
root["c"] = "abcde";
root["d"] = "abcdef";
root["e"] = "abcdefg";
size_t len = root.measureLength();
AsyncWebSocketMessageBuffer * buffer = ws.makeBuffer(len); // creates a buffer (len + 1) for you.
if (buffer) {
root.printTo((char *)buffer->get(), len + 1);
if (client) {
client->text(buffer);
} else {
ws.textAll(buffer);
}
}
}
```
* Add example to readme.
* Reset all handlers. This allowing to use same server few times during app life.
E.g. for WiFi manager when hardware sepups WiFi connection and as HTTP server during hardware life cycle
* New - server.rewirte() to rewrite the request url with optional get parameters injection.
New - rewrite.setFilter() and handler.setFilter() to specify a filter callback for more control on when to include them.
New - static file handler can be set with Last-Modified header value to support Not-Modified (304) response instead of serving the actual file.
* Remove clearRewrites & clearHandlers from server.mplement server distractor to delete internal members. Fixed and improved gzip stats calculation.
* This handler will serve a 302 response to a client request for a SPIFFS file if the request comes from the STA side of the ESP network.
If the request comes from the AP side then it serves the file from SPIFFS.
* corrections. plus readme
* Update README.md
extra space
* move wifi to cpp
* Prevent buffer overflow on received data
* pass to 7 char to avoid save to flash by SDK
* return _contentLength, avoid array reparse to know len
* Added FlashStringHelper for text and binary
* Added FlashStringHelper also to AsyncWebSocketClient
* Added PROGMEM doc
* Corrected binary was sending PSTR as text, addded len
* Server calls client method and code as asked @me-no-dev
* server calls client method and code as asked by @me-no-dev
* Changed Code presentation
* Added printf_P methods
* Prevent buffer overflow on received data
* pass to 7 char to avoid save to flash by SDK
* return _contentLength, avoid array reparse to know len
* Added FlashStringHelper for text and binary
* Added FlashStringHelper also to AsyncWebSocketClient
* Added PROGMEM doc
* Corrected binary was sending PSTR as text, addded len
* Server calls client method and code as asked @me-no-dev
* server calls client method and code as asked by @me-no-dev
* Changed Code presentation