http_server: Add a flag to enable using control frames in user handlers

This commit is contained in:
David Cermak
2020-09-07 16:24:26 +02:00
parent 76ca826758
commit 5e1e5f8be9
5 changed files with 14 additions and 3 deletions

View File

@@ -772,8 +772,9 @@ esp_err_t httpd_req_new(struct httpd_data *hd, struct sock_db *sd)
ESP_LOGD(TAG, LOG_FMT("Received PONG frame"));
}
/* Call handler if it's a non-control frame */
if (ret == ESP_OK && ra->ws_type <= HTTPD_WS_TYPE_PONG) {
/* Call handler if it's a non-control frame (or if handler requests control frames, as well) */
if (ret == ESP_OK &&
(ra->ws_type < HTTPD_WS_TYPE_CLOSE || sd->ws_control_frames)) {
ret = sd->ws_handler(r);
}