| 1 |
ws_recv(buffersize) -> (data, meta) |
| 2 |
|
| 3 |
Receive a WebSocket frame chunk on a connection established with |
| 4 |
``CONNECT_ONLY=2``. |
| 5 |
|
| 6 |
Receive up to *buffersize* bytes. Returns a 2-tuple ``(data, meta)`` |
| 7 |
where *data* is a ``bytes`` object containing the received payload chunk |
| 8 |
and *meta* is a ``WsFrame`` namedtuple carrying the per-frame metadata |
| 9 |
returned by libcurl for this call (``age``, ``flags``, ``offset``, |
| 10 |
``bytesleft``, ``len``). |
| 11 |
|
| 12 |
A single call may return only part of a frame's payload: check |
| 13 |
``meta.bytesleft`` to decide whether to loop. Reassembly of fragmented |
| 14 |
messages is the caller's responsibility. |
| 15 |
|
| 16 |
A *buffersize* of ``0`` performs a zero-length ``curl_ws_recv`` call. |
| 17 |
This returns ``(b"", meta)`` so callers can inspect frame metadata |
| 18 |
without consuming payload bytes. Frames with empty payload are consumed |
| 19 |
by this action. |
| 20 |
|
| 21 |
Raises ``ValueError`` if *buffersize* is negative. |
| 22 |
|
| 23 |
Corresponds to `curl_ws_recv`_ in libcurl. Requires libcurl 7.86.0 or |
| 24 |
later. |
| 25 |
|
| 26 |
Because the underlying socket is used in non-blocking mode internally, |
| 27 |
this method raises ``BlockingIOError`` with ``errno`` set to ``EAGAIN`` |
| 28 |
when libcurl returns ``CURLE_AGAIN``. |
| 29 |
|
| 30 |
Raises pycurl.error exception upon failures other than ``CURLE_AGAIN``. |
| 31 |
|
| 32 |
.. _curl_ws_recv: https://curl.se/libcurl/c/curl_ws_recv.html |