mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
websocket: introduce blocking sends
When using `curl_ws_send()`, perform a blocking send of the data under the following conditions: - the websocket is in raw mode and the call is done from within a curl callback. A partial write of the data could subsequently mess up the ws framing, as a callback has a hard time handling this. - the websocket is encoding the data itself, has added it to its internal sendbuf. A partial flush of the buffer has unclear semantics for the caller, as they will have no idea what to send again. Fixes WebSockets tests with CURL_DBG_SOCK_WBLOCK=90 set. Closes #14458
This commit is contained in:
parent
0a5ea09a91
commit
3e64569a9e
8 changed files with 299 additions and 60 deletions
|
|
@ -221,6 +221,24 @@ void Curl_trc_ftp(struct Curl_easy *data, const char *fmt, ...)
|
|||
}
|
||||
#endif /* !CURL_DISABLE_FTP */
|
||||
|
||||
#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
|
||||
struct curl_trc_feat Curl_trc_feat_ws = {
|
||||
"WS",
|
||||
CURL_LOG_LVL_NONE,
|
||||
};
|
||||
|
||||
void Curl_trc_ws(struct Curl_easy *data, const char *fmt, ...)
|
||||
{
|
||||
DEBUGASSERT(!strchr(fmt, '\n'));
|
||||
if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ws)) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
trc_infof(data, &Curl_trc_feat_ws, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#endif /* USE_WEBSOCKETS && !CURL_DISABLE_HTTP */
|
||||
|
||||
#define TRC_CT_NONE (0)
|
||||
#define TRC_CT_PROTOCOL (1<<(0))
|
||||
#define TRC_CT_NETWORK (1<<(1))
|
||||
|
|
@ -240,6 +258,9 @@ static struct trc_feat_def trc_feats[] = {
|
|||
#ifndef CURL_DISABLE_DOH
|
||||
{ &Curl_doh_trc, TRC_CT_NETWORK },
|
||||
#endif
|
||||
#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
|
||||
{ &Curl_trc_feat_ws, TRC_CT_PROTOCOL },
|
||||
#endif
|
||||
};
|
||||
|
||||
struct trc_cft_def {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue