websocket: add option to disable auto-pong reply

This adds another bitflag on CURLOPT_WS_OPTIONS (CURLWS_NOAUTOPONG) that
disables the default and automatic PONG reply in the WebSocket layer.

Assisted-by: Calvin Ruocco

Closes #16744
This commit is contained in:
Brian Chrzanowski 2024-07-23 22:15:23 -04:00 committed by Daniel Stenberg
parent 21fd64645b
commit c0df01fd94
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
15 changed files with 204 additions and 9 deletions

View file

@ -39,7 +39,8 @@ WebSocket with libcurl can be done two ways.
The new options to `curl_easy_setopt()`:
`CURLOPT_WS_OPTIONS` - to control specific behavior. `CURLWS_RAW_MODE` makes
libcurl provide all WebSocket traffic raw in the callback.
libcurl provide all WebSocket traffic raw in the callback. `CURLWS_NOAUTOPONG`
disables automatic `PONG` replies.
The new function calls:

View file

@ -106,7 +106,8 @@ This is a ping message. It may contain up to 125 bytes of payload text.
libcurl does not verify that the payload is valid UTF-8.
Upon receiving a ping message, libcurl automatically responds with a pong
message unless the **CURLWS_RAW_MODE** bit of CURLOPT_WS_OPTIONS(3) is set.
message unless the **CURLWS_NOAUTOPONG** or **CURLWS_RAW_MODE** bit of
CURLOPT_WS_OPTIONS(3) is set.
## CURLWS_PONG

View file

@ -88,7 +88,8 @@ unidirectional heartbeat.
libcurl automatically responds to server PING messages with a PONG that echoes
the payload of the PING message. libcurl does neither send any PING messages
nor any unsolicited PONG messages automatically.
nor any unsolicited PONG messages automatically. The automatic reply to PING
messages can be disabled through CURLOPT_WS_OPTIONS(3).
# MODELS

View file

@ -44,6 +44,12 @@ callback.
In raw mode, libcurl does not handle pings or any other frame for the
application.
## CURLWS_NOAUTOPONG (2)
Disable the automatic reply to PING messages. This means users must
send a PONG message with curl_ws_send(3). This feature is added with
version 8.14.0.
# DEFAULT
0

View file

@ -1155,6 +1155,7 @@ CURLWARNING 7.66.0
CURLWS_BINARY 7.86.0
CURLWS_CLOSE 7.86.0
CURLWS_CONT 7.86.0
CURLWS_NOAUTOPONG 8.14.0
CURLWS_OFFSET 7.86.0
CURLWS_PING 7.86.0
CURLWS_PONG 7.86.0