Skip to content

Commit

Permalink
Merge branch 'suicide' into espasyncws
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Aug 8, 2024
2 parents dbb3886 + faefbec commit ede6355
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/PsychicHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PsychicHttpServer::PsychicHttpServer(uint16_t port) :
config.close_fn = PsychicHttpServer::closeCallback;
config.uri_match_fn = httpd_uri_match_wildcard;
config.global_user_ctx = this;
config.global_user_ctx_free_fn = destroy;
config.max_uri_handlers = 20;
config.server_port = port;

Expand Down Expand Up @@ -54,6 +55,11 @@ PsychicHttpServer::~PsychicHttpServer()
delete defaultEndpoint;
}

void PsychicHttpServer::destroy(void *ctx)
{
// do not release any resource for PsychicHttpServer in order to be able to restart it after stopping
}

esp_err_t PsychicHttpServer::listen(uint16_t port)
{
this->_use_ssl = false;
Expand Down
2 changes: 2 additions & 0 deletions src/PsychicHttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PsychicHttpServer

PsychicEndpoint *defaultEndpoint;

static void destroy(void *ctx);

esp_err_t listen(uint16_t port);

virtual esp_err_t stop();
Expand Down
1 change: 1 addition & 0 deletions src/PsychicHttpsServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PsychicHttpsServer::PsychicHttpsServer(uint16_t port) : PsychicHttpServer(port)
ssl_config.httpd.close_fn = PsychicHttpServer::closeCallback;
ssl_config.httpd.uri_match_fn = httpd_uri_match_wildcard;
ssl_config.httpd.global_user_ctx = this;
ssl_config.httpd.global_user_ctx_free_fn = destroy;
ssl_config.httpd.max_uri_handlers = 20;

// each SSL connection takes about 45kb of heap
Expand Down
2 changes: 1 addition & 1 deletion src/PsychicWebHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ esp_err_t PsychicWebHandler::handleRequest(PsychicRequest *request)
//get our body loaded up.
esp_err_t err = request->loadBody();
if (err != ESP_OK) {
ESP_LOGE(PH_TAG, "Failed to load body (%S)", esp_err_to_name(err));
ESP_LOGE(PH_TAG, "Failed to load body (%s)", esp_err_to_name(err));
return err;
}

Expand Down

0 comments on commit ede6355

Please sign in to comment.