mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
lib: separate scheme info from protocol implementation
This allows builds know about all schemes - but only have the protocol implementations for those actually built-in. It further allows multiple protocols to reuse the same protocol setup and functions for both TLS and non-TLS implementations instead of needing two (or more) structs. The scheme information is now in 'struct Curl_scheme' and all the function pointers for each scheme/protocol implementation are in struct Curl_protocol. The URL API now always work with all known protocols. Closes #20351
This commit is contained in:
parent
63baa10951
commit
8edc0338f3
59 changed files with 831 additions and 1040 deletions
79
lib/ws.c
79
lib/ws.c
|
|
@ -22,10 +22,16 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)
|
||||
|
||||
#include "urldata.h"
|
||||
|
||||
#ifdef CURL_DISABLE_HTTP
|
||||
/* no WebSockets without HTTP present */
|
||||
#undef CURL_DISABLE_WEBSOCKETS
|
||||
#define CURL_DISABLE_WEBSOCKETS 1
|
||||
#endif
|
||||
|
||||
#ifndef CURL_DISABLE_WEBSOCKETS
|
||||
|
||||
#include "url.h"
|
||||
#include "bufq.h"
|
||||
#include "curlx/dynbuf.h"
|
||||
|
|
@ -1904,8 +1910,7 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
const struct Curl_handler Curl_handler_ws = {
|
||||
"WS", /* scheme */
|
||||
static const struct Curl_protocol Curl_protocol_ws = {
|
||||
ws_setup_conn, /* setup_connection */
|
||||
Curl_http, /* do_it */
|
||||
Curl_http_done, /* done */
|
||||
|
|
@ -1923,41 +1928,8 @@ const struct Curl_handler Curl_handler_ws = {
|
|||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
Curl_http_follow, /* follow */
|
||||
PORT_HTTP, /* defport */
|
||||
CURLPROTO_WS, /* protocol */
|
||||
CURLPROTO_HTTP, /* family */
|
||||
PROTOPT_CREDSPERREQUEST | /* flags */
|
||||
PROTOPT_USERPWDCTRL
|
||||
};
|
||||
|
||||
#ifdef USE_SSL
|
||||
const struct Curl_handler Curl_handler_wss = {
|
||||
"WSS", /* scheme */
|
||||
ws_setup_conn, /* setup_connection */
|
||||
Curl_http, /* do_it */
|
||||
Curl_http_done, /* done */
|
||||
ZERO_NULL, /* do_more */
|
||||
ZERO_NULL, /* connect_it */
|
||||
NULL, /* connecting */
|
||||
ZERO_NULL, /* doing */
|
||||
NULL, /* proto_pollset */
|
||||
Curl_http_doing_pollset, /* doing_pollset */
|
||||
ZERO_NULL, /* domore_pollset */
|
||||
Curl_http_perform_pollset, /* perform_pollset */
|
||||
ZERO_NULL, /* disconnect */
|
||||
Curl_http_write_resp, /* write_resp */
|
||||
Curl_http_write_resp_hd, /* write_resp_hd */
|
||||
ZERO_NULL, /* connection_check */
|
||||
ZERO_NULL, /* attach connection */
|
||||
Curl_http_follow, /* follow */
|
||||
PORT_HTTPS, /* defport */
|
||||
CURLPROTO_WSS, /* protocol */
|
||||
CURLPROTO_HTTP, /* family */
|
||||
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */
|
||||
PROTOPT_USERPWDCTRL
|
||||
};
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
|
|
@ -2002,4 +1974,33 @@ CURL_EXTERN CURLcode curl_ws_start_frame(CURL *curl,
|
|||
return CURLE_NOT_BUILT_IN;
|
||||
}
|
||||
|
||||
#endif /* !CURL_DISABLE_WEBSOCKETS && !CURL_DISABLE_HTTP */
|
||||
#endif /* !CURL_DISABLE_WEBSOCKETS */
|
||||
|
||||
const struct Curl_scheme Curl_scheme_ws = {
|
||||
"WS", /* scheme */
|
||||
#ifdef CURL_DISABLE_WEBSOCKETS
|
||||
ZERO_NULL,
|
||||
#else
|
||||
&Curl_protocol_ws,
|
||||
#endif
|
||||
CURLPROTO_WS, /* protocol */
|
||||
CURLPROTO_HTTP, /* family */
|
||||
PROTOPT_CREDSPERREQUEST | /* flags */
|
||||
PROTOPT_USERPWDCTRL,
|
||||
PORT_HTTP /* defport */
|
||||
}
|
||||
;
|
||||
|
||||
const struct Curl_scheme Curl_scheme_wss = {
|
||||
"WSS", /* scheme */
|
||||
#if defined(CURL_DISABLE_WEBSOCKETS) || !defined(USE_SSL)
|
||||
ZERO_NULL,
|
||||
#else
|
||||
&Curl_protocol_ws,
|
||||
#endif
|
||||
CURLPROTO_WSS, /* protocol */
|
||||
CURLPROTO_HTTP, /* family */
|
||||
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */
|
||||
PROTOPT_USERPWDCTRL,
|
||||
PORT_HTTPS /* defport */
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue