mirror of
https://github.com/curl/curl.git
synced 2026-08-25 11:43:36 +03:00
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:
parent
21fd64645b
commit
c0df01fd94
15 changed files with 204 additions and 9 deletions
8
lib/ws.c
8
lib/ws.c
|
|
@ -502,10 +502,12 @@ static ssize_t ws_cw_dec_next(const unsigned char *buf, size_t buflen,
|
|||
struct ws_cw_dec_ctx *ctx = user_data;
|
||||
struct Curl_easy *data = ctx->data;
|
||||
struct websocket *ws = ctx->ws;
|
||||
bool auto_pong = !data->set.ws_no_auto_pong;
|
||||
curl_off_t remain = (payload_len - (payload_offset + buflen));
|
||||
|
||||
(void)frame_age;
|
||||
if((frame_flags & CURLWS_PING) && !remain) {
|
||||
|
||||
if(auto_pong && (frame_flags & CURLWS_PING) && !remain) {
|
||||
/* auto-respond to PINGs, only works for single-frame payloads atm */
|
||||
size_t bytes;
|
||||
infof(data, "WS: auto-respond to PING with a PONG");
|
||||
|
|
@ -949,6 +951,8 @@ static ssize_t ws_client_collect(const unsigned char *buf, size_t buflen,
|
|||
CURLcode *err)
|
||||
{
|
||||
struct ws_collect *ctx = userp;
|
||||
struct Curl_easy *data = ctx->data;
|
||||
bool auto_pong = !data->set.ws_no_auto_pong;
|
||||
size_t nwritten;
|
||||
curl_off_t remain = (payload_len - (payload_offset + buflen));
|
||||
|
||||
|
|
@ -960,7 +964,7 @@ static ssize_t ws_client_collect(const unsigned char *buf, size_t buflen,
|
|||
ctx->payload_len = payload_len;
|
||||
}
|
||||
|
||||
if((frame_flags & CURLWS_PING) && !remain) {
|
||||
if(auto_pong && (frame_flags & CURLWS_PING) && !remain) {
|
||||
/* auto-respond to PINGs, only works for single-frame payloads atm */
|
||||
size_t bytes;
|
||||
infof(ctx->data, "WS: auto-respond to PING with a PONG");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue