option(CURL_DISABLE_SMTP "Disable SMTP" OFF)
mark_as_advanced(CURL_DISABLE_SMTP)
option(CURL_DISABLE_SOCKETPAIR "Disable use of socketpair for curl_multi_poll" OFF)
+option(CURL_DISABLE_WEBSOCKETS "Disable WebSockets" OFF)
+mark_as_advanced(CURL_DISABLE_WEBSOCKETS)
mark_as_advanced(CURL_DISABLE_SOCKETPAIR)
option(CURL_DISABLE_TELNET "Disable Telnet" OFF)
mark_as_advanced(CURL_DISABLE_TELNET)
option(ENABLE_WEBSOCKETS "Enable WebSockets (experimental)" OFF)
-if(ENABLE_WEBSOCKETS)
- if(SIZEOF_CURL_OFF_T GREATER 4)
- set(USE_WEBSOCKETS ON)
- else()
- message(WARNING "curl_off_t is too small to enable WebSockets")
- endif()
-endif()
-
-curl_internal_test(HAVE_GLIBC_STRERROR_R)
-curl_internal_test(HAVE_POSIX_STRERROR_R)
+foreach(_curl_test IN ITEMS
+ HAVE_GLIBC_STRERROR_R
+ HAVE_POSIX_STRERROR_R
+ )
+ curl_internal_test(${_curl_test})
+endforeach()
# Check for reentrant
foreach(_curl_test IN ITEMS
_add_if("RTSP" NOT CURL_DISABLE_RTSP)
_add_if("RTMP" USE_LIBRTMP)
_add_if("MQTT" NOT CURL_DISABLE_MQTT)
-_add_if("WS" USE_WEBSOCKETS)
-_add_if("WSS" USE_WEBSOCKETS AND _ssl_enabled)
+_add_if("WS" NOT CURL_DISABLE_WEBSOCKETS)
+_add_if("WSS" NOT CURL_DISABLE_WEBSOCKETS AND _ssl_enabled)
if(_items)
list(SORT _items)
endif()
curl_altsvc_msg="enabled (--disable-alt-svc)"
curl_headers_msg="enabled (--disable-headers-api)"
curl_hsts_msg="enabled (--disable-hsts)"
- curl_ws_msg="no (--enable-websockets)"
ssl_backends=
curl_h1_msg="enabled (internal)"
curl_h2_msg="no (--with-nghttp2)"
AC_CHECK_FUNCS([SSL_set0_wbio])
fi
-dnl *************************************************************
-dnl WebSockets
-dnl
-AC_MSG_CHECKING([whether to support WebSockets])
-AC_ARG_ENABLE(websockets,
-AS_HELP_STRING([--enable-websockets],[Enable WebSockets support])
-AS_HELP_STRING([--disable-websockets],[Disable WebSockets support]),
-[ case "$enableval" in
- no)
- AC_MSG_RESULT(no)
- ;;
- *)
- if test ${ac_cv_sizeof_curl_off_t} -gt 4; then
- AC_MSG_RESULT(yes)
- curl_ws_msg="enabled"
- AC_DEFINE_UNQUOTED(USE_WEBSOCKETS, [1], [enable WebSockets support])
- SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WS"
- if test "x$SSL_ENABLED" = "x1"; then
- SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WSS"
- fi
- experimental="$experimental WebSockets"
- else
- dnl WebSockets requires >32 bit curl_off_t
+if test "x$CURL_DISABLE_HTTP" != "x1"; then
+ dnl *************************************************************
+ dnl WebSockets
+ dnl
+ AC_MSG_CHECKING([whether to support WebSockets])
+ AC_ARG_ENABLE(websockets,
+ AS_HELP_STRING([--enable-websockets],[Enable WebSockets support])
+ AS_HELP_STRING([--disable-websockets],[Disable WebSockets support]),
+ [ case "$enableval" in
+ no)
AC_MSG_RESULT(no)
- AC_MSG_WARN([WebSockets disabled due to lack of >32 bit curl_off_t])
- fi
- ;;
- esac ],
- AC_MSG_RESULT(no)
-)
-
+ AC_DEFINE(CURL_DISABLE_WEBSOCKETS, [1], [disable WebSockets])
+ AC_SUBST(CURL_DISABLE_WEBSOCKETS, [1])
+ ;;
+ *)
+ if test ${ac_cv_sizeof_curl_off_t} -gt 4; then
+ AC_MSG_RESULT(yes)
+ else
+ dnl WebSockets requires >32 bit curl_off_t
+ AC_MSG_RESULT(no)
+ AC_MSG_WARN([WebSockets disabled due to lack of >32 bit curl_off_t])
+ AC_DEFINE(CURL_DISABLE_WEBSOCKETS, [1], [disable WebSockets])
+ AC_SUBST(CURL_DISABLE_WEBSOCKETS, [1])
+ fi
+ ;;
+ esac ],
+ AC_MSG_RESULT(yes)
+ )
+else
+ AC_MSG_WARN([WebSockets disabled because HTTP is disabled])
+ AC_DEFINE(CURL_DISABLE_WEBSOCKETS, [1], [disable WebSockets])
+ AC_SUBST(CURL_DISABLE_WEBSOCKETS, [1])
+fi
dnl ************************************************************
dnl hiding of library internal symbols
if test "x$USE_LIBRTMP" = "x1"; then
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP"
fi
+if test "x$CURL_DISABLE_WEBSOCKETS" != "x1"; then
+ SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WS"
+ if test "x$SSL_ENABLED" = "x1"; then
+ SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WSS"
+ fi
+fi
dnl replace spaces with newlines
dnl sort the lines
HTTP2: ${curl_h2_msg}
HTTP3: ${curl_h3_msg}
ECH: ${curl_ech_msg}
- WebSockets: ${curl_ws_msg}
Protocols: ${SUPPORT_PROTOCOLS_LOWER}
Features: ${SUPPORT_FEATURES}
])
## `CURL_DISABLE_VERBOSE_STRINGS`
Disable verbose strings and error messages.
+
+## `CURL_DISABLE_WEBSOCKETS`
+
+Disable the WebSocket protocols.
- a reasonable expectation of a stable API going forward.
-### WebSocket
-
-Graduation requirements:
-
-- feedback from users saying that the API works for their specific use cases
-
-- unless the above happens, we consider WebSocket silently working by
- September 2024 when it has been stewing as EXPERIMENTAL for two years.
-
## ECH
Use of the HTTPS resource record and Encrypted Client Hello (ECH) when using
k->deductheadercount =
(100 <= http_status && 199 >= http_status) ? k->headerbytecount : 0;
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
if(k->upgr101 == UPGR101_WS) {
if(http_status == 101) {
/* verify the response */
/* disables SMTP */
#cmakedefine CURL_DISABLE_SMTP 1
+/* disabled WebSockets */
+#cmakedefine CURL_DISABLE_WEBSOCKETS 1
+
/* disables use of socketpair for curl_multi_poll */
#cmakedefine CURL_DISABLE_SOCKETPAIR 1
/* to enable Apple IDN */
#cmakedefine USE_APPLE_IDN 1
-/* Define to 1 to enable websocket support. */
-#cmakedefine USE_WEBSOCKETS 1
-
/* Define to 1 if OpenSSL has the SSL_CTX_set_srp_username function. */
#cmakedefine HAVE_OPENSSL_SRP 1
}
#endif /* !CURL_DISABLE_SMTP */
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
struct curl_trc_feat Curl_trc_feat_ws = {
"WS",
CURL_LOG_LVL_NONE,
va_end(ap);
}
}
-#endif /* USE_WEBSOCKETS && !CURL_DISABLE_HTTP */
+#endif /* !CURL_DISABLE_WEBSOCKETS && !CURL_DISABLE_HTTP */
#define TRC_CT_NONE (0)
#define TRC_CT_PROTOCOL (1<<(0))
#ifndef CURL_DISABLE_SMTP
{ &Curl_trc_feat_smtp, TRC_CT_PROTOCOL },
#endif
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
{ &Curl_trc_feat_ws, TRC_CT_PROTOCOL },
#endif
};
do { if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_smtp)) \
Curl_trc_smtp(data, __VA_ARGS__); } while(0)
#endif /* !CURL_DISABLE_SMTP */
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
-#define CURL_TRC_WS(data, ...) \
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#define CURL_TRC_WS(data, ...) \
do { if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ws)) \
Curl_trc_ws(data, __VA_ARGS__); } while(0)
-#endif /* USE_WEBSOCKETS && !CURL_DISABLE_HTTP */
+#endif /* !CURL_DISABLE_WEBSOCKETS && !CURL_DISABLE_HTTP */
#else /* CURL_HAVE_C99 */
#ifndef CURL_DISABLE_SMTP
#define CURL_TRC_SMTP Curl_trc_smtp
#endif
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
#define CURL_TRC_WS Curl_trc_ws
#endif
void Curl_trc_smtp(struct Curl_easy *data,
const char *fmt, ...) CURL_PRINTF(2, 3);
#endif
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
extern struct curl_trc_feat Curl_trc_feat_ws;
void Curl_trc_ws(struct Curl_easy *data,
const char *fmt, ...) CURL_PRINTF(2, 3);
(void)data; (void)fmt;
}
#endif
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) || !defined(CURL_DISABLE_HTTP)
static void Curl_trc_ws(struct Curl_easy *data, const char *fmt, ...)
{
(void)data; (void)fmt;
return CURLE_OK;
}
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
CURLcode Curl_connect_only_attach(struct Curl_easy *data)
{
CURLcode result;
return CURLE_OK;
}
-#endif /* USE_WEBSOCKETS */
+#endif /* !CURL_DISABLE_WEBSOCKETS */
/*
* Sends data over the connected socket.
CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
size_t buflen, size_t *n);
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
CURLcode Curl_connect_only_attach(struct Curl_easy *data);
#endif
}
result = Curl_http_cookies(data, conn, &req);
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
if(!result && conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
result = Curl_ws_request(data, &req);
#endif
goto out;
*pconsumed += blen;
}
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
else if(k->upgr101 == UPGR101_WS) {
/* verify the response. Any passed `buf` bytes are already in
* WebSockets format and taken in by the protocol handler. */
}
#endif
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
/* All >=200 HTTP status codes are errors when wanting WebSockets */
if(data->req.upgr101 == UPGR101_WS) {
failf(data, "Refused WebSockets upgrade: %d", k->httpcode);
case CURLOPT_PREREQDATA:
data->set.prereq_userp = va_arg(param, void *);
break;
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
case CURLOPT_WS_OPTIONS: {
bool raw;
arg = va_arg(param, long);
#else
NULL,
#endif
-#if defined(USE_WEBSOCKETS) && \
+#if !defined(CURL_DISABLE_WEBSOCKETS) && \
defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
&Curl_handler_wss,
#else
NULL,
#endif
NULL,
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
&Curl_handler_ws,
#else
NULL,
}
if(!proxy) {
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
/* websocket proxy fallbacks */
if(strcasecompare("ws_proxy", proxy_env)) {
proxy = curl_getenv("http_proxy");
envp = (char *)"ALL_PROXY";
proxy = curl_getenv(envp);
}
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
}
#endif
}
# define CURLECH_CLA_CFG (1<<4)
#endif
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
/* CURLPROTO_GOPHERS (29) is the highest publicly used protocol bit number,
* the rest are internal information. If we use higher bits we only do this on
* platforms that have a >= 64-bit type and then we use such a type for the
#ifndef CURL_DISABLE_MQTT
struct mqtt_conn mqtt;
#endif
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
struct websocket *ws;
#endif
unsigned int unused:1; /* avoids empty union */
BIT(doh_verifystatus); /* DoH certificate status verification */
#endif
BIT(http09_allowed); /* allow HTTP/0.9 responses */
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
BIT(ws_raw_mode);
#endif
#ifdef USE_ECH
#ifndef CURL_DISABLE_TFTP
"tftp",
#endif
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_HTTP
+ /* WebSocket support relies on HTTP */
+#ifndef CURL_DISABLE_WEBSOCKETS
"ws",
#endif
-#if defined(USE_SSL) && defined(USE_WEBSOCKETS)
+#if defined(USE_SSL) && !defined(CURL_DISABLE_WEBSOCKETS)
"wss",
+#endif
#endif
NULL
#include "curl_setup.h"
#include <curl/curl.h>
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
#include "urldata.h"
#include "bufq.h"
{
struct connectdata *conn = data->conn;
struct websocket *ws;
- bool done = FALSE; /* not filled passed buffer yet */
struct ws_collect ctx;
- CURLcode result;
if(!conn) {
/* Unhappy hack with lifetimes of transfers and connection */
ctx.buffer = buffer;
ctx.buflen = buflen;
- while(!done) {
+ while(1) {
+ CURLcode result;
+
/* receive more when our buffer is empty */
if(Curl_bufq_is_empty(&ws->recvbuf)) {
ssize_t n = Curl_bufq_slurp(&ws->recvbuf, nw_in_recv, data, &result);
ws_dec_info(&ws->dec, data, "need more input");
continue; /* nothing written, try more input */
}
- done = TRUE;
break;
}
else if(result) {
/* The decoded frame is passed back to our caller.
* There are frames like PING were we auto-respond to and
* that we do not return. For these `ctx.written` is not set. */
- done = TRUE;
break;
}
}
(void)data;
return NULL;
}
-#endif /* USE_WEBSOCKETS */
+#endif /* !CURL_DISABLE_WEBSOCKETS */
***************************************************************************/
#include "curl_setup.h"
-#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
+#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
#ifdef USE_HYPER
#define REQTYPE void
{"smtps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)" },
{"telnet", "#ifndef CURL_DISABLE_TELNET" },
{"tftp", "#ifndef CURL_DISABLE_TFTP" },
- {"ws", "#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)" },
- {"wss", "#if defined(USE_WEBSOCKETS) && \\\n"
+ {"ws",
+ "#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)" },
+ {"wss", "#if !defined(CURL_DISABLE_WEBSOCKETS) && \\\n"
" defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" },
{ NULL, NULL }
};
#include <stdlib.h>
#include <string.h>
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
int main(int argc, char *argv[])
{
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
CURL *curl;
CURLcode res = CURLE_OK;
const char *url;
curl_global_cleanup();
return (int)res;
-#else /* USE_WEBSOCKETS */
+#else /* !CURL_DISABLE_WEBSOCKETS */
(void)argc;
(void)argv;
fprintf(stderr, "WebSockets not enabled in libcurl\n");
return 1;
-#endif /* !USE_WEBSOCKETS */
+#endif /* CURL_DISABLE_WEBSOCKETS */
}
#include <sys/time.h>
#endif
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
static CURLcode ping(CURL *curl, const char *send_payload)
{
int main(int argc, char *argv[])
{
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
CURL *curl;
CURLcode res = CURLE_OK;
const char *url, *payload;
curl_global_cleanup();
return (int)res;
-#else /* USE_WEBSOCKETS */
+#else /* !CURL_DISABLE_WEBSOCKETS */
(void)argc;
(void)argv;
fprintf(stderr, "WebSockets not enabled in libcurl\n");
return 1;
-#endif /* !USE_WEBSOCKETS */
+#endif /* CURL_DISABLE_WEBSOCKETS */
}
{"https://user@example.net",
"https | user | [12] | [13] | example.net | [15] | / | [16] | [17]",
0, 0, CURLUE_OK},
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
{"ws://example.com/color/?green",
"ws | [11] | [12] | [13] | example.com | [15] | /color/ | green |"
" [17]",
#include "test.h"
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
#if 0
static CURLcode send_ping(CURL *curl, const char *send_payload)
#include "test.h"
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
struct ws_data {
CURL *easy;
#include "test.h"
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
static CURLcode send_ping(CURL *curl, const char *send_payload)
{
#include "testtrace.h"
#include "memdebug.h"
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
/* just close the connection */
static void websocket_close(CURL *curl)
!ENDIF
!ENDIF
-!IF "$(ENABLE_WEBSOCKETS)"=="true"
-CFLAGS = $(CFLAGS) /DUSE_WEBSOCKETS=1
+!IF "$(DISABLE_WEBSOCKETS)"=="true"
+CFLAGS = $(CFLAGS) /DCURL_DISABLE_WEBSOCKETS=1
!ENDIF
!IFDEF NGHTTP2_PATH