Debian Codegraph @

doc/docstrings/curl_ws_recv_into.rst

raw
1 ws_recv_into(buffer[, nbytes]) -> (nbytes, meta)
2
3 Receive a WebSocket frame chunk on a connection established with
4 ``CONNECT_ONLY=2`` into a caller-owned writable *buffer*.
5
6 *buffer* must be a writable bytes-like object (e.g. ``bytearray``,
7 ``memoryview``, ``array.array``).
8
9 If *nbytes* is ``0`` (the default), receive up to ``len(buffer)`` bytes.
10 Otherwise, receive up to *nbytes* bytes.
11
12 Returns a 2-tuple ``(nbytes, meta)`` where *nbytes* is the number of
13 bytes written into *buffer* and *meta* is a ``WsFrame`` namedtuple with
14 the per-frame metadata returned by libcurl for this call.
15
16 Raises ``ValueError`` if *nbytes* is negative or larger than
17 ``len(buffer)``.
18
19 If *buffer* has length ``0``, this performs a zero-length
20 ``curl_ws_recv`` call and returns ``(0, meta)`` so callers can inspect
21 frame metadata without consuming payload bytes. Frames with empty
22 payload are consumed by this action.
23
24 Corresponds to `curl_ws_recv`_ in libcurl. Requires libcurl 7.86.0 or
25 later.
26
27 Because the underlying socket is used in non-blocking mode internally,
28 this method raises ``BlockingIOError`` with ``errno`` set to ``EAGAIN``
29 when libcurl returns ``CURLE_AGAIN``.
30
31 Raises pycurl.error exception upon failures other than ``CURLE_AGAIN``.
32
33 .. _curl_ws_recv: https://curl.se/libcurl/c/curl_ws_recv.html