In CURLWS_RAW_MODE, to not add an encoding reader, so clients can send raw frames.

This commit is contained in:
Stefan Eissing 2025-07-31 11:26:12 +02:00
parent e2bbfc437b
commit f61706cbac
No known key found for this signature in database
2 changed files with 19 additions and 9 deletions

View file

@ -39,6 +39,7 @@ Available bits in the bitmask
## CURLWS_RAW_MODE (1)
Deliver "raw" WebSocket traffic to the CURLOPT_WRITEFUNCTION(3)
callback. Read "raw" WebSocket traffic from the CURLOPT_READFUNCTION(3)
callback.
In raw mode, libcurl does not handle pings or any other frame for the

View file

@ -1185,15 +1185,17 @@ CURLcode Curl_ws_accept(struct Curl_easy *data,
if(result)
goto out;
/* Add our client readerr encoding WS BINARY frames */
result = Curl_creader_create(&ws_enc_reader, data, &ws_cr_encode,
CURL_CR_CONTENT_ENCODE);
if(result)
goto out;
result = Curl_creader_add(data, ws_enc_reader);
if(result)
goto out;
ws_enc_reader = NULL; /* owned by transfer now */
if(!data->set.ws_raw_mode) {
/* Add our client readerr encoding WS BINARY frames */
result = Curl_creader_create(&ws_enc_reader, data, &ws_cr_encode,
CURL_CR_CONTENT_ENCODE);
if(result)
goto out;
result = Curl_creader_add(data, ws_enc_reader);
if(result)
goto out;
ws_enc_reader = NULL; /* owned by transfer now */
}
/* start over with sending */
data->req.eos_read = FALSE;
@ -1723,6 +1725,13 @@ CURL_EXTERN CURLcode curl_ws_start_frame(CURL *d,
CURLcode result = CURLE_OK;
struct Curl_easy *data = d;
if(!GOOD_EASY_HANDLE(data))
return CURLE_BAD_FUNCTION_ARGUMENT;
if(data->set.ws_raw_mode) {
failf(data, "cannot curl_ws_start_frame() with CURLWS_RAW_MODE enabled");
return CURLE_FAILED_INIT;
}
CURL_TRC_WS(data, "curl_start_frame(flags=%x, frame_len=%" FMT_OFF_T,
flags, frame_len);