mirror of
https://github.com/curl/curl.git
synced 2025-04-24 16:40:32 +08:00
WebSockets: make support official (non-experimental)
Inverts the configure/cmake options to instead provide options that disable WebSockets and have them (ws + wss) enabled by default. Closes #14936
This commit is contained in:
parent
cfae354a9a
commit
d78e129d50
@ -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()
|
||||
|
70
configure.ac
70
configure.ac
@ -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}
|
||||
])
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -148,6 +148,9 @@
|
||||
/* 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
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
12
lib/ws.c
12
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 */
|
||||
|
2
lib/ws.h
2
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
|
||||
|
@ -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 }
|
||||
};
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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]",
|
||||
|
@ -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)
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#ifdef USE_WEBSOCKETS
|
||||
#ifndef CURL_DISABLE_WEBSOCKETS
|
||||
|
||||
struct ws_data {
|
||||
CURL *easy;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#ifdef USE_WEBSOCKETS
|
||||
#ifndef CURL_DISABLE_WEBSOCKETS
|
||||
|
||||
static CURLcode send_ping(CURL *curl, const char *send_payload)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user