Repository navigation
Conversation
CURLOPT_WS_OPTIONS(3) documents that in raw mode (CURLWS_RAW_MODE), libcurl does not handle pings or any other frame for the application. Previously, auto_pong only checked !data->set.ws_no_auto_pong, ignoring data->set.ws_raw_mode. As a result, receiving a PING in raw mode caused libcurl to intercept the frame, discard it from the application stream, and queue an automatic PONG into ws->pending. When sending raw data via curl_ws_send(), ws_flush() would inject this unexpected PONG control frame into the application's raw stream, corrupting message framing. Disable auto_pong whenever ws_raw_mode is active.
bagder
approved these changes
Sep 22, 2026
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The connect-only raw-mode regression needs automated test coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
What changed in this PR
Prevents automatic WebSocket PONG handling in raw mode.
Changes:
- Disables auto-PONG in callback and
curl_ws_recv()paths when raw mode is enabled.
| File | Description |
|---|---|
lib/ws.c |
Adds raw-mode checks to auto-PONG logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| struct ws_collect *ctx = userp; | ||
| struct Curl_easy *data = ctx->data; | ||
| bool auto_pong = !data->set.ws_no_auto_pong; | ||
| bool auto_pong = !data->set.ws_raw_mode && !data->set.ws_no_auto_pong; |
filtede98
force-pushed
the
fix-ws-raw-mode-auto-pong
branch
from
September 22, 2026 12:55
30089cd to
73fdcde
Compare
filtede98
force-pushed
the
fix-ws-raw-mode-auto-pong
branch
from
September 22, 2026 13:27
73fdcde to
30089cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
According to
CURLOPT_WS_OPTIONS(3):However, in
lib/ws.c(ws_cw_dec_next()andws_client_collect()),auto_pongwas computed as:which omitted checking
data->set.ws_raw_mode.Consequence
When receiving a WebSocket
PINGframe whileCURLWS_RAW_MODEis enabled:auto_pongevaluates totrue, causing libcurl to intercept thePINGframe and discard it from the application stream (ctx.writtenremains unset).PONGintows->pending.curl_ws_recv(), line 1689 checksif(!data->set.ws_raw_mode && ws->pending.type), intentionally skipping flushing pending control frames in raw mode. Consequently, the peer never receives a pong reply and may timeout.curl_ws_send(),ws_flush()callsws_enc_add_pending(), injecting the queuedPONGcontrol frame directly into the application's raw stream, corrupting user frame boundaries and protocol state.Fix
Disable
auto_pongwheneverws_raw_modeis active:Verified with
checksrc.pl(0 warnings).