mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2026-01-26 16:52:20 +01:00
Add ESP32 equivalent of beginResponse_P for embedded binary data.
`AsyncWebServerResponse* beginResponse(int code, const String& contentType, const uint8_t* content, size_t len, AwsTemplateProcessor callback = nullptr);` Ref: https://docs.platformio.org/en/latest/platforms/espressif32.html#embedding-binary-data
This commit is contained in:
@@ -303,6 +303,7 @@ class AsyncWebServerRequest {
|
||||
#endif
|
||||
|
||||
AsyncWebServerResponse* beginResponse(int code, const String& contentType = String(), const String& content = String());
|
||||
AsyncWebServerResponse* beginResponse(int code, const String& contentType, const uint8_t* content, size_t len, AwsTemplateProcessor callback = nullptr);
|
||||
AsyncWebServerResponse* beginResponse(FS& fs, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
|
||||
AsyncWebServerResponse* beginResponse(File content, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
|
||||
AsyncWebServerResponse* beginResponse(Stream& stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
|
||||
|
||||
@@ -702,6 +702,10 @@ AsyncWebServerResponse* AsyncWebServerRequest::beginResponse(int code, const Str
|
||||
return new AsyncBasicResponse(code, contentType, content);
|
||||
}
|
||||
|
||||
AsyncWebServerResponse* AsyncWebServerRequest::beginResponse(int code, const String& contentType, const uint8_t* content, size_t len, AwsTemplateProcessor callback) {
|
||||
return new AsyncProgmemResponse(code, contentType, content, len, callback);
|
||||
}
|
||||
|
||||
AsyncWebServerResponse* AsyncWebServerRequest::beginResponse(FS& fs, const String& path, const String& contentType, bool download, AwsTemplateProcessor callback) {
|
||||
if (fs.exists(path) || (!download && fs.exists(path + F(".gz"))))
|
||||
return new AsyncFileResponse(fs, path, contentType, download, callback);
|
||||
|
||||
Reference in New Issue
Block a user