Skip to content

ws: return CURLE_WS_DENIED on refused upgrade, reuse connections#21580

Open
bradw456 wants to merge 3 commits into
curl:masterfrom
bradw456:add-ws-denied-err-and-reuse-conns
Open

ws: return CURLE_WS_DENIED on refused upgrade, reuse connections#21580
bradw456 wants to merge 3 commits into
curl:masterfrom
bradw456:add-ws-denied-err-and-reuse-conns

Conversation

@bradw456

Copy link
Copy Markdown

When a WebSocket upgrade is refused (non-101 response), return CURLE_WS_DENIED instead of CURLE_HTTP_RETURNED_ERROR. The HTTP response is still fully processed and the connection is returned to the cache when possible.

Allow WebSocket requests to reuse cached HTTP/HTTPS connections by matching compatible connections in the pool.

@bradw456

Copy link
Copy Markdown
Author

This replaces #20003. This approach uses an error code to indicate a WebSocket server denied an upgrade - the previous approach used an option. Since there was a lot of churn in the previous PR and the description was out of date, I've created this PR.

@bradw456 bradw456 force-pushed the add-ws-denied-err-and-reuse-conns branch 2 times, most recently from bfccff8 to 3018ec0 Compare May 18, 2026 13:34
@bradw456

Copy link
Copy Markdown
Author

Hi @bagder and @vszakats can you have a look at this PR? I think I've addressed all the concerns. See #20003 for previous discussion. Thanks!

@bradw456 bradw456 force-pushed the add-ws-denied-err-and-reuse-conns branch from 3018ec0 to c691c58 Compare May 28, 2026 12:50
@bradw456

Copy link
Copy Markdown
Author

Hi @bagder @vszakats, just checking in on this when you have a moment. This change seems to always hit conflicts with master so its an effort to keep updating it. I'd rather not miss another feature window. I’d love to get it finalized. Is there something more I can do to get it merged? I believe CI failures are related to recent changes in master not these changes.

bradw789 added 3 commits June 16, 2026 13:11
When a WebSocket upgrade is refused (non-101 response), return
CURLE_WS_DENIED instead of CURLE_HTTP_RETURNED_ERROR. The HTTP
response is still fully processed and the connection is returned to the
cache when possible.

Allow WebSocket requests to reuse cached HTTP/HTTPS connections by
matching compatible connections in the pool.
…tead of checking it exactly

Slowness in the CI env made test 10 fail because the timeouts are
tight.  Change condition to make sure max_concurrent isn't exceeded,
rather than match exactly.  I think this matches the spirit of the
happy eyeballs test.
@bradw456 bradw456 force-pushed the add-ws-denied-err-and-reuse-conns branch from 13b52cd to e44be34 Compare June 16, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants