mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix #339 maxJsonBuffrSize
This commit is contained in:
@@ -173,7 +173,7 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
ArJsonRequestHandlerFunction _onRequest;
|
||||
size_t _contentLength;
|
||||
#ifndef ARDUINOJSON_5_COMPATIBILITY
|
||||
const size_t maxJsonBufferSize;
|
||||
size_t _maxJsonBufferSize;
|
||||
#endif
|
||||
size_t _maxContentLength;
|
||||
|
||||
@@ -182,7 +182,7 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
: _uri(uri)
|
||||
, _method(HTTP_POST | HTTP_PUT | HTTP_PATCH)
|
||||
, _onRequest(onRequest)
|
||||
, maxJsonBufferSize(maxJsonBufferSize)
|
||||
, _maxJsonBufferSize(maxJsonBufferSize)
|
||||
, _maxContentLength(16384) {
|
||||
}
|
||||
|
||||
@@ -192,6 +192,9 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
void setMaxContentLength(int maxContentLength) {
|
||||
_maxContentLength = maxContentLength;
|
||||
}
|
||||
void setMaxJsonBufferSize(size_t maxJsonBufferSize) {
|
||||
_maxJsonBufferSize = maxJsonBufferSize;
|
||||
}
|
||||
void onRequest(ArJsonRequestHandlerFunction fn) {
|
||||
_onRequest = fn;
|
||||
}
|
||||
@@ -216,7 +219,7 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
virtual void handleRequest(AsyncWebServerRequest * request) override final {
|
||||
if (_onRequest) {
|
||||
if (request->_tempObject != NULL) {
|
||||
DynamicJsonDocument jsonBuffer(this->maxJsonBufferSize);
|
||||
DynamicJsonDocument jsonBuffer(this->_maxJsonBufferSize);
|
||||
DeserializationError error = deserializeJson(jsonBuffer, (uint8_t *)(request->_tempObject));
|
||||
if (!error) {
|
||||
JsonVariant json = jsonBuffer.as<JsonVariant>();
|
||||
|
||||
@@ -46,7 +46,8 @@ WebCustomizationService::WebCustomizationService(AsyncWebServer * server, FS * f
|
||||
securityManager->wrapRequest(std::bind(&WebCustomizationService::reset_customization, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||
|
||||
_exclude_entities_handler.setMethod(HTTP_POST);
|
||||
_exclude_entities_handler.setMaxContentLength(1024);
|
||||
_exclude_entities_handler.setMaxContentLength(2048);
|
||||
_exclude_entities_handler.setMaxJsonBufferSize(2048);
|
||||
server->addHandler(&_exclude_entities_handler);
|
||||
|
||||
_device_entities_handler.setMethod(HTTP_POST);
|
||||
|
||||
Reference in New Issue
Block a user