From 3b91281c910e69cb59516b88e148ef126b83f7ed Mon Sep 17 00:00:00 2001 From: yuanjm Date: Wed, 9 Feb 2022 10:15:36 +0800 Subject: [PATCH] esp_http_server: Websocket CLOSE frame can support callback function Closes https://github.com/espressif/esp-idf/issues/7493 --- components/esp_http_server/src/httpd_parse.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/esp_http_server/src/httpd_parse.c b/components/esp_http_server/src/httpd_parse.c index 296a43dfc0..6df2e4cb26 100644 --- a/components/esp_http_server/src/httpd_parse.c +++ b/components/esp_http_server/src/httpd_parse.c @@ -756,13 +756,10 @@ esp_err_t httpd_req_new(struct httpd_data *hd, struct sock_db *sd) ret = httpd_ws_get_frame_type(r); ESP_LOGD(TAG, LOG_FMT("New WS request from existing socket, ws_type=%d"), ra->ws_type); - /* Stop and return here immediately if it's a CLOSE frame */ if (ra->ws_type == HTTPD_WS_TYPE_CLOSE) { + /* Only mark ws_close to true if it's a CLOSE frame */ sd->ws_close = true; - return ret; - } - - if (ra->ws_type == HTTPD_WS_TYPE_PONG) { + } else if (ra->ws_type == HTTPD_WS_TYPE_PONG) { /* Pass the PONG frames to the handler as well, as user app might send PINGs */ ESP_LOGD(TAG, LOG_FMT("Received PONG frame")); }