Artifactspublic-v0

curl

master
ply4 git calls29 ms293 KiB3 cachedprotocol v2
810 lines22 KiBRaw
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"
26#ifndef CURL_DISABLE_HTTP
28#include "urldata.h"
29#include "curl_trc.h"
30#include "cfilters.h"
31#include "cf-setup.h"
32#include "connect.h"
33#include "multiif.h"
34#include "cf-https-connect.h"
35#include "http2.h"
36#include "progress.h"
37#include "select.h"
38#include "vdns/cf-dns.h"
39#include "vdns/hostip.h"
40#include "vdns/httpsrr.h"
41#include "vquic/vquic.h"
43typedef enum {
44 CF_HC_RESOLV,
45 CF_HC_INIT,
46 CF_HC_CONNECT,
47 CF_HC_SUCCESS,
48 CF_HC_FAILURE
49} cf_hc_state;
51struct cf_hc_baller {
52 const char *name;
53 struct Curl_cfilter *cf;
54 CURLcode result;
55 int reply_ms;
56 uint8_t transport;
57 enum alpnid alpn_id;
58 BIT(shutdown);
59};
61static void cf_hc_baller_discard(struct cf_hc_baller *b,
62 struct Curl_easy *data)
64 if(b->cf) {
65 Curl_conn_cf_discard_chain(&b->cf, data);
66 b->cf = NULL;
67 }
70static bool cf_hc_baller_is_connecting(struct cf_hc_baller *b)
72 return b->cf && !b->result;
75static bool cf_hc_baller_has_started(struct cf_hc_baller *b)
77 return !!b->cf;
80static int cf_hc_baller_reply_ms(struct cf_hc_baller *b,
81 struct Curl_easy *data)
83 if(b->cf && (b->reply_ms < 0))
84 b->cf->cft->query(b->cf, data, CF_QUERY_CONNECT_REPLY_MS,
85 &b->reply_ms, NULL);
86 return b->reply_ms;
89static bool cf_hc_baller_data_pending(struct cf_hc_baller *b,
90 const struct Curl_easy *data)
92 return b->cf && !b->result && b->cf->cft->has_data_pending(b->cf, data);
95static bool cf_hc_baller_needs_flush(struct cf_hc_baller *b,
96 struct Curl_easy *data)
98 return b->cf && !b->result && Curl_conn_cf_needs_flush(b->cf, data);
101static CURLcode cf_hc_baller_cntrl(struct cf_hc_baller *b,
102 struct Curl_easy *data,
103 int event, int arg1, void *arg2)
105 if(b->cf && !b->result)
106 return Curl_conn_cf_cntrl(b->cf, data, FALSE, event, arg1, arg2);
107 return CURLE_OK;
110struct cf_hc_ctx {
111 cf_hc_state state;
112 struct Curl_peer *destination; /* who we ultimately want to talk to */
113 struct curltime started; /* when connect started */
114 CURLcode result; /* overall result */
115 CURLcode check_h3_result;
116 struct cf_hc_baller ballers[2];
117 size_t baller_count;
118 timediff_t soft_eyeballs_timeout_ms;
119 timediff_t hard_eyeballs_timeout_ms;
120 uint8_t def_transport;
121 BIT(httpsrr_resolved);
122 BIT(checked_h3);
123 BIT(ballers_complete);
124};
126static void cf_hc_ctx_destroy(struct Curl_easy *data,
127 struct cf_hc_ctx *ctx)
129 if(ctx) {
130 size_t i;
131 for(i = 0; i < ctx->baller_count; ++i)
132 cf_hc_baller_discard(&ctx->ballers[i], data);
133 Curl_peer_unlink(&ctx->destination);
134 curlx_free(ctx);
135 }
138static void cf_hc_baller_assign(struct cf_hc_baller *b,
139 enum alpnid alpn_id,
140 uint8_t def_transport)
142 b->alpn_id = alpn_id;
143 b->transport = def_transport;
144 b->cf = NULL;
145 b->result = CURLE_OK;
146 b->reply_ms = -1;
147 b->shutdown = FALSE;
148 switch(b->alpn_id) {
149 case ALPN_h3:
150 b->name = "h3";
151 b->transport = TRNSPRT_QUIC;
152 break;
153 case ALPN_h2:
154 b->name = "h2";
155 break;
156 case ALPN_h1:
157 b->name = "h1";
158 break;
159 case ALPN_none:
160 b->name = "no-alpn";
161 break;
162 default:
163 b->result = CURLE_FAILED_INIT;
164 break;
165 }
168static void cf_hc_baller_init(struct cf_hc_baller *b,
169 struct Curl_cfilter *cf,
170 struct Curl_easy *data)
172 struct Curl_cfilter *save = cf->next;
174 cf->next = NULL;
175 b->result = Curl_cf_setup_insert_after(cf, data, b->transport,
176 CURL_CF_SSL_ENABLE);
177 b->cf = cf->next;
178 cf->next = save;
181static CURLcode cf_hc_baller_connect(struct cf_hc_baller *b,
182 struct Curl_cfilter *cf,
183 struct Curl_easy *data,
184 bool *done)
186 struct Curl_cfilter *save = cf->next;
188 cf->next = b->cf;
189 b->result = Curl_conn_cf_connect(cf->next, data, done);
190 b->cf = cf->next; /* it might mutate */
191 cf->next = save;
192 return b->result;
195static CURLcode baller_connected(struct Curl_cfilter *cf,
196 struct Curl_easy *data,
197 struct cf_hc_baller *winner)
199 struct cf_hc_ctx *ctx = cf->ctx;
201 /* Make the winner's connection filter out own sub-filter, check, move,
202 * close all remaining. */
203 if(cf->next) {
204 DEBUGASSERT(0);
205 return CURLE_FAILED_INIT;
206 }
207 if(!winner->cf) {
208 DEBUGASSERT(0);
209 return CURLE_FAILED_INIT;
210 }
212 cf->next = winner->cf;
213 winner->cf = NULL;
214 ctx->state = CF_HC_SUCCESS;
215 cf->connected = TRUE;
217 /* ballers may have failf()'d, the winner resets it, so our
218 * errorbuf is clean again. */
219 Curl_reset_fail(data);
220 return CURLE_OK;
223static bool time_to_start_baller2(struct Curl_cfilter *cf,
224 struct Curl_easy *data,
225 const struct curltime *pnow)
227 struct cf_hc_ctx *ctx = cf->ctx;
228 timediff_t elapsed_ms;
230 if(ctx->baller_count < 2)
231 return FALSE;
232 else if(cf_hc_baller_has_started(&ctx->ballers[1]))
233 return FALSE;
234 else if(ctx->ballers[0].result) {
235 CURL_TRC_CF(data, cf, "%s baller failed, starting %s",
236 ctx->ballers[0].name, ctx->ballers[1].name);
237 return TRUE;
238 }
240 elapsed_ms = curlx_ptimediff_ms(pnow, &ctx->started);
241 if(elapsed_ms >= ctx->hard_eyeballs_timeout_ms) {
242 CURL_TRC_CF(data, cf, "%s inconclusive after %" FMT_TIMEDIFF_T ", "
243 "starting %s", ctx->ballers[0].name,
244 ctx->hard_eyeballs_timeout_ms, ctx->ballers[1].name);
245 return TRUE;
246 }
247 else if(elapsed_ms >= ctx->soft_eyeballs_timeout_ms) {
248 if(cf_hc_baller_reply_ms(&ctx->ballers[0], data) < 0) {
249 CURL_TRC_CF(data, cf, "%s has not seen any data after %"
250 FMT_TIMEDIFF_T "ms, starting %s",
251 ctx->ballers[0].name, ctx->soft_eyeballs_timeout_ms,
252 ctx->ballers[1].name);
253 return TRUE;
254 }
255 /* set the effective hard timeout again */
256 Curl_expire_set(data, EXPIRE_ALPN_EYEBALLS,
257 ctx->hard_eyeballs_timeout_ms - elapsed_ms, pnow);
258 }
259 return FALSE;
262static bool cf_hc_may_h3(struct Curl_cfilter *cf,
263 struct Curl_easy *data)
265 struct cf_hc_ctx *ctx = cf->ctx;
266 if(!ctx->checked_h3) {
267 ctx->check_h3_result =
268 Curl_conn_may_http3(data, cf->conn);
269 ctx->checked_h3 = TRUE;
270 }
271 return !ctx->check_h3_result;
274static enum alpnid cf_hc_get_httpsrr_alpn(struct Curl_cfilter *cf,
275 struct Curl_easy *data,
276 enum alpnid not_this_one)
278#ifdef USE_HTTPSRR
279 struct cf_hc_ctx *ctx = cf->ctx;
280 /* Is there an HTTPSRR use its ALPNs here.
281 * We are here after having selected a connection to a host+port and
282 * can no longer change that. Any HTTPSRR advice for other hosts and ports
283 * we need to ignore. */
284 const struct Curl_https_rrinfo *rr;
285 size_t i;
287 /* Do we have HTTPS-RR information? */
288 rr = Curl_conn_dns_get_https(data, cf->sockindex, ctx->destination);
290 CURL_TRC_CF(data, cf, "HTTPS-RR %savailable", rr ? "" : "not ");
291 /* We do not support `rr->no_def_alpn`. */
292 if(Curl_httpsrr_applicable(data, rr) && !rr->no_def_alpn) {
293 for(i = 0; i < CURL_ARRAYSIZE(rr->alpns); ++i) {
294 enum alpnid alpn_rr = (enum alpnid)rr->alpns[i];
295 if(alpn_rr == not_this_one) /* do not want this one */
296 continue;
297 switch(alpn_rr) {
298 case ALPN_h3:
299 if((data->state.http_neg.allowed & CURL_HTTP_V3x) &&
300 cf_hc_may_h3(cf, data)) {
301 return alpn_rr;
302 }
303 break;
304 case ALPN_h2:
305 if(data->state.http_neg.allowed & CURL_HTTP_V2x) {
306 return alpn_rr;
307 }
308 break;
309 case ALPN_h1:
310 if(data->state.http_neg.allowed & CURL_HTTP_V1x) {
311 return alpn_rr;
312 }
313 break;
314 default: /* ignore */
315 break;
316 }
317 }
318 }
319#else
320 (void)cf;
321 (void)data;
322 (void)not_this_one;
323#endif
324 return ALPN_none;
327static enum alpnid cf_hc_get_pref_alpn(struct Curl_cfilter *cf,
328 struct Curl_easy *data,
329 enum alpnid not_this_one)
331 if((data->state.http_neg.preferred & data->state.http_neg.allowed)) {
332 switch(data->state.http_neg.preferred) {
333 case CURL_HTTP_V3x:
334 if(cf_hc_may_h3(cf, data) && (ALPN_h3 != not_this_one))
335 return ALPN_h3;
336 break;
337 case CURL_HTTP_V2x:
338 if(ALPN_h2 != not_this_one)
339 return ALPN_h2;
340 break;
341 case CURL_HTTP_V1x:
342 /* If we are trying h2 already, h1 is already used as fallback */
343 if((ALPN_h1 != not_this_one) && (ALPN_h2 != not_this_one))
344 return ALPN_h1;
345 break;
346 default:
347 break;
348 }
349 }
350 return ALPN_none;
353static enum alpnid cf_hc_get_first_alpn(struct Curl_cfilter *cf,
354 struct Curl_easy *data,
355 http_majors choices,
356 enum alpnid not_this_one)
358 /* When told to not try h2, we also do not try h1 and vice versa */
359 bool allow_h1_or_h2 = (not_this_one != ALPN_h1) &&
360 (not_this_one != ALPN_h2);
361 if((ALPN_h3 != not_this_one) && (choices & CURL_HTTP_V3x) &&
362 cf_hc_may_h3(cf, data)) {
363 return ALPN_h3;
364 }
365 if(allow_h1_or_h2 && (choices & CURL_HTTP_V2x)) {
366 return ALPN_h2;
367 }
368 if(allow_h1_or_h2 && (choices & CURL_HTTP_V1x)) {
369 return ALPN_h1;
370 }
371 return ALPN_none;
374static CURLcode cf_hc_set_baller1(struct Curl_cfilter *cf,
375 struct Curl_easy *data)
377 struct cf_hc_ctx *ctx = cf->ctx;
378 enum alpnid alpn1 = ALPN_none;
379 VERBOSE(const char *source = "HTTPS-RR");
381 DEBUGASSERT(cf->conn->bits.tls_enable_alpn);
383 alpn1 = cf_hc_get_httpsrr_alpn(cf, data, ALPN_none);
384 if(alpn1 == ALPN_none) {
385 /* preference is configured and allowed, can we use it? */
386 VERBOSE(source = "preferred version");
387 alpn1 = cf_hc_get_pref_alpn(cf, data, ALPN_none);
388 }
389 if(alpn1 == ALPN_none) {
390 VERBOSE(source = "wanted versions");
391 alpn1 = cf_hc_get_first_alpn(cf, data,
392 data->state.http_neg.wanted,
393 ALPN_none);
394 }
395 if(alpn1 == ALPN_none) {
396 VERBOSE(source = "allowed versions");
397 alpn1 = cf_hc_get_first_alpn(cf, data,
398 data->state.http_neg.allowed,
399 ALPN_none);
400 }
402 if(alpn1 == ALPN_none) {
403 /* None of the wanted/allowed HTTP versions could be chosen */
404 if(ctx->check_h3_result) {
405 CURL_TRC_CF(data, cf, "unable to use HTTP/3");
406 return ctx->check_h3_result;
407 }
408 CURL_TRC_CF(data, cf, "unable to select HTTP version");
409 return CURLE_FAILED_INIT;
410 }
412 cf_hc_baller_assign(&ctx->ballers[0], alpn1, ctx->def_transport);
413 ctx->baller_count = 1;
414 CURL_TRC_CF(data, cf, "1st attempt uses %s from %s",
415 ctx->ballers[0].name, source);
417 switch(alpn1) {
418 case ALPN_h1:
419 /* We really want h1, switch off h2 to make it disappear in ALPN */
420 data->state.http_neg.wanted &= (uint8_t)~CURL_HTTP_V2x;
421 break;
422 default:
423 break;
424 }
426 return CURLE_OK;
429static void cf_hc_set_baller2(struct Curl_cfilter *cf,
430 struct Curl_easy *data)
432 struct cf_hc_ctx *ctx = cf->ctx;
433 enum alpnid alpn2 = ALPN_none, alpn1 = ctx->ballers[0].alpn_id;
434 VERBOSE(const char *source = "HTTPS-RR");
436 if(ctx->ballers_complete)
437 return; /* already done */
438 if(!ctx->httpsrr_resolved)
439 return; /* HTTPS-RR pending */
441 alpn2 = cf_hc_get_httpsrr_alpn(cf, data, alpn1);
442 if(alpn2 == ALPN_none) {
443 /* preference is configured and allowed, can we use it? */
444 VERBOSE(source = "preferred version");
445 alpn2 = cf_hc_get_pref_alpn(cf, data, alpn1);
446 }
447 if(alpn2 == ALPN_none) {
448 VERBOSE(source = "wanted versions");
449 alpn2 = cf_hc_get_first_alpn(cf, data,
450 data->state.http_neg.wanted,
451 alpn1);
452 }
454 if(alpn2 != ALPN_none) {
455 cf_hc_baller_assign(&ctx->ballers[1], alpn2, ctx->def_transport);
456 ctx->baller_count = 2;
457 CURL_TRC_CF(data, cf, "2nd attempt uses %s from %s",
458 ctx->ballers[1].name, source);
459 }
460 ctx->ballers_complete = TRUE;
463static CURLcode cf_hc_connect(struct Curl_cfilter *cf,
464 struct Curl_easy *data,
465 bool *done)
467 struct cf_hc_ctx *ctx = cf->ctx;
468 CURLcode result = CURLE_OK;
469 const struct curltime *pnow = NULL;
471 if(cf->connected) {
472 *done = TRUE;
473 return CURLE_OK;
474 }
476 *done = FALSE;
478 if(!ctx->httpsrr_resolved) {
479 ctx->httpsrr_resolved = Curl_conn_dns_resolved_https(
480 data, cf->sockindex, ctx->destination);
481#ifdef DEBUGBUILD
482 if(!ctx->httpsrr_resolved && getenv("CURL_DBG_AWAIT_HTTPSRR")) {
483 CURL_TRC_CF(data, cf, "awaiting HTTPS-RR");
484 return CURLE_OK;
485 }
486#endif
487 }
489 switch(ctx->state) {
490 case CF_HC_RESOLV:
491 ctx->state = CF_HC_INIT;
492 FALLTHROUGH();
494 case CF_HC_INIT:
495 DEBUGASSERT(!cf->next);
496 CURL_TRC_CF(data, cf, "connect, init");
497 result = cf_hc_set_baller1(cf, data);
498 if(result) {
499 ctx->result = result;
500 ctx->state = CF_HC_FAILURE;
501 goto out;
502 }
503 cf_hc_set_baller2(cf, data);
504 pnow = Curl_pgrs_now(data);
505 ctx->started = *pnow;
506 cf_hc_baller_init(&ctx->ballers[0], cf, data);
507 if((ctx->baller_count > 1) || !ctx->ballers_complete) {
508 Curl_expire_set(data, EXPIRE_ALPN_EYEBALLS,
509 ctx->soft_eyeballs_timeout_ms, pnow);
510 }
511 ctx->state = CF_HC_CONNECT;
512 FALLTHROUGH();
514 case CF_HC_CONNECT:
515 if(!ctx->ballers_complete)
516 cf_hc_set_baller2(cf, data);
518 if(cf_hc_baller_is_connecting(&ctx->ballers[0])) {
519 result = cf_hc_baller_connect(&ctx->ballers[0], cf, data, done);
520 if(!result && *done) {
521 result = baller_connected(cf, data, &ctx->ballers[0]);
522 goto out;
523 }
524 }
526 pnow = Curl_pgrs_now(data);
527 if(time_to_start_baller2(cf, data, pnow)) {
528 cf_hc_baller_init(&ctx->ballers[1], cf, data);
529 }
531 if(cf_hc_baller_is_connecting(&ctx->ballers[1])) {
532 result = cf_hc_baller_connect(&ctx->ballers[1], cf, data, done);
533 if(!result && *done) {
534 result = baller_connected(cf, data, &ctx->ballers[1]);
535 goto out;
536 }
537 }
539 if(ctx->ballers[0].result &&
540 (ctx->ballers[1].result ||
541 (ctx->ballers_complete && (ctx->baller_count < 2)))) {
542 /* all have failed. we give up */
543 CURL_TRC_CF(data, cf, "connect, all attempts failed");
544 ctx->result = result = ctx->ballers[0].result;
545 ctx->state = CF_HC_FAILURE;
546 goto out;
547 }
548 result = CURLE_OK;
549 *done = FALSE;
550 break;
552 case CF_HC_FAILURE:
553 result = ctx->result;
554 cf->connected = FALSE;
555 *done = FALSE;
556 break;
558 case CF_HC_SUCCESS:
559 result = CURLE_OK;
560 cf->connected = TRUE;
561 *done = TRUE;
562 break;
563 }
565out:
566 CURL_TRC_CF(data, cf, "connect -> %d, done=%d", (int)result, *done);
567 return result;
570static CURLcode cf_hc_shutdown(struct Curl_cfilter *cf,
571 struct Curl_easy *data, bool *done)
573 struct cf_hc_ctx *ctx = cf->ctx;
574 size_t i;
575 CURLcode result = CURLE_OK;
577 DEBUGASSERT(data);
578 if(cf->connected) {
579 *done = TRUE;
580 return CURLE_OK;
581 }
583 /* shutdown all ballers that have not done so already. If one fails,
584 * continue shutting down others until all are shutdown. */
585 for(i = 0; i < ctx->baller_count; i++) {
586 struct cf_hc_baller *b = &ctx->ballers[i];
587 bool bdone = FALSE;
588 if(!cf_hc_baller_is_connecting(b) || b->shutdown)
589 continue;
590 b->result = b->cf->cft->do_shutdown(b->cf, data, &bdone);
591 if(b->result || bdone)
592 b->shutdown = TRUE; /* treat a failed shutdown as done */
593 }
595 *done = TRUE;
596 for(i = 0; i < ctx->baller_count; i++) {
597 if(!ctx->ballers[i].shutdown)
598 *done = FALSE;
599 }
600 if(*done) {
601 for(i = 0; i < ctx->baller_count; i++) {
602 if(ctx->ballers[i].result)
603 result = ctx->ballers[i].result;
604 }
605 }
606 CURL_TRC_CF(data, cf, "shutdown -> %d, done=%d", (int)result, *done);
607 return result;
610static CURLcode cf_hc_adjust_pollset(struct Curl_cfilter *cf,
611 struct Curl_easy *data,
612 struct easy_pollset *ps)
614 CURLcode result = CURLE_OK;
615 if(!cf->connected) {
616 struct cf_hc_ctx *ctx = cf->ctx;
617 size_t i;
619 for(i = 0; (i < ctx->baller_count) && !result; i++) {
620 struct cf_hc_baller *b = &ctx->ballers[i];
621 if(!cf_hc_baller_is_connecting(b))
622 continue;
623 result = Curl_conn_cf_adjust_pollset(b->cf, data, ps);
624 }
625 CURL_TRC_CF(data, cf, "adjust_pollset -> %d, %u socks", (int)result,
626 ps->n);
627 }
628 return result;
631static bool cf_hc_data_pending(struct Curl_cfilter *cf,
632 const struct Curl_easy *data)
634 struct cf_hc_ctx *ctx = cf->ctx;
635 size_t i;
637 if(cf->connected)
638 return cf->next->cft->has_data_pending(cf->next, data);
640 for(i = 0; i < ctx->baller_count; i++)
641 if(cf_hc_baller_data_pending(&ctx->ballers[i], data))
642 return TRUE;
643 return FALSE;
646static CURLcode cf_hc_query(struct Curl_cfilter *cf,
647 struct Curl_easy *data,
648 int query, int *pres1, void *pres2)
650 struct cf_hc_ctx *ctx = cf->ctx;
651 size_t i;
653 if(!cf->connected) {
654 switch(query) {
655 case CF_QUERY_NEED_FLUSH: {
656 for(i = 0; i < ctx->baller_count; i++)
657 if(cf_hc_baller_needs_flush(&ctx->ballers[i], data)) {
658 *pres1 = TRUE;
659 return CURLE_OK;
660 }
661 break;
662 }
663 default:
664 break;
665 }
666 }
667 return cf->next ?
668 cf->next->cft->query(cf->next, data, query, pres1, pres2) :
669 CURLE_UNKNOWN_OPTION;
672static CURLcode cf_hc_cntrl(struct Curl_cfilter *cf,
673 struct Curl_easy *data,
674 int event, int arg1, void *arg2)
676 struct cf_hc_ctx *ctx = cf->ctx;
677 CURLcode result = CURLE_OK;
678 size_t i;
680 if(!cf->connected) {
681 switch(event) {
682 case CF_CTRL_REPORT_STATS:
683 case CF_CTRL_CONN_INFO_UPDATE:
684 for(i = 0; i < ctx->baller_count; i++) {
685 /* Make the first baller that connected at network level report */
686 if(Curl_conn_cf_is_ip_connected(ctx->ballers[i].cf, data)) {
687 Curl_conn_cf_cntrl(ctx->ballers[i].cf, data, TRUE,
688 event, arg1, arg2);
689 break;
690 }
691 }
692 break;
693 default:
694 for(i = 0; i < ctx->baller_count; i++) {
695 result = cf_hc_baller_cntrl(&ctx->ballers[i], data, event, arg1, arg2);
696 if(result && (result != CURLE_AGAIN))
697 goto out;
698 }
699 result = CURLE_OK;
700 break;
701 }
702 }
703out:
704 return result;
707static void cf_hc_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
709 struct cf_hc_ctx *ctx = cf->ctx;
711 CURL_TRC_CF(data, cf, "destroy");
712 cf_hc_ctx_destroy(data, ctx);
715struct Curl_cftype Curl_cft_http_connect = {
716 "HTTPS-CONNECT",
717 CF_TYPE_SETUP,
718 CURL_LOG_LVL_NONE,
719 cf_hc_destroy,
720 cf_hc_connect,
721 cf_hc_shutdown,
722 cf_hc_adjust_pollset,
723 cf_hc_data_pending,
724 Curl_cf_def_send,
725 Curl_cf_def_recv,
726 cf_hc_cntrl,
727 Curl_cf_def_conn_is_alive,
728 Curl_cf_def_conn_keep_alive,
729 cf_hc_query,
730};
732static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
733 struct Curl_easy *data,
734 struct Curl_peer *destination,
735 uint8_t def_transport)
737 struct Curl_cfilter *cf = NULL;
738 struct cf_hc_ctx *ctx;
739 CURLcode result = CURLE_OK;
741 ctx = curlx_calloc(1, sizeof(*ctx));
742 if(!ctx) {
743 result = CURLE_OUT_OF_MEMORY;
744 goto out;
745 }
746 Curl_peer_link(&ctx->destination, destination);
747 ctx->def_transport = def_transport;
748 ctx->hard_eyeballs_timeout_ms = data->set.happy_eyeballs_timeout;
749 ctx->soft_eyeballs_timeout_ms = data->set.happy_eyeballs_timeout / 2;
751 result = Curl_cf_create(&cf, &Curl_cft_http_connect, ctx);
752 if(result)
753 goto out;
754 ctx = NULL;
756out:
757 *pcf = result ? NULL : cf;
758 cf_hc_ctx_destroy(data, ctx);
759 return result;
762static CURLcode cf_hc_add(struct Curl_easy *data,
763 struct Curl_peer *destination,
764 struct connectdata *conn,
765 int8_t sockindex,
766 uint8_t def_transport)
768 struct Curl_cfilter *cf;
769 CURLcode result = CURLE_OK;
771 DEBUGASSERT(data);
772 result = cf_hc_create(&cf, data, destination, def_transport);
773 if(result)
774 goto out;
775 Curl_conn_cf_add(data, conn, sockindex, cf);
777#ifdef USE_HTTPSRR
778 result = Curl_conn_dns_add_https_resolve(data, cf->conn, cf->sockindex,
779 destination);
780#endif
781out:
782 return result;
785CURLcode Curl_cf_https_setup(struct Curl_easy *data,
786 struct Curl_peer *destination,
787 struct connectdata *conn,
788 int8_t sockindex)
790 CURLcode result = CURLE_OK;
792 DEBUGASSERT(conn->scheme->protocol == CURLPROTO_HTTPS);
794 /* This filter is intended for HTTPS using ALPN and does
795 * not support HTTPS Eyeballing to a proxy. */
796 if((conn->scheme->protocol != CURLPROTO_HTTPS) ||
797#ifndef CURL_DISABLE_PROXY
798 conn->bits.origin_is_proxy ||
799#endif
800 !conn->bits.tls_enable_alpn)
801 goto out;
803 result = cf_hc_add(data, destination, conn, sockindex,
804 conn->transport_wanted);
806out:
807 return result;
810#endif /* !CURL_DISABLE_HTTP */
Diagnostics4 git calls · 29 ms
CallStatusSizeTime029 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2006.1 KiB · hit24 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=24
git.response.bytes=6208
git.response.cache=HIT
git.response.duration_ms=24
git.fetch.wants=9a51d6dd44f91fe32c667b268bc22e402c28861b
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=6208
git.pkt.payload.max=6187
git.sideband.band1.bytes=6186
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e1404c9fee0bf5
Request
2b932e63…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format