]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
WebSockets: make support official (non-experimental)
authorDaniel Stenberg <daniel@haxx.se>
Fri, 27 Sep 2024 11:19:55 +0000 (13:19 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 27 Sep 2024 11:20:25 +0000 (13:20 +0200)
Inverts the configure/cmake options to instead provide options that
disable WebSockets and have them (ws + wss) enabled by default.

Closes #14936

26 files changed:
CMakeLists.txt
configure.ac
docs/CURL-DISABLE.md
docs/EXPERIMENTAL.md
lib/c-hyper.c
lib/curl_config.h.cmake
lib/curl_trc.c
lib/curl_trc.h
lib/easy.c
lib/easyif.h
lib/http.c
lib/setopt.c
lib/url.c
lib/urldata.h
lib/version.c
lib/ws.c
lib/ws.h
scripts/schemetable.c
tests/http/clients/ws-data.c
tests/http/clients/ws-pingpong.c
tests/libtest/lib1560.c
tests/libtest/lib2301.c
tests/libtest/lib2302.c
tests/libtest/lib2304.c
tests/libtest/lib2305.c
winbuild/MakefileBuild.vc

index e7b7e849ec2fe28f8a9f6320564f208ed7e94613..e9f2e77d02383d0f00a6822d1685f8fcba506abc 100644 (file)
@@ -345,6 +345,8 @@ mark_as_advanced(CURL_DISABLE_SMB)
 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)
@@ -1608,16 +1610,12 @@ unset(CMAKE_REQUIRED_FLAGS)
 
 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
@@ -1855,8 +1853,8 @@ _add_if("IPNS"          NOT CURL_DISABLE_IPFS)
 _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()
index 9565055c7e5198cf3e976a938d11743bb845055c..e558032e51fa28348a7fcaab644b5bae177615f7 100644 (file)
@@ -175,7 +175,6 @@ curl_verbose_msg="enabled (--disable-verbose)"
  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)"
@@ -4954,37 +4953,39 @@ if test "x$OPENSSL_ENABLED" = "x1"; then
   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
@@ -5311,6 +5312,12 @@ fi
 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
@@ -5428,7 +5435,6 @@ AC_MSG_NOTICE([Configured to build curl/libcurl:
   HTTP2:            ${curl_h2_msg}
   HTTP3:            ${curl_h3_msg}
   ECH:              ${curl_ech_msg}
-  WebSockets:       ${curl_ws_msg}
   Protocols:        ${SUPPORT_PROTOCOLS_LOWER}
   Features:         ${SUPPORT_FEATURES}
 ])
index 7962832fad85df54e68b379399e2b072ee01b861..112b251cd5e84104112da9a8bc37aa90e6c97c4a 100644 (file)
@@ -185,3 +185,7 @@ Disable the TFTP protocol
 ## `CURL_DISABLE_VERBOSE_STRINGS`
 
 Disable verbose strings and error messages.
+
+## `CURL_DISABLE_WEBSOCKETS`
+
+Disable the WebSocket protocols.
index 7a9de9a810dae954fa321682d03ae4512467da89..e880942426e3890836f05acb96f12f96b92a0545 100644 (file)
@@ -57,15 +57,6 @@ Graduation requirements:
 
 - 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
index cfd2c2b767191477c7b47e7600ffdf7489e17c93..2b8eb9570752746144e0c5a4e5b3ee86560b80ee 100644 (file)
@@ -482,7 +482,7 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
 
       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 */
index 6e5fe4fcb2812996a911df9d167c14bb4e247c98..9c785f334e003a555a62326d719be8f7d2339d8d 100644 (file)
 /* 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
 
@@ -812,9 +815,6 @@ ${SIZEOF_TIME_T_CODE}
 /* 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
 
index 3c3e064d9124e6822e0708ba22fd4a0d6e881bbc..301926c6657857e6320dc0a3cfe3e977aeb86ffc 100644 (file)
@@ -239,7 +239,7 @@ void Curl_trc_smtp(struct Curl_easy *data, const char *fmt, ...)
 }
 #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,
@@ -255,7 +255,7 @@ void Curl_trc_ws(struct Curl_easy *data, const char *fmt, ...)
     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))
@@ -279,7 +279,7 @@ static struct trc_feat_def trc_feats[] = {
 #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
 };
index 1801d33cea7c1c8003d7f9569c2e7cda4f4ca171..32d2251d0242786c29642c3a272f54fb01eef998 100644 (file)
@@ -94,11 +94,11 @@ void Curl_failf(struct Curl_easy *data,
   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 */
 
@@ -113,7 +113,7 @@ void Curl_failf(struct Curl_easy *data,
 #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
 
@@ -169,7 +169,7 @@ extern struct curl_trc_feat Curl_trc_feat_smtp;
 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);
@@ -226,7 +226,7 @@ static void Curl_trc_smtp(struct Curl_easy *data, const char *fmt, ...)
   (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;
index c6c8aeb661b9de32dc58c49d8ba0bdfcf8561b50..95442a771b3d0b3bd5bbdb36d5c7d8cfcd1345c8 100644 (file)
@@ -1247,7 +1247,7 @@ CURLcode curl_easy_recv(struct Curl_easy *data, void *buffer, size_t buflen,
   return CURLE_OK;
 }
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 CURLcode Curl_connect_only_attach(struct Curl_easy *data)
 {
   CURLcode result;
@@ -1264,7 +1264,7 @@ CURLcode Curl_connect_only_attach(struct Curl_easy *data)
 
   return CURLE_OK;
 }
-#endif /* USE_WEBSOCKETS */
+#endif /* !CURL_DISABLE_WEBSOCKETS */
 
 /*
  * Sends data over the connected socket.
index d77bb98f920f337a4245c6ae0bed6d4dd2540b8d..181ce38f7bc18ee2464dbceb3bf8f6c9d7861bd3 100644 (file)
@@ -30,7 +30,7 @@
 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
 
index 0c8fdf15b459c92eeebaf221bd093354a2bb9933..706d2e08507e1f5492b0bae239838fec6426f14e 100644 (file)
@@ -2697,7 +2697,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
   }
 
   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
@@ -3449,7 +3449,7 @@ static CURLcode http_on_response(struct Curl_easy *data,
           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. */
@@ -3534,7 +3534,7 @@ static CURLcode http_on_response(struct Curl_easy *data,
   }
 #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);
index 5b96eb7a31eadbd560204deeeb9c438fc6f0aeb1..1242612bb0638abd518fb8bca381373588fab368 100644 (file)
@@ -3184,7 +3184,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
   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);
index cac8d71edb2e140df253d857c38047ab3e4a5a7c..8cebbcf15c7e7c8cb147d3e75979e868bf7b79f7 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1509,7 +1509,7 @@ const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme,
 #else
     NULL,
 #endif
-#if defined(USE_WEBSOCKETS) && \
+#if !defined(CURL_DISABLE_WEBSOCKETS) &&                \
   defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
     &Curl_handler_wss,
 #else
@@ -1578,7 +1578,7 @@ const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme,
     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,
@@ -2102,7 +2102,7 @@ static char *detect_proxy(struct Curl_easy *data,
   }
 
   if(!proxy) {
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
     /* websocket proxy fallbacks */
     if(strcasecompare("ws_proxy", proxy_env)) {
       proxy = curl_getenv("http_proxy");
@@ -2120,7 +2120,7 @@ static char *detect_proxy(struct Curl_easy *data,
         envp = (char *)"ALL_PROXY";
         proxy = curl_getenv(envp);
       }
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
     }
 #endif
   }
index 22dceeed85db3fe13cfbfe68e141dabc5565c35e..028ac0aff54f14e34ce32a44f67f4c757f0fd9e5 100644 (file)
@@ -64,7 +64,7 @@ struct curl_trc_featt;
 # 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
@@ -951,7 +951,7 @@ struct connectdata {
 #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 */
@@ -1844,7 +1844,7 @@ struct UserDefined {
   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
index 4f6d23dc136763a3f8d0587ce95d0e94bc9262d5..3f0f0ae5034a95785eeb308eaf526dd8077c928f 100644 (file)
@@ -384,11 +384,14 @@ static const char * const supported_protocols[] = {
 #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
index 802058647f7092315e9caf8619f49e4b3dd37566..8b58f1afc6496dc1ab8dbfe43b6b3af0ce819eeb 100644 (file)
--- a/lib/ws.c
+++ b/lib/ws.c
@@ -24,7 +24,7 @@
 #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"
@@ -930,9 +930,7 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
 {
   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 */
@@ -961,7 +959,9 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
   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);
@@ -984,7 +984,6 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
         ws_dec_info(&ws->dec, data, "need more input");
         continue;  /* nothing written, try more input */
       }
-      done = TRUE;
       break;
     }
     else if(result) {
@@ -994,7 +993,6 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
       /* 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;
     }
   }
@@ -1387,4 +1385,4 @@ CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(struct Curl_easy *data)
   (void)data;
   return NULL;
 }
-#endif /* USE_WEBSOCKETS */
+#endif /* !CURL_DISABLE_WEBSOCKETS */
index 398900cc3f5105a2a43b70f720df838f1d3171e0..186cc2c63a8241763af0506dcb3bae1499de4bc2 100644 (file)
--- a/lib/ws.h
+++ b/lib/ws.h
@@ -25,7 +25,7 @@
  ***************************************************************************/
 #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
index 47516adcbd478cf5d6ae5f43e0a3e86d3ad0ac78..bebf29d9fe542cecc9c4b41eeb0c872fa70a7df7 100644 (file)
@@ -70,8 +70,9 @@ static const struct detail scheme[] = {
   {"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 }
 };
index 120e2f84daff30daa83915052e3908ea17ec8a0c..6698326dfb8b6a78d9a82d2cc5aa4ff1f83044c8 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 
 #ifdef _WIN32
 #ifndef WIN32_LEAN_AND_MEAN
@@ -210,7 +210,7 @@ out:
 
 int main(int argc, char *argv[])
 {
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
   CURL *curl;
   CURLcode res = CURLE_OK;
   const char *url;
@@ -262,10 +262,10 @@ int main(int argc, char *argv[])
   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 */
 }
index 4b57e21e85a556b999ec897c2bd64087ce3fe420..efb01bcd711396ace2e39caacbf2f17a3c787d73 100644 (file)
@@ -42,7 +42,7 @@
 #include <sys/time.h>
 #endif
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 
 static CURLcode ping(CURL *curl, const char *send_payload)
 {
@@ -124,7 +124,7 @@ static CURLcode pingpong(CURL *curl, const char *payload)
 
 int main(int argc, char *argv[])
 {
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
   CURL *curl;
   CURLcode res = CURLE_OK;
   const char *url, *payload;
@@ -157,10 +157,10 @@ int main(int argc, char *argv[])
   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 */
 }
index 47558331735b8b7214353f0b609469c678a3274f..78bdb161b3490022b97f68000c3e755a04775af8 100644 (file)
@@ -274,7 +274,7 @@ static const struct testcase get_parts_list[] ={
   {"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]",
index bfac8305f31542a164822852c72afaa0da07b52a..15615145f2b6f5b091ff3882452de556fcd9b363 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "test.h"
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 #if 0
 
 static CURLcode send_ping(CURL *curl, const char *send_payload)
index 02d23352ff276ebb78269350645013343a07c7d4..415ab9ff1f134019f3209204740e25878313b468 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "test.h"
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 
 struct ws_data {
   CURL *easy;
index 0052bfdba815bea93af0704a7271b9140c870bf6..bc8a1f343628e41aa98ce1a444887ea99be66fca 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "test.h"
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 
 static CURLcode send_ping(CURL *curl, const char *send_payload)
 {
index b44771792b7041232732750edec8b38721f036bd..71ee19496a3a2459d4219399795411341674b862 100644 (file)
@@ -26,7 +26,7 @@
 #include "testtrace.h"
 #include "memdebug.h"
 
-#ifdef USE_WEBSOCKETS
+#ifndef CURL_DISABLE_WEBSOCKETS
 
 /* just close the connection */
 static void websocket_close(CURL *curl)
index 38f77184bbace55d27331595cd1c510aff047acd..6a3cd1e2238aa4f6c8613c0421ec162064279911 100644 (file)
@@ -141,8 +141,8 @@ SSL_CFLAGS   = $(SSL_CFLAGS) /DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
 !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