cf-https-connect.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #if !defined(CURL_DISABLE_HTTP)
  26. #include "urldata.h"
  27. #include <curl/curl.h>
  28. #include "curl_trc.h"
  29. #include "cfilters.h"
  30. #include "connect.h"
  31. #include "multiif.h"
  32. #include "cf-https-connect.h"
  33. #include "http2.h"
  34. #include "vquic/vquic.h"
  35. /* The last 3 #include files should be in this order */
  36. #include "curl_printf.h"
  37. #include "curl_memory.h"
  38. #include "memdebug.h"
  39. typedef enum {
  40. CF_HC_INIT,
  41. CF_HC_CONNECT,
  42. CF_HC_SUCCESS,
  43. CF_HC_FAILURE
  44. } cf_hc_state;
  45. struct cf_hc_baller {
  46. const char *name;
  47. struct Curl_cfilter *cf;
  48. CURLcode result;
  49. struct curltime started;
  50. int reply_ms;
  51. BIT(enabled);
  52. BIT(shutdown);
  53. };
  54. static void cf_hc_baller_reset(struct cf_hc_baller *b,
  55. struct Curl_easy *data)
  56. {
  57. if(b->cf) {
  58. Curl_conn_cf_close(b->cf, data);
  59. Curl_conn_cf_discard_chain(&b->cf, data);
  60. b->cf = NULL;
  61. }
  62. b->result = CURLE_OK;
  63. b->reply_ms = -1;
  64. }
  65. static bool cf_hc_baller_is_active(struct cf_hc_baller *b)
  66. {
  67. return b->enabled && b->cf && !b->result;
  68. }
  69. static bool cf_hc_baller_has_started(struct cf_hc_baller *b)
  70. {
  71. return !!b->cf;
  72. }
  73. static int cf_hc_baller_reply_ms(struct cf_hc_baller *b,
  74. struct Curl_easy *data)
  75. {
  76. if(b->reply_ms < 0)
  77. b->cf->cft->query(b->cf, data, CF_QUERY_CONNECT_REPLY_MS,
  78. &b->reply_ms, NULL);
  79. return b->reply_ms;
  80. }
  81. static bool cf_hc_baller_data_pending(struct cf_hc_baller *b,
  82. const struct Curl_easy *data)
  83. {
  84. return b->cf && !b->result && b->cf->cft->has_data_pending(b->cf, data);
  85. }
  86. static bool cf_hc_baller_needs_flush(struct cf_hc_baller *b,
  87. struct Curl_easy *data)
  88. {
  89. return b->cf && !b->result && Curl_conn_cf_needs_flush(b->cf, data);
  90. }
  91. static CURLcode cf_hc_baller_cntrl(struct cf_hc_baller *b,
  92. struct Curl_easy *data,
  93. int event, int arg1, void *arg2)
  94. {
  95. if(b->cf && !b->result)
  96. return Curl_conn_cf_cntrl(b->cf, data, FALSE, event, arg1, arg2);
  97. return CURLE_OK;
  98. }
  99. struct cf_hc_ctx {
  100. cf_hc_state state;
  101. const struct Curl_dns_entry *remotehost;
  102. struct curltime started; /* when connect started */
  103. CURLcode result; /* overall result */
  104. struct cf_hc_baller h3_baller;
  105. struct cf_hc_baller h21_baller;
  106. unsigned int soft_eyeballs_timeout_ms;
  107. unsigned int hard_eyeballs_timeout_ms;
  108. };
  109. static void cf_hc_baller_init(struct cf_hc_baller *b,
  110. struct Curl_cfilter *cf,
  111. struct Curl_easy *data,
  112. const char *name,
  113. int transport)
  114. {
  115. struct cf_hc_ctx *ctx = cf->ctx;
  116. struct Curl_cfilter *save = cf->next;
  117. b->name = name;
  118. cf->next = NULL;
  119. b->started = Curl_now();
  120. b->result = Curl_cf_setup_insert_after(cf, data, ctx->remotehost,
  121. transport, CURL_CF_SSL_ENABLE);
  122. b->cf = cf->next;
  123. cf->next = save;
  124. }
  125. static CURLcode cf_hc_baller_connect(struct cf_hc_baller *b,
  126. struct Curl_cfilter *cf,
  127. struct Curl_easy *data,
  128. bool *done)
  129. {
  130. struct Curl_cfilter *save = cf->next;
  131. cf->next = b->cf;
  132. b->result = Curl_conn_cf_connect(cf->next, data, FALSE, done);
  133. b->cf = cf->next; /* it might mutate */
  134. cf->next = save;
  135. return b->result;
  136. }
  137. static void cf_hc_reset(struct Curl_cfilter *cf, struct Curl_easy *data)
  138. {
  139. struct cf_hc_ctx *ctx = cf->ctx;
  140. if(ctx) {
  141. cf_hc_baller_reset(&ctx->h3_baller, data);
  142. cf_hc_baller_reset(&ctx->h21_baller, data);
  143. ctx->state = CF_HC_INIT;
  144. ctx->result = CURLE_OK;
  145. ctx->hard_eyeballs_timeout_ms = data->set.happy_eyeballs_timeout;
  146. ctx->soft_eyeballs_timeout_ms = data->set.happy_eyeballs_timeout / 2;
  147. }
  148. }
  149. static CURLcode baller_connected(struct Curl_cfilter *cf,
  150. struct Curl_easy *data,
  151. struct cf_hc_baller *winner)
  152. {
  153. struct cf_hc_ctx *ctx = cf->ctx;
  154. CURLcode result = CURLE_OK;
  155. int reply_ms;
  156. DEBUGASSERT(winner->cf);
  157. if(winner != &ctx->h3_baller)
  158. cf_hc_baller_reset(&ctx->h3_baller, data);
  159. if(winner != &ctx->h21_baller)
  160. cf_hc_baller_reset(&ctx->h21_baller, data);
  161. reply_ms = cf_hc_baller_reply_ms(winner, data);
  162. if(reply_ms >= 0)
  163. CURL_TRC_CF(data, cf, "connect+handshake %s: %dms, 1st data: %dms",
  164. winner->name, (int)Curl_timediff(Curl_now(), winner->started),
  165. reply_ms);
  166. else
  167. CURL_TRC_CF(data, cf, "deferred handshake %s: %dms",
  168. winner->name, (int)Curl_timediff(Curl_now(), winner->started));
  169. cf->next = winner->cf;
  170. winner->cf = NULL;
  171. switch(cf->conn->alpn) {
  172. case CURL_HTTP_VERSION_3:
  173. break;
  174. case CURL_HTTP_VERSION_2:
  175. #ifdef USE_NGHTTP2
  176. /* Using nghttp2, we add the filter "below" us, so when the conn
  177. * closes, we tear it down for a fresh reconnect */
  178. result = Curl_http2_switch_at(cf, data);
  179. if(result) {
  180. ctx->state = CF_HC_FAILURE;
  181. ctx->result = result;
  182. return result;
  183. }
  184. #endif
  185. break;
  186. default:
  187. break;
  188. }
  189. ctx->state = CF_HC_SUCCESS;
  190. cf->connected = TRUE;
  191. return result;
  192. }
  193. static bool time_to_start_h21(struct Curl_cfilter *cf,
  194. struct Curl_easy *data,
  195. struct curltime now)
  196. {
  197. struct cf_hc_ctx *ctx = cf->ctx;
  198. timediff_t elapsed_ms;
  199. if(!ctx->h21_baller.enabled || cf_hc_baller_has_started(&ctx->h21_baller))
  200. return FALSE;
  201. if(!ctx->h3_baller.enabled || !cf_hc_baller_is_active(&ctx->h3_baller))
  202. return TRUE;
  203. elapsed_ms = Curl_timediff(now, ctx->started);
  204. if(elapsed_ms >= ctx->hard_eyeballs_timeout_ms) {
  205. CURL_TRC_CF(data, cf, "hard timeout of %dms reached, starting h21",
  206. ctx->hard_eyeballs_timeout_ms);
  207. return TRUE;
  208. }
  209. if(elapsed_ms >= ctx->soft_eyeballs_timeout_ms) {
  210. if(cf_hc_baller_reply_ms(&ctx->h3_baller, data) < 0) {
  211. CURL_TRC_CF(data, cf, "soft timeout of %dms reached, h3 has not "
  212. "seen any data, starting h21",
  213. ctx->soft_eyeballs_timeout_ms);
  214. return TRUE;
  215. }
  216. /* set the effective hard timeout again */
  217. Curl_expire(data, ctx->hard_eyeballs_timeout_ms - elapsed_ms,
  218. EXPIRE_ALPN_EYEBALLS);
  219. }
  220. return FALSE;
  221. }
  222. static CURLcode cf_hc_connect(struct Curl_cfilter *cf,
  223. struct Curl_easy *data,
  224. bool blocking, bool *done)
  225. {
  226. struct cf_hc_ctx *ctx = cf->ctx;
  227. struct curltime now;
  228. CURLcode result = CURLE_OK;
  229. (void)blocking;
  230. if(cf->connected) {
  231. *done = TRUE;
  232. return CURLE_OK;
  233. }
  234. *done = FALSE;
  235. now = Curl_now();
  236. switch(ctx->state) {
  237. case CF_HC_INIT:
  238. DEBUGASSERT(!ctx->h3_baller.cf);
  239. DEBUGASSERT(!ctx->h21_baller.cf);
  240. DEBUGASSERT(!cf->next);
  241. CURL_TRC_CF(data, cf, "connect, init");
  242. ctx->started = now;
  243. if(ctx->h3_baller.enabled) {
  244. cf_hc_baller_init(&ctx->h3_baller, cf, data, "h3", TRNSPRT_QUIC);
  245. if(ctx->h21_baller.enabled)
  246. Curl_expire(data, ctx->soft_eyeballs_timeout_ms, EXPIRE_ALPN_EYEBALLS);
  247. }
  248. else if(ctx->h21_baller.enabled)
  249. cf_hc_baller_init(&ctx->h21_baller, cf, data, "h21",
  250. cf->conn->transport);
  251. ctx->state = CF_HC_CONNECT;
  252. FALLTHROUGH();
  253. case CF_HC_CONNECT:
  254. if(cf_hc_baller_is_active(&ctx->h3_baller)) {
  255. result = cf_hc_baller_connect(&ctx->h3_baller, cf, data, done);
  256. if(!result && *done) {
  257. result = baller_connected(cf, data, &ctx->h3_baller);
  258. goto out;
  259. }
  260. }
  261. if(time_to_start_h21(cf, data, now)) {
  262. cf_hc_baller_init(&ctx->h21_baller, cf, data, "h21",
  263. cf->conn->transport);
  264. }
  265. if(cf_hc_baller_is_active(&ctx->h21_baller)) {
  266. CURL_TRC_CF(data, cf, "connect, check h21");
  267. result = cf_hc_baller_connect(&ctx->h21_baller, cf, data, done);
  268. if(!result && *done) {
  269. result = baller_connected(cf, data, &ctx->h21_baller);
  270. goto out;
  271. }
  272. }
  273. if((!ctx->h3_baller.enabled || ctx->h3_baller.result) &&
  274. (!ctx->h21_baller.enabled || ctx->h21_baller.result)) {
  275. /* both failed or disabled. we give up */
  276. CURL_TRC_CF(data, cf, "connect, all failed");
  277. result = ctx->result = ctx->h3_baller.enabled ?
  278. ctx->h3_baller.result : ctx->h21_baller.result;
  279. ctx->state = CF_HC_FAILURE;
  280. goto out;
  281. }
  282. result = CURLE_OK;
  283. *done = FALSE;
  284. break;
  285. case CF_HC_FAILURE:
  286. result = ctx->result;
  287. cf->connected = FALSE;
  288. *done = FALSE;
  289. break;
  290. case CF_HC_SUCCESS:
  291. result = CURLE_OK;
  292. cf->connected = TRUE;
  293. *done = TRUE;
  294. break;
  295. }
  296. out:
  297. CURL_TRC_CF(data, cf, "connect -> %d, done=%d", result, *done);
  298. return result;
  299. }
  300. static CURLcode cf_hc_shutdown(struct Curl_cfilter *cf,
  301. struct Curl_easy *data, bool *done)
  302. {
  303. struct cf_hc_ctx *ctx = cf->ctx;
  304. struct cf_hc_baller *ballers[2];
  305. size_t i;
  306. CURLcode result = CURLE_OK;
  307. DEBUGASSERT(data);
  308. if(cf->connected) {
  309. *done = TRUE;
  310. return CURLE_OK;
  311. }
  312. /* shutdown all ballers that have not done so already. If one fails,
  313. * continue shutting down others until all are shutdown. */
  314. ballers[0] = &ctx->h3_baller;
  315. ballers[1] = &ctx->h21_baller;
  316. for(i = 0; i < sizeof(ballers)/sizeof(ballers[0]); i++) {
  317. struct cf_hc_baller *b = ballers[i];
  318. bool bdone = FALSE;
  319. if(!cf_hc_baller_is_active(b) || b->shutdown)
  320. continue;
  321. b->result = b->cf->cft->do_shutdown(b->cf, data, &bdone);
  322. if(b->result || bdone)
  323. b->shutdown = TRUE; /* treat a failed shutdown as done */
  324. }
  325. *done = TRUE;
  326. for(i = 0; i < sizeof(ballers)/sizeof(ballers[0]); i++) {
  327. if(ballers[i] && !ballers[i]->shutdown)
  328. *done = FALSE;
  329. }
  330. if(*done) {
  331. for(i = 0; i < sizeof(ballers)/sizeof(ballers[0]); i++) {
  332. if(ballers[i] && ballers[i]->result)
  333. result = ballers[i]->result;
  334. }
  335. }
  336. CURL_TRC_CF(data, cf, "shutdown -> %d, done=%d", result, *done);
  337. return result;
  338. }
  339. static void cf_hc_adjust_pollset(struct Curl_cfilter *cf,
  340. struct Curl_easy *data,
  341. struct easy_pollset *ps)
  342. {
  343. if(!cf->connected) {
  344. struct cf_hc_ctx *ctx = cf->ctx;
  345. struct cf_hc_baller *ballers[2];
  346. size_t i;
  347. ballers[0] = &ctx->h3_baller;
  348. ballers[1] = &ctx->h21_baller;
  349. for(i = 0; i < sizeof(ballers)/sizeof(ballers[0]); i++) {
  350. struct cf_hc_baller *b = ballers[i];
  351. if(!cf_hc_baller_is_active(b))
  352. continue;
  353. Curl_conn_cf_adjust_pollset(b->cf, data, ps);
  354. }
  355. CURL_TRC_CF(data, cf, "adjust_pollset -> %d socks", ps->num);
  356. }
  357. }
  358. static bool cf_hc_data_pending(struct Curl_cfilter *cf,
  359. const struct Curl_easy *data)
  360. {
  361. struct cf_hc_ctx *ctx = cf->ctx;
  362. if(cf->connected)
  363. return cf->next->cft->has_data_pending(cf->next, data);
  364. CURL_TRC_CF((struct Curl_easy *)data, cf, "data_pending");
  365. return cf_hc_baller_data_pending(&ctx->h3_baller, data)
  366. || cf_hc_baller_data_pending(&ctx->h21_baller, data);
  367. }
  368. static struct curltime cf_get_max_baller_time(struct Curl_cfilter *cf,
  369. struct Curl_easy *data,
  370. int query)
  371. {
  372. struct cf_hc_ctx *ctx = cf->ctx;
  373. struct Curl_cfilter *cfb;
  374. struct curltime t, tmax;
  375. memset(&tmax, 0, sizeof(tmax));
  376. memset(&t, 0, sizeof(t));
  377. cfb = ctx->h21_baller.enabled ? ctx->h21_baller.cf : NULL;
  378. if(cfb && !cfb->cft->query(cfb, data, query, NULL, &t)) {
  379. if((t.tv_sec || t.tv_usec) && Curl_timediff_us(t, tmax) > 0)
  380. tmax = t;
  381. }
  382. memset(&t, 0, sizeof(t));
  383. cfb = ctx->h3_baller.enabled ? ctx->h3_baller.cf : NULL;
  384. if(cfb && !cfb->cft->query(cfb, data, query, NULL, &t)) {
  385. if((t.tv_sec || t.tv_usec) && Curl_timediff_us(t, tmax) > 0)
  386. tmax = t;
  387. }
  388. return tmax;
  389. }
  390. static CURLcode cf_hc_query(struct Curl_cfilter *cf,
  391. struct Curl_easy *data,
  392. int query, int *pres1, void *pres2)
  393. {
  394. struct cf_hc_ctx *ctx = cf->ctx;
  395. if(!cf->connected) {
  396. switch(query) {
  397. case CF_QUERY_TIMER_CONNECT: {
  398. struct curltime *when = pres2;
  399. *when = cf_get_max_baller_time(cf, data, CF_QUERY_TIMER_CONNECT);
  400. return CURLE_OK;
  401. }
  402. case CF_QUERY_TIMER_APPCONNECT: {
  403. struct curltime *when = pres2;
  404. *when = cf_get_max_baller_time(cf, data, CF_QUERY_TIMER_APPCONNECT);
  405. return CURLE_OK;
  406. }
  407. case CF_QUERY_NEED_FLUSH: {
  408. if(cf_hc_baller_needs_flush(&ctx->h3_baller, data)
  409. || cf_hc_baller_needs_flush(&ctx->h21_baller, data)) {
  410. *pres1 = TRUE;
  411. return CURLE_OK;
  412. }
  413. break;
  414. }
  415. default:
  416. break;
  417. }
  418. }
  419. return cf->next ?
  420. cf->next->cft->query(cf->next, data, query, pres1, pres2) :
  421. CURLE_UNKNOWN_OPTION;
  422. }
  423. static CURLcode cf_hc_cntrl(struct Curl_cfilter *cf,
  424. struct Curl_easy *data,
  425. int event, int arg1, void *arg2)
  426. {
  427. struct cf_hc_ctx *ctx = cf->ctx;
  428. CURLcode result = CURLE_OK;
  429. if(!cf->connected) {
  430. result = cf_hc_baller_cntrl(&ctx->h3_baller, data, event, arg1, arg2);
  431. if(!result || (result == CURLE_AGAIN))
  432. result = cf_hc_baller_cntrl(&ctx->h21_baller, data, event, arg1, arg2);
  433. if(result == CURLE_AGAIN)
  434. result = CURLE_OK;
  435. }
  436. return result;
  437. }
  438. static void cf_hc_close(struct Curl_cfilter *cf, struct Curl_easy *data)
  439. {
  440. CURL_TRC_CF(data, cf, "close");
  441. cf_hc_reset(cf, data);
  442. cf->connected = FALSE;
  443. if(cf->next) {
  444. cf->next->cft->do_close(cf->next, data);
  445. Curl_conn_cf_discard_chain(&cf->next, data);
  446. }
  447. }
  448. static void cf_hc_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
  449. {
  450. struct cf_hc_ctx *ctx = cf->ctx;
  451. (void)data;
  452. CURL_TRC_CF(data, cf, "destroy");
  453. cf_hc_reset(cf, data);
  454. Curl_safefree(ctx);
  455. }
  456. struct Curl_cftype Curl_cft_http_connect = {
  457. "HTTPS-CONNECT",
  458. 0,
  459. CURL_LOG_LVL_NONE,
  460. cf_hc_destroy,
  461. cf_hc_connect,
  462. cf_hc_close,
  463. cf_hc_shutdown,
  464. Curl_cf_def_get_host,
  465. cf_hc_adjust_pollset,
  466. cf_hc_data_pending,
  467. Curl_cf_def_send,
  468. Curl_cf_def_recv,
  469. cf_hc_cntrl,
  470. Curl_cf_def_conn_is_alive,
  471. Curl_cf_def_conn_keep_alive,
  472. cf_hc_query,
  473. };
  474. static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
  475. struct Curl_easy *data,
  476. const struct Curl_dns_entry *remotehost,
  477. bool try_h3, bool try_h21)
  478. {
  479. struct Curl_cfilter *cf = NULL;
  480. struct cf_hc_ctx *ctx;
  481. CURLcode result = CURLE_OK;
  482. (void)data;
  483. ctx = calloc(1, sizeof(*ctx));
  484. if(!ctx) {
  485. result = CURLE_OUT_OF_MEMORY;
  486. goto out;
  487. }
  488. ctx->remotehost = remotehost;
  489. ctx->h3_baller.enabled = try_h3;
  490. ctx->h21_baller.enabled = try_h21;
  491. result = Curl_cf_create(&cf, &Curl_cft_http_connect, ctx);
  492. if(result)
  493. goto out;
  494. ctx = NULL;
  495. cf_hc_reset(cf, data);
  496. out:
  497. *pcf = result ? NULL : cf;
  498. free(ctx);
  499. return result;
  500. }
  501. static CURLcode cf_http_connect_add(struct Curl_easy *data,
  502. struct connectdata *conn,
  503. int sockindex,
  504. const struct Curl_dns_entry *remotehost,
  505. bool try_h3, bool try_h21)
  506. {
  507. struct Curl_cfilter *cf;
  508. CURLcode result = CURLE_OK;
  509. DEBUGASSERT(data);
  510. result = cf_hc_create(&cf, data, remotehost, try_h3, try_h21);
  511. if(result)
  512. goto out;
  513. Curl_conn_cf_add(data, conn, sockindex, cf);
  514. out:
  515. return result;
  516. }
  517. CURLcode Curl_cf_https_setup(struct Curl_easy *data,
  518. struct connectdata *conn,
  519. int sockindex,
  520. const struct Curl_dns_entry *remotehost)
  521. {
  522. bool try_h3 = FALSE, try_h21 = TRUE; /* defaults, for now */
  523. CURLcode result = CURLE_OK;
  524. (void)sockindex;
  525. (void)remotehost;
  526. if(!conn->bits.tls_enable_alpn)
  527. goto out;
  528. if(data->state.httpwant == CURL_HTTP_VERSION_3ONLY) {
  529. result = Curl_conn_may_http3(data, conn);
  530. if(result) /* cannot do it */
  531. goto out;
  532. try_h3 = TRUE;
  533. try_h21 = FALSE;
  534. }
  535. else if(data->state.httpwant >= CURL_HTTP_VERSION_3) {
  536. /* We assume that silently not even trying H3 is ok here */
  537. /* TODO: should we fail instead? */
  538. try_h3 = (Curl_conn_may_http3(data, conn) == CURLE_OK);
  539. try_h21 = TRUE;
  540. }
  541. result = cf_http_connect_add(data, conn, sockindex, remotehost,
  542. try_h3, try_h21);
  543. out:
  544. return result;
  545. }
  546. #endif /* !defined(CURL_DISABLE_HTTP) */