master
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 "unitcheck.h"
25#include "urldata.h"
26#include "connect.h"
28static CURLcode t1303_setup(struct Curl_easy **easy)
29{
30 CURLcode result = CURLE_OK;
32 global_init(CURL_GLOBAL_ALL);
33 *easy = curl_easy_init();
34 if(!*easy) {
35 curl_global_cleanup();
36 return CURLE_OUT_OF_MEMORY;
37 }
38 return result;
39}
41static void t1303_stop(struct Curl_easy *easy)
42{
43 curl_easy_cleanup(easy);
44 curl_global_cleanup();
45}
47/* BASE is a define to make us fool around with decently large number so
48 that we are not zero-based */
49#define BASE 1000000
51/* macro to set the pretended current time */
52#define NOW(x, y) \
53 now.tv_sec = x; \
54 now.tv_usec = y
55/* macro to set the millisecond based timeouts to use */
56#define TIMEOUTS(x, y) \
57 easy->set.timeout = x; \
58 easy->set.connecttimeout = y
60/*
61 * To test:
62 *
63 * 00/10/01/11 timeouts set
64 * 0/1 during connect
65 * T various values on the timeouts
66 * N various values of now
67 */
69static CURLcode test_unit1303(const char *arg)
70{
71 struct Curl_easy *easy;
73 UNITTEST_BEGIN(t1303_setup(&easy))
75 struct curltime now;
76 unsigned int i;
78 struct timetest {
79 int now_s;
80 int now_us;
81 unsigned int timeout_ms;
82 unsigned int connecttimeout_ms;
83 bool connecting;
84 timediff_t result;
85 const char *comment;
86 };
88 static const struct timetest run[] = {
89 /* both timeouts set, not connecting */
90 {BASE + 4, 0, 10000, 8000, FALSE, 6000, "6 seconds should be left"},
91 {BASE + 4, 990000, 10000, 8000, FALSE, 5010, "5010 ms should be left"},
92 {BASE + 10, 0, 10000, 8000, FALSE, -1, "timeout is -1, expired"},
93 {BASE + 12, 0, 10000, 8000, FALSE, -2000, "-2000, overdue 2 seconds"},
95 /* both timeouts set, connecting */
96 {BASE + 4, 0, 10000, 8000, TRUE, 4000, "4 seconds should be left"},
97 {BASE + 4, 990000, 10000, 8000, TRUE, 3010, "3010 ms should be left"},
98 {BASE + 8, 0, 10000, 8000, TRUE, -1, "timeout is -1, expired"},
99 {BASE + 10, 0, 10000, 8000, TRUE, -2000, "-2000, overdue 2 seconds"},
101 /* no connect timeout set, not connecting */
102 {BASE + 4, 0, 10000, 0, FALSE, 6000, "6 seconds should be left"},
103 {BASE + 4, 990000, 10000, 0, FALSE, 5010, "5010 ms should be left"},
104 {BASE + 10, 0, 10000, 0, FALSE, -1, "timeout is -1, expired"},
105 {BASE + 12, 0, 10000, 0, FALSE, -2000, "-2000, overdue 2 seconds"},
107 /* no connect timeout set, connecting */
108 {BASE + 4, 0, 10000, 0, TRUE, 6000, "6 seconds should be left"},
109 {BASE + 4, 990000, 10000, 0, TRUE, 5010, "5010 ms should be left"},
110 {BASE + 10, 0, 10000, 0, TRUE, -1, "timeout is -1, expired"},
111 {BASE + 12, 0, 10000, 0, TRUE, -2000, "-2000, overdue 2 seconds"},
113 /* only connect timeout set, not connecting */
114 {BASE + 4, 0, 0, 10000, FALSE, 0, "no timeout active"},
115 {BASE + 4, 990000, 0, 10000, FALSE, 0, "no timeout active"},
116 {BASE + 10, 0, 0, 10000, FALSE, 0, "no timeout active"},
117 {BASE + 12, 0, 0, 10000, FALSE, 0, "no timeout active"},
119 /* only connect timeout set, connecting */
120 {BASE + 4, 0, 0, 10000, TRUE, 6000, "6 seconds should be left"},
121 {BASE + 4, 990000, 0, 10000, TRUE, 5010, "5010 ms should be left"},
122 {BASE + 10, 0, 0, 10000, TRUE, -1, "timeout is -1, expired"},
123 {BASE + 12, 0, 0, 10000, TRUE, -2000, "-2000, overdue 2 seconds"},
125 /* no timeout set, not connecting */
126 {BASE + 4, 0, 0, 0, FALSE, 0, "no timeout active"},
127 {BASE + 4, 990000, 0, 0, FALSE, 0, "no timeout active"},
128 {BASE + 10, 0, 0, 0, FALSE, 0, "no timeout active"},
129 {BASE + 12, 0, 0, 0, FALSE, 0, "no timeout active"},
131 /* no timeout set, connecting */
132 {BASE + 4, 0, 0, 0, TRUE, 296000, "no timeout active"},
133 {BASE + 4, 990000, 0, 0, TRUE, 295010, "no timeout active"},
134 {BASE + 10, 0, 0, 0, TRUE, 290000, "no timeout active"},
135 {BASE + 12, 0, 0, 0, TRUE, 288000, "no timeout active"},
137 /* both timeouts set, connecting, connect timeout the longer one */
138 {BASE + 4, 0, 10000, 12000, TRUE, 6000, "6 seconds should be left"},
139 };
141 /* this is the pretended start time of the transfer */
142 easy->progress.start.tv_sec = BASE;
143 easy->progress.start.tv_usec = 0;
144 easy->progress.delta.startsingle_us = 0;
145 easy->progress.delta.startop_us = 0;
147 for(i = 0; i < CURL_ARRAYSIZE(run); i++) {
148 timediff_t timeout;
149 NOW(run[i].now_s, run[i].now_us);
150 TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
151 easy->progress.now = now;
152 easy->mstate = run[i].connecting ? MSTATE_INIT : MSTATE_DO;
153 timeout = timeleft_now_ms(easy, &now);
154 if(timeout != run[i].result)
155 fail(run[i].comment);
156 }
158 UNITTEST_END(t1303_stop(easy))
159}
Diagnostics4 git calls · 910 ms
CallStatusSizeTime0910 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=86Open pack map
fetch2001.7 KiB905 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=905 git.response.bytes=1789 git.response.cache=MISS git.response.duration_ms=905 git.fetch.wants=acc31c39f179261a325c056513af1e6662f55bad 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=1789 git.pkt.payload.max=1768 git.sideband.band1.bytes=1767 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
- a5e1fd009a4aa9c0
- Request
- 0a78f00d…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format