docs: Update CN translation for protocols.rst

This commit is contained in:
Zhang Shuxian
2026-06-05 17:31:43 +08:00
committed by Ashish Sharma
parent 4852f54610
commit 24c97d55ab
2 changed files with 74 additions and 12 deletions
@@ -110,11 +110,9 @@ ESP HTTP Server
WebSocket Handler No Longer Called During Handshake
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From v6.0.1, the URI handler registered
for a WebSocket endpoint is **no longer called** during the WebSocket handshake.
Prior to this change, the handler was invoked with ``req->method == HTTP_GET``
immediately after the handshake completed, which applications used for
connection-time initialization:
From v6.0.1, the URI handler registered for a WebSocket endpoint is **no longer called** during the WebSocket handshake.
Prior to this change, the handler was invoked with ``req->method == HTTP_GET`` immediately after the handshake completed, which applications used for connection-time initialization:
.. code-block:: c
@@ -128,8 +126,7 @@ connection-time initialization:
/* Handle WebSocket frames ... */
}
From v6.0.1, the handler is invoked only for subsequent WebSocket data frames,
so the ``HTTP_GET`` check is no longer needed in frame handlers.
From v6.0.1, the handler is invoked only for subsequent WebSocket data frames, so the ``HTTP_GET`` check is no longer needed in frame handlers.
Migration Options
^^^^^^^^^^^^^^^^^
@@ -137,8 +134,7 @@ Migration Options
**Option 1 (Recommended)** — Move connection-time logic into a dedicated post-handshake callback:
1. Enable :ref:`CONFIG_HTTPD_WS_POST_HANDSHAKE_CB_SUPPORT` in menuconfig.
2. Register a ``ws_post_handshake_cb`` on the ``httpd_uri_t`` struct. The frame handler
remains clean with no ``HTTP_GET`` check.
2. Register a ``ws_post_handshake_cb`` on the ``httpd_uri_t`` struct. The frame handler remains clean with no ``HTTP_GET`` check.
.. code-block:: c
@@ -164,9 +160,7 @@ Migration Options
**Option 2 (Minimal change)** — Set ``.ws_post_handshake_cb`` to the same function as ``.handler``:
1. Enable :ref:`CONFIG_HTTPD_WS_POST_HANDSHAKE_CB_SUPPORT` in menuconfig.
2. Set ``.ws_post_handshake_cb = ws_handler`` in the URI registration. The existing
``if (req->method == HTTP_GET)`` check inside the handler continues to work
without any further code changes.
2. Set ``.ws_post_handshake_cb = ws_handler`` in the URI registration. The existing ``if (req->method == HTTP_GET)`` check inside the handler continues to work without any further code changes.
.. code-block:: c