Skip to content

websocket: add option to disable auto-pong reply - #16744

Closed
viscruocco wants to merge 8 commits into
curl:masterfrom
viscruocco:no-auto-pong
Closed

viscruocco wants to merge 8 commits into
curl:masterfrom
viscruocco:no-auto-pong

Conversation

@viscruocco

Copy link
Copy Markdown
Contributor

Rebased #12220 with kind permission of @brimonk.

Additionally added some more documentation and explicitly initialized CURLOPT_WS_OPTIONS values to their defaults.

Comment thread tests/libtest/lib2312.c Resolved
@viscruocco
viscruocco requested a review from vszakats March 19, 2025 15:12
@viscruocco

Copy link
Copy Markdown
Contributor Author

Does anything remain to do, to move this PR forward?

@bagder bagder added the feature-window A merge of this requires an open feature window label Mar 25, 2025
@bagder

bagder commented Mar 25, 2025

Copy link
Copy Markdown
Member

@viscruocco the PR itself looks fine - now we only need to wait for the feature window to open again to allow new features such as this to get merged (for 8.14.0). The feature window for 8.13.0 closed a few weeks ago. You can prepare for this to make sure the PR speaks of the correct version for this feature.

The feature window is planned to open again on April 12.

@bagder bagder changed the title [rebased] websocket: add option to disable auto-pong reply websocket: add option to disable auto-pong reply Mar 25, 2025
Comment thread docs/libcurl/opts/CURLOPT_WS_OPTIONS.md Resolved
Comment thread docs/libcurl/symbols-in-versions Resolved
Comment thread lib/ws.c Resolved
@viscruocco
viscruocco marked this pull request as draft April 9, 2025 13:55
Comment thread docs/libcurl/symbols-in-versions Resolved
@viscruocco
viscruocco marked this pull request as ready for review April 14, 2025 15:22
@bagder bagder closed this in c0df01f Apr 18, 2025
@bagder

bagder commented Apr 18, 2025

Copy link
Copy Markdown
Member

Thanks, both of you!

@viscruocco
viscruocco deleted the no-auto-pong branch April 22, 2025 13:11
nbaws pushed a commit to nbaws/curl that referenced this pull request Apr 26, 2025
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 curl#16744
nbaws pushed a commit to nbaws/curl that referenced this pull request Apr 26, 2025
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 curl#16744
vszakats added a commit that referenced this pull request Oct 16, 2026
…ol type

Setting the `CURLWS_NOAUTOPONG` flag via the `CURLOPT_WS_OPTIONS`
`curl_easy_setopt()` API failed to enable this flag in libcurl builds
using a compiler without a native C99 bool type. This in turn caused
2700, 2709, 2711, 2712 WebSocket tests to fail.

The initial WebSocket code assigned `arg & CURLWS_RAW_MODE` to a
bit-field, after casting the expression to `bool`. This worked because
`CURLWS_RAW_MODE` equals 1. Later this line was cloned when adding
support for `CURLWS_NOAUTOPONG`, but this new bit flag's value was 2.
Casting it to `bool` and then assigning it to a bit-field worked as
expected, as long as the bool type was the C99 one. On compilers without
the C99 bool type, the interim cast did not work, and when assigning the
value 2 to the bit-field, it ended up storing zero/false
unconditionally.

Such compilers are VS2012 and VS2010. For them, another trigger was a
subsequent update that enabled bit-field support for MSVC compilers.

Fix by replacing the `(bool)` cast with `!!`. Also for
`CURLWS_RAW_MODE`, to not rely on the literal value of this macro, and
to avoid reusing this pattern in future code.

There were no other places in the codebase with this pattern. The rest
use either `!!` or ternary expression for this type of conversion.

Discovered while trying to enable tests for MSVC builds in AppVeyor CI,
causing test failures with VS2012 and VS2010.

Refs:
https://en.cppreference.com/c/language/arithmetic_types#Boolean_type
https://en.cppreference.com/c/language/conversion
https://godbolt.org/z/3h5zMfePq

Bug: #23306 (comment)
Bug: #23306 (comment)
Follow-up to 85c841c #20142
Follow-up to c0df01f #16744
Follow-up to 664249d #8995

Cherry-picked from #23306

Closes #23428
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-window A merge of this requires an open feature window libcurl API tests

Development

Successfully merging this pull request may close these issues.

4 participants