Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dzungpv committed May 25, 2024
2 parents ec80969 + b4d54fb commit 932b662
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
* PsychicHttpServerRequest -> PsychicRequest
* PsychicHttpServerResponse -> PsychicResponse
* PsychicHttpWebsocket.h -> PsychicWebSocket.h
* Websocket => WebSocket
* Websocket => WebSocket
* Quite a few bugfixes from the community.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -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":
Expand Down Expand Up @@ -32,7 +32,7 @@
{
"owner": "bblanchon",
"name": "ArduinoJson",
"version": "^6.21.4"
"version": "^7.0.4"
},
{
"owner": "bblanchon",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PsychicHttp
version=1.0.1
version=1.1.0
author=Zach Hoeken <[email protected]>
maintainer=Zach Hoeken <[email protected]>
sentence=PsychicHttp is a robust webserver that supports http/https + websockets.
Expand Down
10 changes: 9 additions & 1 deletion src/PsychicHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ PsychicHandler::PsychicHandler() :
_password(""),
_method(DIGEST_AUTH),
_realm(""),
_authFailMsg("")
_authFailMsg(""),
_subprotocol("")
{}

PsychicHandler::~PsychicHandler() {
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/PsychicHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class PsychicHandler {
String _realm;
String _authFailMsg;

String _subprotocol;

std::list<PsychicClient*> _clients;

public:
Expand All @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/PsychicHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 932b662

Please sign in to comment.