From 147f342e8470a89797dfc7599096ff7384acb103 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Wed, 23 Oct 2024 10:13:58 +0200 Subject: [PATCH] added isWebSocketUpgrade(), isSSE(), isHTTP() methods --- src/ESPAsyncWebServer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ESPAsyncWebServer.h b/src/ESPAsyncWebServer.h index 538fd11..2d41d9f 100644 --- a/src/ESPAsyncWebServer.h +++ b/src/ESPAsyncWebServer.h @@ -275,6 +275,9 @@ class AsyncWebServerRequest { RequestedConnectionType requestedConnType() const { return _reqconntype; } bool isExpectedRequestedConnType(RequestedConnectionType erct1, RequestedConnectionType erct2 = RCT_NOT_USED, RequestedConnectionType erct3 = RCT_NOT_USED) const; + bool isWebSocketUpgrade() const { return _method == HTTP_GET && isExpectedRequestedConnType(RCT_WS); } + bool isSSE() const { return _method == HTTP_GET && isExpectedRequestedConnType(RCT_EVENT); } + bool isHTTP() const { return isExpectedRequestedConnType(RCT_DEFAULT, RCT_HTTP); } void onDisconnect(ArDisconnectHandler fn); // hash is the string representation of: