diff --git a/CHANGELOG.md b/CHANGELOG.md index 60c2f81..6b4e49e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,4 +13,5 @@ * PsychicHttpServerRequest -> PsychicRequest * PsychicHttpServerResponse -> PsychicResponse * PsychicHttpWebsocket.h -> PsychicWebSocket.h - * Websocket => WebSocket \ No newline at end of file + * Websocket => WebSocket +* Quite a few bugfixes from the community. \ No newline at end of file diff --git a/README.md b/README.md index 238d7b0..2ba9510 100644 --- a/README.md +++ b/README.md @@ -589,15 +589,10 @@ ArduinoMongoose is a good alternative, although the latency issues when it gets # Roadmap -## v1.1: Event Source + Handlers +## v1.2: ESPAsyncWebserver Parity -* Fix all outstanding issues on Github * Another pass over the docs * DefaultHeaders - - -## v1.2: ESPAsyncWebserver Parity - * HTTP_ANY support (by abusing httpd_req_handle_err) * Issue: it would log a warning on every request (httpd_uri.c:298) * Issue: req->user_ctx is not passed in. (httpd_uri.c:309) diff --git a/library.json b/library.json index 2eca5b1..e6f8a7a 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "PsychicHttp", - "version": "1.0.1", + "version": "1.1.0", "description": "Arduino style wrapper around ESP-IDF HTTP library. HTTP server with SSL + websockets. Works on esp32 and probably esp8266", "keywords": "network,http,https,tcp,ssl,tls,websocket,espasyncwebserver", "repository": @@ -32,7 +32,7 @@ { "owner": "bblanchon", "name": "ArduinoJson", - "version": "^6.21.4" + "version": "^7.0.4" }, { "owner": "bblanchon", diff --git a/library.properties b/library.properties index 8557da1..d2b104e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=PsychicHttp -version=1.0.1 +version=1.1.0 author=Zach Hoeken maintainer=Zach Hoeken sentence=PsychicHttp is a robust webserver that supports http/https + websockets. diff --git a/src/PsychicHandler.cpp b/src/PsychicHandler.cpp index f02971f..097b30e 100644 --- a/src/PsychicHandler.cpp +++ b/src/PsychicHandler.cpp @@ -7,7 +7,8 @@ PsychicHandler::PsychicHandler() : _password(""), _method(DIGEST_AUTH), _realm(""), - _authFailMsg("") + _authFailMsg(""), + _subprotocol("") {} PsychicHandler::~PsychicHandler() { @@ -26,6 +27,13 @@ bool PsychicHandler::filter(PsychicRequest *request){ return _filter == NULL || _filter(request); } +void PsychicHandler::setSubprotocol(const String& subprotocol) { + this->_subprotocol = subprotocol; +} +const char* PsychicHandler::getSubprotocol() const { + return _subprotocol.c_str(); +} + PsychicHandler* PsychicHandler::setAuthentication(const char *username, const char *password, HTTPAuthMethod method, const char *realm, const char *authFailMsg) { _username = String(username); _password = String(password); diff --git a/src/PsychicHandler.h b/src/PsychicHandler.h index 72d795c..bad62bf 100644 --- a/src/PsychicHandler.h +++ b/src/PsychicHandler.h @@ -24,6 +24,8 @@ class PsychicHandler { String _realm; String _authFailMsg; + String _subprotocol; + std::list _clients; public: @@ -39,6 +41,9 @@ class PsychicHandler { virtual bool isWebSocket() { return false; }; + void setSubprotocol(const String& subprotocol); + const char* getSubprotocol() const; + PsychicClient * checkForNewClient(PsychicClient *client); void checkForClosedClient(PsychicClient *client); diff --git a/src/PsychicHttpServer.cpp b/src/PsychicHttpServer.cpp index e48a73b..f318764 100644 --- a/src/PsychicHttpServer.cpp +++ b/src/PsychicHttpServer.cpp @@ -141,7 +141,8 @@ PsychicEndpoint* PsychicHttpServer::on(const char* uri, http_method method, Psyc .method = method, .handler = PsychicEndpoint::requestCallback, .user_ctx = endpoint, - .is_websocket = handler->isWebSocket() + .is_websocket = handler->isWebSocket(), + .supported_subprotocol = handler->getSubprotocol() }; // Register endpoint with ESP-IDF server