Debian Codegraph @

doc/docstrings/curl_ws_meta.rst

raw
1 ws_meta() -> WsFrame or None
2
3 Return a snapshot of the current WebSocket frame's metadata.
4
5 This is a callback-context helper. It is intended to be called from
6 inside an active ``WRITEFUNCTION`` callback on a WebSocket transfer,
7 where it returns a ``WsFrame`` namedtuple with the metadata of the
8 chunk currently being delivered.
9
10 Outside that context — including when used in detached mode
11 (``CONNECT_ONLY=2``), after ``perform()`` has returned, or on a
12 non-WebSocket transfer — libcurl's ``curl_ws_meta()`` returns ``NULL``
13 and PycURL maps that ``NULL`` to Python ``None``. No exception is
14 raised; callers can use ``if c.ws_meta() is None`` to probe context
15 validity.
16
17 In detached mode, prefer the metadata returned directly by
18 ``ws_recv()`` / ``ws_recv_into()`` rather than a separate ``ws_meta()``
19 call.
20
21 Corresponds to `curl_ws_meta`_ in libcurl. Requires libcurl 7.86.0 or
22 later.
23
24 .. _curl_ws_meta: https://curl.se/libcurl/c/curl_ws_meta.html