Verze 2.9.5 odsud https://github.com/mathieucarbou/ESPAsyncWebServer/releases/tag/v2.9.5
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "AsyncEventSource.h"
|
||||
#ifndef ESP8266
|
||||
#include <rom/ets_sys.h>
|
||||
#endif
|
||||
|
||||
static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){
|
||||
String ev;
|
||||
|
@@ -137,7 +137,11 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
|
||||
return _contentLength;
|
||||
}
|
||||
|
||||
size_t getSize() { return _jsonBuffer.size(); }
|
||||
size_t getSize() const { return _jsonBuffer.size(); }
|
||||
|
||||
#if ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
bool overflowed() const { return _jsonBuffer.overflowed(); }
|
||||
#endif
|
||||
|
||||
size_t _fillBuffer(uint8_t* data, size_t len) {
|
||||
ChunkPrint dest(data, _sentLength, len);
|
||||
@@ -197,10 +201,10 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
public:
|
||||
#if ARDUINOJSON_VERSION_MAJOR == 6
|
||||
AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE)
|
||||
: _uri(uri), _method(HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), _maxContentLength(16384) {}
|
||||
: _uri(uri), _method(HTTP_GET | HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), _maxContentLength(16384) {}
|
||||
#else
|
||||
AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest)
|
||||
: _uri(uri), _method(HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), _maxContentLength(16384) {}
|
||||
: _uri(uri), _method(HTTP_GET | HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), _maxContentLength(16384) {}
|
||||
#endif
|
||||
|
||||
void setMethod(WebRequestMethodComposite method) { _method = method; }
|
||||
@@ -211,13 +215,14 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
if (!_onRequest)
|
||||
return false;
|
||||
|
||||
if (!(_method & request->method()))
|
||||
WebRequestMethodComposite request_method = request->method();
|
||||
if (!(_method & request_method))
|
||||
return false;
|
||||
|
||||
if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/")))
|
||||
return false;
|
||||
|
||||
if (!request->contentType().equalsIgnoreCase(JSON_MIMETYPE))
|
||||
if (request_method != HTTP_GET && !request->contentType().equalsIgnoreCase(JSON_MIMETYPE))
|
||||
return false;
|
||||
|
||||
request->addInterestingHeader("ANY");
|
||||
@@ -225,8 +230,14 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
|
||||
}
|
||||
|
||||
virtual void handleRequest(AsyncWebServerRequest* request) override final {
|
||||
if((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str()))
|
||||
return request->requestAuthentication();
|
||||
if (_onRequest) {
|
||||
if (request->_tempObject != NULL) {
|
||||
if (request->method() == HTTP_GET) {
|
||||
JsonVariant json;
|
||||
_onRequest(request, json);
|
||||
return;
|
||||
} else if (request->_tempObject != NULL) {
|
||||
|
||||
#if ARDUINOJSON_VERSION_MAJOR == 5
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#ifndef ESP8266
|
||||
#include "mbedtls/sha1.h"
|
||||
#include <rom/ets_sys.h>
|
||||
#else
|
||||
#include <Hash.h>
|
||||
#endif
|
||||
@@ -212,8 +213,6 @@ public:
|
||||
uint8_t opcode(){ return _opcode; }
|
||||
uint8_t len(){ return _len + 2; }
|
||||
size_t send(AsyncClient *client){
|
||||
if (_finished)
|
||||
return 0; // fix from https://github.com/me-no-dev/ESPAsyncWebServer/pull/1390/files
|
||||
_finished = true;
|
||||
return webSocketSendFrame(client, true, _opcode & 0x0F, _mask, _data, _len);
|
||||
}
|
||||
@@ -1274,9 +1273,15 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket
|
||||
(String&)key += WS_STR_UUID;
|
||||
mbedtls_sha1_context ctx;
|
||||
mbedtls_sha1_init(&ctx);
|
||||
#if ESP_IDF_VERSION_MAJOR == 5
|
||||
mbedtls_sha1_starts(&ctx);
|
||||
mbedtls_sha1_update(&ctx, (const unsigned char*)key.c_str(), key.length());
|
||||
mbedtls_sha1_finish(&ctx, hash);
|
||||
#else
|
||||
mbedtls_sha1_starts_ret(&ctx);
|
||||
mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length());
|
||||
mbedtls_sha1_finish_ret(&ctx, hash);
|
||||
#endif
|
||||
mbedtls_sha1_free(&ctx);
|
||||
#endif
|
||||
base64_encodestate _state;
|
||||
|
@@ -40,10 +40,10 @@
|
||||
#error Platform not supported
|
||||
#endif
|
||||
|
||||
#define ASYNCWEBSERVER_VERSION "2.7.0"
|
||||
#define ASYNCWEBSERVER_VERSION "2.9.5"
|
||||
#define ASYNCWEBSERVER_VERSION_MAJOR 2
|
||||
#define ASYNCWEBSERVER_VERSION_MINOR 7
|
||||
#define ASYNCWEBSERVER_VERSION_REVISION 0
|
||||
#define ASYNCWEBSERVER_VERSION_MINOR 9
|
||||
#define ASYNCWEBSERVER_VERSION_REVISION 5
|
||||
#define ASYNCWEBSERVER_FORK_mathieucarbou
|
||||
|
||||
#ifdef ASYNCWEBSERVER_REGEX
|
||||
|
@@ -77,9 +77,15 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
|
||||
memset(_buf, 0x00, 16);
|
||||
#ifdef ESP32
|
||||
mbedtls_md5_init(&_ctx);
|
||||
#if ESP_IDF_VERSION_MAJOR == 5
|
||||
mbedtls_md5_starts(&_ctx);
|
||||
mbedtls_md5_update(&_ctx, data, len);
|
||||
mbedtls_md5_finish(&_ctx, _buf);
|
||||
#else
|
||||
mbedtls_md5_starts_ret(&_ctx);
|
||||
mbedtls_md5_update_ret(&_ctx, data, len);
|
||||
mbedtls_md5_finish_ret(&_ctx, _buf);
|
||||
#endif
|
||||
#else
|
||||
MD5Init(&_ctx);
|
||||
MD5Update(&_ctx, data, len);
|
||||
|
@@ -539,7 +539,7 @@ AsyncFileResponse::AsyncFileResponse(FS &fs, const String& path, const String& c
|
||||
snprintf_P(buf, sizeof (buf), PSTR("attachment; filename=\"%s\""), filename);
|
||||
} else {
|
||||
// set filename and force rendering
|
||||
snprintf_P(buf, sizeof (buf), PSTR("inline; filename=\"%s\""), filename);
|
||||
snprintf_P(buf, sizeof (buf), PSTR("inline"));
|
||||
}
|
||||
addHeader(F("Content-Disposition"), buf);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ AsyncFileResponse::AsyncFileResponse(File content, const String& path, const Str
|
||||
if(download) {
|
||||
snprintf_P(buf, sizeof (buf), PSTR("attachment; filename=\"%s\""), filename);
|
||||
} else {
|
||||
snprintf_P(buf, sizeof (buf), PSTR("inline; filename=\"%s\""), filename);
|
||||
snprintf_P(buf, sizeof (buf), PSTR("inline"));
|
||||
}
|
||||
addHeader(F("Content-Disposition"), buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user