Artifactspublic-v0

curl

master
ply4 git calls159 ms298 KiB2 cachedprotocol v2
1312 lines50 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.
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.
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
21# SPDX-License-Identifier: curl
23###########################################################################
25import contextlib
26import json
27import logging
28import os
29import re
30import shutil
31import subprocess
32import sys
33import time
34from datetime import datetime, timedelta, timezone
35from functools import cmp_to_key
36from statistics import fmean, mean
37from threading import Thread
38from typing import Any, ClassVar, Dict, List, Optional, Tuple, Union
39from urllib.parse import urlparse
41import psutil
43from .env import Env, EnvError
45log = logging.getLogger(__name__)
48class RunProfile:
50 STAT_KEYS: ClassVar[List[str]] = ['cpu', 'rss', 'vsz']
52 @classmethod
53 def AverageStats(cls, profiles: List['RunProfile']):
54 avg = {}
55 stats = [p.stats for p in profiles]
56 for key in cls.STAT_KEYS:
57 vals = [s[key] for s in stats]
58 avg[key] = mean(vals) if vals else 0.0
59 vals = [s['rss-max'] for s in [p.stats for p in profiles]]
60 avg['rss-max'] = mean(vals) if vals else 0
61 return avg
63 def __init__(self, pid: int, started_at: datetime, run_dir):
64 self._pid = pid
65 self._started_at = started_at
66 self._duration = timedelta(seconds=0)
67 self._run_dir = run_dir
68 self._samples = []
69 self._psu = None
70 self._stats = None
72 @property
73 def duration(self) -> timedelta:
74 return self._duration
76 @property
77 def stats(self) -> Optional[Dict[str, Any]]:
78 return self._stats
80 def sample(self):
81 elapsed = datetime.now(timezone.utc) - self._started_at
82 try:
83 if self._psu is None:
84 self._psu = psutil.Process(pid=self._pid)
85 mem = self._psu.memory_info()
86 self._samples.append({
87 'time': elapsed,
88 'cpu': self._psu.cpu_percent(),
89 'vsz': mem.vms,
90 'rss': mem.rss,
91 })
92 except psutil.NoSuchProcess:
93 # process may exit between sampling ticks: ignore this
94 pass
96 def finish(self):
97 self._duration = datetime.now(timezone.utc) - self._started_at
98 if len(self._samples) > 0:
99 weights = [s['time'].total_seconds() for s in self._samples]
100 self._stats = {}
101 for key in self.STAT_KEYS:
102 self._stats[key] = fmean([s[key] for s in self._samples], weights)
103 self._stats['rss-max'] = max(s['rss'] for s in self._samples)
104 else:
105 self._stats = None
106 self._psu = None
108 def __repr__(self):
109 return f'RunProfile[pid={self._pid}, '\
110 f'duration={self.duration.total_seconds():.3f}s, '\
111 f'stats={self.stats}]'
114class PerfProfile:
116 def __init__(self, pid: int, run_dir):
117 self._pid = pid
118 self._run_dir = run_dir
119 self._proc = None
120 self._rc = 0
121 self._file = os.path.join(self._run_dir, 'curl.perf_stacks')
123 def start(self):
124 if os.path.exists(self._file):
125 os.remove(self._file)
126 args = [
127 'sudo', 'perf', 'record', '-F', '99', '-p', f'{self._pid}',
128 '-g', '--', 'sleep', '60'
129 ]
130 self._proc = subprocess.Popen(args, text=True, cwd=self._run_dir, shell=False)
131 assert self._proc
133 def finish(self):
134 if self._proc:
135 self._proc.terminate()
136 self._rc = self._proc.returncode
137 with open(self._file, 'w') as cout:
138 subprocess.run(['sudo', 'perf', 'script'],
139 stdout=cout, cwd=self._run_dir, shell=False, check=True)
141 @property
142 def file(self):
143 return self._file
146class DTraceProfile:
148 def __init__(self, pid: int, run_dir):
149 self._pid = pid
150 self._run_dir = run_dir
151 self._proc = None
152 self._rc = 0
153 self._file = os.path.join(self._run_dir, 'curl.dtrace_stacks')
155 def start(self):
156 if os.path.exists(self._file):
157 os.remove(self._file)
158 args = [
159 'sudo', 'dtrace',
160 '-x', 'ustackframes=100',
161 '-n', f'profile-97 /pid == {self._pid}/ {{ @[ustack()] = count(); }} tick-60s {{ exit(0); }}',
162 '-o', f'{self._file}'
163 ]
164 if sys.platform.startswith('darwin'):
165 # macOS seems to like this for producing symbols in user stacks
166 args.extend(['-p', f'{self._pid}'])
167 self._proc = subprocess.Popen(args, text=True, cwd=self._run_dir, shell=False)
168 assert self._proc
170 def finish(self):
171 if self._proc:
172 self._proc.terminate()
173 self._rc = self._proc.returncode
175 @property
176 def file(self):
177 return self._file
180class RunTcpDump:
182 def __init__(self, env, run_dir):
183 self._env = env
184 self._run_dir = run_dir
185 self._proc = None
186 self._stdoutfile = os.path.join(self._run_dir, 'tcpdump.out')
187 self._stderrfile = os.path.join(self._run_dir, 'tcpdump.err')
189 def get_rsts(self, ports: Optional[List[int]] = None,
190 port_pairs: Optional[List[Tuple[int, int]]] = None
191 ) -> Optional[List[str]]:
192 if self._proc:
193 raise EnvError('tcpdump still running')
194 # a pair matches only a RST between exactly these two ports, while
195 # a port in `ports` matches any RST it is involved in
196 pairs = None
197 if port_pairs is not None:
198 pairs = set()
199 for p1, p2 in port_pairs:
200 pairs.add((p1, p2))
201 pairs.add((p2, p1))
202 lines = []
203 with open(self._stdoutfile) as fd:
204 for line in fd:
205 m = re.match(r'.* IP 127\.0\.0\.1\.(\d+) [<>] 127\.0\.0\.1\.(\d+):.*', line)
206 if m:
207 sport = int(m.group(1))
208 dport = int(m.group(2))
209 if pairs is not None:
210 if (sport, dport) in pairs:
211 lines.append(line)
212 elif ports is None or sport in ports or dport in ports:
213 lines.append(line)
214 return lines
216 @property
217 def stats(self) -> Optional[List[str]]:
218 return self.get_rsts()
220 @property
221 def stderr(self) -> List[str]:
222 if self._proc:
223 raise EnvError('tcpdump still running')
224 with open(self._stderrfile) as fd:
225 return fd.readlines()
227 def sample(self):
228 # not sure how to make that detection reliable for all platforms
229 local_if = 'lo0' if sys.platform.startswith('darwin') else 'lo'
230 try:
231 tcpdump = self._env.tcpdump()
232 if tcpdump is None:
233 raise EnvError('tcpdump not available')
234 # look with tcpdump for TCP RST packets which indicate
235 # we did not shut down connections cleanly
236 args = []
237 # at least on Linux, we need root permissions to run tcpdump
238 if sys.platform.startswith('linux'):
239 args.append('sudo')
240 args.extend([
241 tcpdump, '-i', local_if, '-n', 'tcp[tcpflags] & (tcp-rst)!=0'
242 ])
243 with open(self._stdoutfile, 'w') as cout, open(self._stderrfile, 'w') as cerr:
244 self._proc = subprocess.Popen(args, stdout=cout, stderr=cerr,
245 text=True, cwd=self._run_dir,
246 shell=False)
247 assert self._proc
248 assert self._proc.returncode is None
249 while self._proc:
250 # timeout means tcpdump is still running
251 with contextlib.suppress(subprocess.TimeoutExpired):
252 self._proc.wait(timeout=1)
253 except Exception:
254 log.exception('Tcpdump')
256 def start(self):
257 def do_sample():
258 self.sample()
259 t = Thread(target=do_sample)
260 t.start()
262 def finish(self):
263 if self._proc:
264 time.sleep(1)
265 self._proc.terminate()
266 self._proc = None
269class ExecResult:
271 def __init__(self, args: List[str], exit_code: int,
272 stdout: List[str], stderr: List[str],
273 duration: Optional[timedelta] = None,
274 with_stats: bool = False,
275 exception: Optional[str] = None,
276 profile: Optional[RunProfile] = None,
277 tcpdump: Optional[RunTcpDump] = None):
278 self._args = args
279 self._exit_code = exit_code
280 self._exception = exception
281 self._stdout = stdout
282 self._stderr = stderr
283 self._profile = profile
284 self._tcpdump = tcpdump
285 self._duration = duration if duration is not None else timedelta()
286 self._response = None
287 self._responses = []
288 self._results = {}
289 self._assets = []
290 self._stats = []
291 self._json_out = None
292 self._with_stats = with_stats
293 if with_stats:
294 self._parse_stats()
295 else:
296 try:
297 out = ''.join(self._stdout)
298 self._json_out = json.loads(out)
299 except (json.JSONDecodeError, TypeError, ValueError):
300 # stdout not guaranteed to be JSON, keep _json_out as None
301 pass
303 def __repr__(self):
304 return f"ExecResult[code={self.exit_code}, exception={self._exception}, "\
305 f"args={self._args}, stdout={self._stdout}, stderr={self._stderr}]"
307 def _parse_stats(self):
308 self._stats = []
309 for line in self._stdout:
310 try:
311 self._stats.append(json.loads(line))
312 except (json.JSONDecodeError, TypeError, ValueError):
313 log.exception(f'not a JSON stat: {line}')
314 break
316 @property
317 def exit_code(self) -> int:
318 return self._exit_code
320 @property
321 def args(self) -> List[str]:
322 return self._args
324 @property
325 def outraw(self) -> bytes:
326 return ''.join(self._stdout).encode()
328 @property
329 def stdout(self) -> str:
330 return ''.join(self._stdout)
332 @property
333 def json(self) -> Optional[Dict]:
334 """Output as JSON dictionary or None if not parseable."""
335 return self._json_out
337 @property
338 def stderr(self) -> str:
339 return ''.join(self._stderr)
341 @property
342 def trace_lines(self) -> List[str]:
343 return self._stderr
345 @property
346 def duration(self) -> timedelta:
347 return self._duration
349 @property
350 def profile(self) -> Optional[RunProfile]:
351 return self._profile
353 @property
354 def tcpdump(self) -> Optional[RunTcpDump]:
355 return self._tcpdump
357 @property
358 def response(self) -> Optional[Dict]:
359 return self._response
361 @property
362 def responses(self) -> List[Dict]:
363 return self._responses
365 @property
366 def results(self) -> Dict:
367 return self._results
369 @property
370 def assets(self) -> List:
371 return self._assets
373 @property
374 def with_stats(self) -> bool:
375 return self._with_stats
377 @property
378 def stats(self) -> List:
379 return self._stats
381 def set_stats(self, stats):
382 self._stats = stats
384 @property
385 def total_connects(self) -> Optional[int]:
386 if self.stats:
387 n = 0
388 for stat in self.stats:
389 n += stat['num_connects']
390 return n
391 return None
393 def add_response(self, resp: Dict):
394 self._response = resp
395 self._responses.append(resp)
397 def add_results(self, results: Dict):
398 self._results.update(results)
399 if 'response' in results:
400 self.add_response(results['response'])
402 def add_assets(self, assets: List):
403 self._assets.extend(assets)
405 def check_exit_code(self, code: Union[int, bool]):
406 if code is True:
407 assert self.exit_code == 0, f'expected exit code {code}, '\
408 f'got {self.exit_code}\n{self.dump_logs()}'
409 elif code is False:
410 assert self.exit_code != 0, f'expected exit code {code}, '\
411 f'got {self.exit_code}\n{self.dump_logs()}'
412 else:
413 assert self.exit_code == code, f'expected exit code {code}, '\
414 f'got {self.exit_code}\n{self.dump_logs()}'
416 def check_response(self, http_status: Optional[int] = 200,
417 count: Optional[int] = 1,
418 protocol: Optional[str] = None,
419 exitcode: Optional[int] = 0,
420 connect_count: Optional[int] = None):
421 if exitcode:
422 self.check_exit_code(exitcode)
423 if self.with_stats and isinstance(exitcode, int):
424 for idx, x in enumerate(self.stats):
425 if 'exitcode' in x:
426 assert int(x['exitcode']) == exitcode, \
427 f'response #{idx} exitcode: expected {exitcode}, '\
428 f'got {x["exitcode"]}\n{self.dump_logs()}'
430 if self.with_stats:
431 assert len(self.stats) == count, \
432 f'response count: expected {count}, ' \
433 f'got {len(self.stats)}\n{self.dump_logs()}'
434 else:
435 assert len(self.responses) == count, \
436 f'response count: expected {count}, ' \
437 f'got {len(self.responses)}\n{self.dump_logs()}'
438 if http_status is not None:
439 if self.with_stats:
440 for idx, x in enumerate(self.stats):
441 assert 'http_code' in x, \
442 f'response #{idx} reports no http_code\n{self.dump_stat(x)}'
443 assert x['http_code'] == http_status, \
444 f'response #{idx} http_code: expected {http_status}, '\
445 f'got {x["http_code"]}\n{self.dump_stat(x)}'
446 else:
447 for idx, x in enumerate(self.responses):
448 assert x['status'] == http_status, \
449 f'response #{idx} status: expected {http_status},'\
450 f'got {x["status"]}\n{self.dump_stat(x)}'
451 if protocol is not None:
452 if self.with_stats:
453 http_version = None
454 if protocol == 'HTTP/1.1':
455 http_version = '1.1'
456 elif protocol == 'HTTP/2':
457 http_version = '2'
458 elif protocol == 'HTTP/3':
459 http_version = '3'
460 if http_version is not None:
461 for idx, x in enumerate(self.stats):
462 assert x['http_version'] == http_version, \
463 f'response #{idx} protocol: expected http/{http_version},' \
464 f'got version {x["http_version"]}\n{self.dump_stat(x)}'
465 else:
466 for idx, x in enumerate(self.responses):
467 assert x['protocol'] == protocol, \
468 f'response #{idx} protocol: expected {protocol},'\
469 f'got {x["protocol"]}\n{self.dump_logs()}'
470 if connect_count is not None:
471 assert self.total_connects == connect_count, \
472 f'expected {connect_count}, but {self.total_connects} '\
473 f'were made\n{self.dump_logs()}'
475 def check_stats(self, count: int, http_status: Optional[int] = None,
476 exitcode: Optional[Union[int, List[int]]] = None,
477 remote_port: Optional[int] = None,
478 remote_ip: Optional[str] = None):
479 if exitcode is None:
480 self.check_exit_code(0)
481 elif isinstance(exitcode, int):
482 exitcode = [exitcode]
483 assert len(self.stats) == count, \
484 f'stats count: expected {count}, got {len(self.stats)}\n{self.dump_logs()}'
485 if http_status is not None:
486 for idx, x in enumerate(self.stats):
487 assert 'http_code' in x, \
488 f'status #{idx} reports no http_code\n{self.dump_stat(x)}'
489 assert x['http_code'] == http_status, \
490 f'status #{idx} http_code: expected {http_status}, '\
491 f'got {x["http_code"]}\n{self.dump_stat(x)}'
492 if exitcode is not None:
493 for idx, x in enumerate(self.stats):
494 if 'exitcode' in x:
495 assert x['exitcode'] in exitcode, \
496 f'status #{idx} exitcode: expected {exitcode}, '\
497 f'got {x["exitcode"]}\n{self.dump_stat(x)}'
498 if remote_port is not None:
499 for idx, x in enumerate(self.stats):
500 assert 'remote_port' in x, f'remote_port missing\n{self.dump_stat(x)}'
501 assert x['remote_port'] == remote_port, \
502 f'status #{idx} remote_port: expected {remote_port}, '\
503 f'got {x["remote_port"]}\n{self.dump_stat(x)}'
504 if remote_ip is not None:
505 for idx, x in enumerate(self.stats):
506 assert 'remote_ip' in x, f'remote_ip missing\n{self.dump_stat(x)}'
507 assert x['remote_ip'] == remote_ip, \
508 f'status #{idx} remote_ip: expected {remote_ip}, '\
509 f'got {x["remote_ip"]}\n{self.dump_stat(x)}'
511 def check_stat_positive(self, s, idx, key):
512 assert key in s, f'stat #{idx} "{key}" missing: {s}'
513 assert s[key] > 0, f'stat #{idx} "{key}" not positive: {s}'
515 def check_stat_positive_or_0(self, s, idx, key):
516 assert key in s, f'stat #{idx} "{key}" missing: {s}'
517 assert s[key] >= 0, f'stat #{idx} "{key}" not positive: {s}'
519 def check_stat_zero(self, s, key):
520 assert key in s, f'stat "{key}" missing: {s}'
521 assert s[key] == 0, f'stat "{key}" not zero: {s}'
523 def check_stats_timelines(self):
524 for i in range(len(self._stats)):
525 self.check_stats_timeline(i)
527 def check_stats_timeline(self, idx):
528 # check timings reported on a transfer for consistency
529 s = self._stats[idx]
531 url = s['url_effective']
533 self.check_stat_positive_or_0(s, idx, 'time_connect')
534 # all stat keys which reporting timings
535 all_keys = {
536 'time_queue', 'time_namelookup',
537 'time_connect', 'time_appconnect',
538 'time_pretransfer', 'time_posttransfer',
539 'time_starttransfer', 'time_total',
540 }
541 # stat keys where we expect a positive value
542 ref_tl = []
543 # time_queue has its own start timestamp. Other timers start *after*
544 # queueing is done. queue duration might therefore be anywhere.
545 somewhere_keys = ['time_queue']
546 exact_match = True
547 # redirects mess up the times, some are accumulative
548 if s['time_redirect']:
549 exact_match = False
550 # connect events?
551 if url.startswith('ftp'):
552 # ftp is messy with connect events for its DATA connection
553 exact_match = False
554 elif s['num_connects'] > 0:
555 ref_tl += ['time_namelookup', 'time_connect']
556 if url.startswith('https:'):
557 ref_tl += ['time_appconnect']
558 ref_tl += ['time_pretransfer', 'time_posttransfer']
559 somewhere_keys.extend(['time_starttransfer'])
560 # always there at the end
561 ref_tl += ['time_total']
563 # assert all events in reference timeline are > 0
564 for key in ref_tl:
565 self.check_stat_positive(s, idx, key)
566 if exact_match:
567 # assert all events not in reference timeline are 0
568 for key in [key for key in all_keys if key not in ref_tl and key not in somewhere_keys]:
569 self.check_stat_zero(s, key)
571 # calculate the timeline that did happen
572 def cmp_ts(t1, t2):
573 n = s[t1] - s[t2]
574 if not n: # same timestamp, order to expected occurrence
575 return ref_tl.index(t1) - ref_tl.index(t2)
576 return n
578 seen_tl = sorted(ref_tl, key=cmp_to_key(cmp_ts))
579 assert seen_tl == ref_tl, f'timeline {idx}: {[f"{ts}: {s[ts]}" for ts in seen_tl]}\n{self.dump_logs()}'
580 for key in somewhere_keys:
581 if key == 'time_queue':
582 # time_queue is a bastard and sometimes in CI it is reported as 0
583 self.check_stat_positive_or_0(s, idx, key)
584 else:
585 self.check_stat_positive(s, idx, key)
586 assert s[key] <= s['time_total']
588 def dump_logs(self):
589 lines = ['>>--stdout ----------------------------------------------\n']
590 lines.extend(self._stdout)
591 lines.append('>>--stderr ----------------------------------------------\n')
592 lines.extend(self._stderr)
593 lines.append('<<-------------------------------------------------------\n')
594 return ''.join(lines)
596 def dump_stat(self, x):
597 lines = [
598 'json stat from curl:',
599 json.JSONEncoder(indent=2).encode(x),
600 ]
601 if 'xfer_id' in x:
602 xfer_id = x['xfer_id']
603 lines.append(f'>>--xfer {xfer_id} trace:\n')
604 lines.extend(self.xfer_trace_for(xfer_id))
605 else:
606 lines.append('>>--full trace-------------------------------------------\n')
607 lines.extend(self._stderr)
608 lines.append('<<-------------------------------------------------------\n')
609 return ''.join(lines)
611 def xfer_trace_for(self, xfer_id) -> List[str]:
612 pat = re.compile(f'^[^[]* \\[{xfer_id}-.*$')
613 return [line for line in self._stderr if pat.match(line)]
616class CurlClient:
618 ALPN_ARG: ClassVar[Dict[str, str]] = {
619 'http/0.9': '--http0.9',
620 'http/1.0': '--http1.0',
621 'http/1.1': '--http1.1',
622 'h2': '--http2',
623 'h2c': '--http2',
624 'h3': '--http3-only',
625 }
627 def __init__(self, env: Env,
628 run_dir: Optional[str] = None,
629 timeout: Optional[float] = None,
630 silent: bool = False,
631 run_env: Optional[Dict[str, str]] = None,
632 server_addr: Optional[str] = None,
633 with_dtrace: bool = False,
634 with_perf: bool = False,
635 with_flame: bool = False,
636 force_resolv: bool = True,
637 socks_args: Optional[List[str]] = None):
638 self.env = env
639 self._timeout = timeout or env.test_timeout
640 self._curl = os.environ.get('CURL', env.curl)
641 self._run_dir = run_dir or os.path.join(env.gen_dir, 'curl')
642 self._stdoutfile = f'{self._run_dir}/curl.stdout'
643 self._stderrfile = f'{self._run_dir}/curl.stderr'
644 self._headerfile = f'{self._run_dir}/curl.headers'
645 self._log_path = f'{self._run_dir}/curl.log'
646 self._with_dtrace = with_dtrace
647 self._with_perf = with_perf
648 self._with_flame = with_flame
649 self._fg_dir = None
650 if self._with_flame:
651 self._fg_dir = os.path.join(self.env.project_dir, '../FlameGraph')
652 if 'FLAMEGRAPH' in os.environ:
653 self._fg_dir = os.environ['FLAMEGRAPH']
654 if not os.path.exists(self._fg_dir):
655 raise EnvError(f'FlameGraph checkout not found in {self._fg_dir}, set env variable FLAMEGRAPH')
656 if sys.platform.startswith('linux'):
657 self._with_perf = True
658 elif sys.platform.startswith('darwin'):
659 self._with_dtrace = True
660 else:
661 raise EnvError(f'flame graphs unsupported on {sys.platform}')
662 self._socks_args = socks_args
663 self._silent = silent
664 self._run_env = run_env
665 self._server_addr = server_addr or '127.0.0.1'
666 self._force_resolv = force_resolv
667 self._rmrf(self._run_dir)
668 self._mkpath(self._run_dir)
670 @property
671 def run_dir(self) -> str:
672 return self._run_dir
674 def download_file(self, i: int) -> str:
675 return os.path.join(self.run_dir, f'download_{i}.data')
677 def _rmf(self, path):
678 if os.path.exists(path):
679 os.remove(path)
681 def _rmrf(self, path):
682 if os.path.exists(path):
683 shutil.rmtree(path)
685 def _mkpath(self, path):
686 if not os.path.exists(path):
687 os.makedirs(path)
689 def get_proxy_args(self, proto: str = 'http/1.1',
690 proxys: bool = True, tunnel: bool = False,
691 use_ip: bool = False, use_ipv6: bool = False,
692 use_h2o: bool = False):
693 proxy_name = '[::1]' if use_ipv6 else \
694 self._server_addr if use_ip else self.env.proxy_domain
695 if proxys:
696 if tunnel:
697 pport = self.env.pts_port(proto, use_h2o=use_h2o)
698 elif proto == 'h3':
699 pport = self.env.h3proxys_port
700 else:
701 pport = self.env.proxys_port
702 xargs = [
703 '--proxy', f'https://{proxy_name}:{pport}/',
704 '--proxy-cacert', self.env.ca.cert_file,
705 ]
706 if self._force_resolv and not use_ip and not use_ipv6:
707 xargs.extend(['--resolve', f'{proxy_name}:{pport}:{self._server_addr}'])
708 if proto == 'h2':
709 xargs.append('--proxy-http2')
710 elif proto == 'h3':
711 xargs.append('--proxy-http3')
712 else:
713 xargs = [
714 '--proxy', f'http://{proxy_name}:{self.env.proxy_port}/',
715 ]
716 if self._force_resolv and not use_ip and not use_ipv6:
717 xargs.extend(['--resolve', f'{proxy_name}:{self.env.proxy_port}:{self._server_addr}'])
718 if tunnel:
719 xargs.append('--proxytunnel')
720 return xargs
722 def http_get(self, url: str, extra_args: Optional[List[str]] = None,
723 alpn_proto: Optional[str] = None,
724 def_tracing: bool = True,
725 with_stats: bool = False,
726 with_profile: bool = False,
727 with_tcpdump: bool = False):
728 return self._raw(url, options=extra_args,
729 with_stats=with_stats,
730 alpn_proto=alpn_proto,
731 def_tracing=def_tracing,
732 with_profile=with_profile,
733 with_tcpdump=with_tcpdump)
735 def http_download(self, urls: List[str],
736 alpn_proto: Optional[str] = None,
737 with_stats: bool = True,
738 with_headers: bool = False,
739 with_profile: bool = False,
740 with_tcpdump: bool = False,
741 no_save: bool = False,
742 limit_rate: Optional[str] = None,
743 extra_args: Optional[List[str]] = None,
744 url_options: Optional[Dict[str, List[str]]] = None):
745 if extra_args is None:
746 extra_args = []
747 if no_save:
748 if self.env.curl_version_at_least('8.16.0'):
749 extra_args.extend(['--out-null'])
750 else:
751 extra_args.extend(['-o', '/dev/null'])
752 else:
753 extra_args.extend(['-o', 'download_#1.data'])
754 if limit_rate:
755 extra_args.extend(['--limit-rate', limit_rate])
756 # remove any existing ones
757 for i in range(100):
758 self._rmf(self.download_file(i))
759 if with_stats:
760 extra_args.extend([
761 '-w', '%{json}\\n'
762 ])
763 return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
764 with_stats=with_stats,
765 url_options=url_options,
766 with_headers=with_headers,
767 with_profile=with_profile,
768 with_tcpdump=with_tcpdump)
770 def http_upload(self, urls: List[str], data: str,
771 alpn_proto: Optional[str] = None,
772 with_stats: bool = True,
773 with_headers: bool = False,
774 with_profile: bool = False,
775 with_tcpdump: bool = False,
776 extra_args: Optional[List[str]] = None):
777 if extra_args is None:
778 extra_args = []
779 extra_args.extend([
780 '--data-binary', data, '-o', 'download_#1.data',
781 ])
782 if with_stats:
783 extra_args.extend([
784 '-w', '%{json}\\n'
785 ])
786 return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
787 with_stats=with_stats,
788 with_headers=with_headers,
789 with_profile=with_profile,
790 with_tcpdump=with_tcpdump)
792 def http_delete(self, urls: List[str],
793 alpn_proto: Optional[str] = None,
794 with_stats: bool = True,
795 with_profile: bool = False,
796 extra_args: Optional[List[str]] = None):
797 if extra_args is None:
798 extra_args = []
799 extra_args.extend([
800 '-X', 'DELETE', '--out-null',
801 ])
802 if with_stats:
803 extra_args.extend([
804 '-w', '%{json}\\n'
805 ])
806 return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
807 with_stats=with_stats,
808 with_headers=False,
809 with_profile=with_profile)
811 def http_put(self, urls: List[str], data=None, fdata=None,
812 alpn_proto: Optional[str] = None,
813 with_stats: bool = True,
814 with_headers: bool = False,
815 with_profile: bool = False,
816 suppress_cl: bool = False,
817 extra_args: Optional[List[str]] = None):
818 if extra_args is None:
819 extra_args = []
820 if fdata is not None:
821 extra_args.extend(['-T', fdata])
822 elif data is not None:
823 extra_args.extend(['-T', '-'])
824 extra_args.extend([
825 '-o', 'download_#1.data',
826 ])
827 if with_stats:
828 extra_args.extend([
829 '-w', '%{json}\\n'
830 ])
831 if suppress_cl:
832 extra_args.extend([
833 '-H', 'Content-Length:',
834 '-H', 'Transfer-Encoding: chunked',
835 ])
836 return self._raw(urls, intext=data,
837 alpn_proto=alpn_proto, options=extra_args,
838 with_stats=with_stats,
839 with_headers=with_headers,
840 with_profile=with_profile)
842 def http_form(self, urls: List[str], form: Dict[str, str],
843 alpn_proto: Optional[str] = None,
844 with_stats: bool = True,
845 with_headers: bool = False,
846 extra_args: Optional[List[str]] = None):
847 if extra_args is None:
848 extra_args = []
849 for key, val in form.items():
850 extra_args.extend(['-F', f'{key}={val}'])
851 extra_args.extend([
852 '-o', 'download_#1.data',
853 ])
854 if with_stats:
855 extra_args.extend([
856 '-w', '%{json}\\n'
857 ])
858 return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
859 with_stats=with_stats,
860 with_headers=with_headers)
862 def ftp_get(self, urls: List[str],
863 with_stats: bool = True,
864 with_profile: bool = False,
865 with_tcpdump: bool = False,
866 no_save: bool = False,
867 extra_args: Optional[List[str]] = None):
868 if extra_args is None:
869 extra_args = []
870 if no_save:
871 extra_args.extend([
872 '--out-null',
873 ])
874 else:
875 extra_args.extend([
876 '-o', 'download_#1.data',
877 ])
878 # remove any existing ones
879 for i in range(100):
880 self._rmf(self.download_file(i))
881 if with_stats:
882 extra_args.extend([
883 '-w', '%{json}\\n'
884 ])
885 return self._raw(urls, options=extra_args,
886 with_stats=with_stats,
887 with_headers=False,
888 with_profile=with_profile,
889 with_tcpdump=with_tcpdump)
891 def ftp_ssl_get(self, urls: List[str],
892 with_stats: bool = True,
893 with_profile: bool = False,
894 with_tcpdump: bool = False,
895 no_save: bool = False,
896 extra_args: Optional[List[str]] = None):
897 if extra_args is None:
898 extra_args = []
899 extra_args.extend([
900 '--ssl-reqd',
901 ])
902 return self.ftp_get(urls=urls, with_stats=with_stats,
903 with_profile=with_profile, no_save=no_save,
904 with_tcpdump=with_tcpdump,
905 extra_args=extra_args)
907 def ftp_upload(self, urls: List[str],
908 fupload: Optional[Any] = None,
909 updata: Optional[str] = None,
910 with_stats: bool = True,
911 with_profile: bool = False,
912 with_tcpdump: bool = False,
913 extra_args: Optional[List[str]] = None):
914 if extra_args is None:
915 extra_args = []
916 if fupload is not None:
917 extra_args.extend([
918 '--upload-file', fupload
919 ])
920 elif updata is not None:
921 extra_args.extend([
922 '--upload-file', '-'
923 ])
924 else:
925 raise EnvError('need either file or data to upload')
926 if with_stats:
927 extra_args.extend([
928 '-w', '%{json}\\n'
929 ])
930 return self._raw(urls, options=extra_args,
931 intext=updata,
932 with_stats=with_stats,
933 with_headers=False,
934 with_profile=with_profile,
935 with_tcpdump=with_tcpdump)
937 def ftp_ssl_upload(self, urls: List[str],
938 fupload: Optional[Any] = None,
939 updata: Optional[str] = None,
940 with_stats: bool = True,
941 with_profile: bool = False,
942 with_tcpdump: bool = False,
943 extra_args: Optional[List[str]] = None):
944 if extra_args is None:
945 extra_args = []
946 extra_args.extend([
947 '--ssl-reqd',
948 ])
949 return self.ftp_upload(urls=urls, fupload=fupload, updata=updata,
950 with_stats=with_stats, with_profile=with_profile,
951 with_tcpdump=with_tcpdump,
952 extra_args=extra_args)
954 def ssh_download(self, urls: List[str],
955 with_stats: bool = True,
956 with_profile: bool = False,
957 with_tcpdump: bool = False,
958 no_save: bool = False,
959 extra_args: Optional[List[str]] = None):
960 if extra_args is None:
961 extra_args = []
962 if no_save:
963 extra_args.extend([
964 '--out-null',
965 ])
966 else:
967 extra_args.extend([
968 '-o', 'download_#1.data',
969 ])
970 # remove any existing ones
971 for i in range(100):
972 self._rmf(self.download_file(i))
973 if with_stats:
974 extra_args.extend([
975 '-w', '%{json}\\n'
976 ])
977 return self._raw(urls, options=extra_args,
978 with_stats=with_stats,
979 with_headers=False,
980 with_profile=with_profile,
981 with_tcpdump=with_tcpdump)
983 def ssh_upload(self, urls: List[str],
984 fupload: Optional[Any] = None,
985 updata: Optional[str] = None,
986 with_stats: bool = True,
987 with_profile: bool = False,
988 with_tcpdump: bool = False,
989 extra_args: Optional[List[str]] = None):
990 if extra_args is None:
991 extra_args = []
992 if fupload is not None:
993 extra_args.extend([
994 '--upload-file', fupload
995 ])
996 elif updata is not None:
997 extra_args.extend([
998 '--upload-file', '-'
999 ])
1000 else:
1001 raise EnvError('need either file or data to upload')
1002 if with_stats:
1003 extra_args.extend([
1004 '-w', '%{json}\\n'
1005 ])
1006 return self._raw(urls, options=extra_args,
1007 intext=updata,
1008 with_stats=with_stats,
1009 with_headers=False,
1010 with_profile=with_profile,
1011 with_tcpdump=with_tcpdump)
1013 def response_file(self, idx: int):
1014 return os.path.join(self._run_dir, f'download_{idx}.data')
1016 def run_direct(self, args, with_stats: bool = False, with_profile: bool = False):
1017 my_args = [self._curl]
1018 if with_stats:
1019 my_args.extend([
1020 '-w', '%{json}\\n'
1021 ])
1022 my_args.extend([
1023 '-o', 'download.data',
1024 ])
1025 my_args.extend(args)
1026 return self._run(args=my_args, with_stats=with_stats, with_profile=with_profile)
1028 def _run(self, args, intext='', with_stats: bool = False,
1029 with_profile: bool = True, with_tcpdump: bool = False):
1030 self._rmf(self._stdoutfile)
1031 self._rmf(self._stderrfile)
1032 self._rmf(self._headerfile)
1033 exception = None
1034 profile = None
1035 tcpdump = None
1036 perf = None
1037 dtrace = None
1038 if with_tcpdump:
1039 tcpdump = RunTcpDump(self.env, self._run_dir)
1040 tcpdump.start()
1041 started_at = datetime.now(timezone.utc)
1042 try:
1043 with open(self._stdoutfile, 'w') as cout, open(self._stderrfile, 'w') as cerr:
1044 if with_profile:
1045 end_at = started_at + timedelta(seconds=self._timeout) \
1046 if self._timeout else None
1047 log.info(f'starting: {args}')
1048 p = subprocess.Popen(args, stderr=cerr, stdout=cout,
1049 cwd=self._run_dir, shell=False,
1050 env=self._run_env)
1051 profile = RunProfile(p.pid, started_at, self._run_dir)
1052 if self._with_perf:
1053 perf = PerfProfile(p.pid, self._run_dir)
1054 perf.start()
1055 elif self._with_dtrace:
1056 dtrace = DTraceProfile(p.pid, self._run_dir)
1057 dtrace.start()
1058 ptimeout = 0.0
1059 while True:
1060 try:
1061 p.wait(timeout=ptimeout)
1062 break
1063 except subprocess.TimeoutExpired as e:
1064 if end_at and datetime.now(timezone.utc) >= end_at:
1065 p.kill()
1066 raise subprocess.TimeoutExpired(cmd=args, timeout=self._timeout) from e
1067 profile.sample()
1068 ptimeout = 0.001
1069 exitcode = p.returncode
1070 profile.finish()
1071 log.info(f'done: exit={exitcode}, profile={profile}')
1072 else:
1073 p = subprocess.run(args, stderr=cerr, stdout=cout,
1074 cwd=self._run_dir, shell=False,
1075 input=intext.encode() if intext else None,
1076 timeout=self._timeout,
1077 env=self._run_env, check=False)
1078 exitcode = p.returncode
1079 except subprocess.TimeoutExpired:
1080 now = datetime.now(timezone.utc)
1081 duration = now - started_at
1082 log.warning(f'Timeout at {now} after {duration.total_seconds()}s '
1083 f'(configured {self._timeout}s): {args}')
1084 exitcode = -1
1085 exception = 'TimeoutExpired'
1086 ended_at = datetime.now(timezone.utc)
1087 if tcpdump:
1088 tcpdump.finish()
1089 if perf:
1090 perf.finish()
1091 if dtrace:
1092 dtrace.finish()
1093 if self._with_flame:
1094 self._generate_flame(args, dtrace=dtrace, perf=perf)
1095 with open(self._stdoutfile) as fout, open(self._stderrfile) as ferr:
1096 coutput = fout.readlines()
1097 cerrput = ferr.readlines()
1098 return ExecResult(args=args, exit_code=exitcode, exception=exception,
1099 stdout=coutput, stderr=cerrput,
1100 duration=ended_at - started_at,
1101 with_stats=with_stats,
1102 profile=profile, tcpdump=tcpdump)
1104 def _raw(self, urls, intext='', timeout=None, options=None, insecure=False,
1105 alpn_proto: Optional[str] = None,
1106 url_options=None,
1107 with_stats=False,
1108 with_headers=True,
1109 def_tracing=True,
1110 with_profile=False,
1111 with_tcpdump=False):
1112 args = self._complete_args(
1113 urls=urls, timeout=timeout, options=options, insecure=insecure,
1114 alpn_proto=alpn_proto, with_headers=with_headers,
1115 def_tracing=def_tracing, url_options=url_options)
1116 r = self._run(args, intext=intext, with_stats=with_stats,
1117 with_profile=with_profile, with_tcpdump=with_tcpdump)
1118 if r.exit_code == 0 and with_headers:
1119 self._parse_headerfile(self._headerfile, r=r)
1120 return r
1122 def _complete_args(self, urls, timeout=None, options=None,
1123 insecure=False, alpn_proto: Optional[str] = None,
1124 url_options=None,
1125 with_headers: bool = True,
1126 def_tracing: bool = True):
1127 url_sep = []
1128 if not isinstance(urls, list):
1129 urls = [urls]
1131 if options is not None and '--resolve' in options:
1132 force_resolve = False
1133 else:
1134 force_resolve = self._force_resolv
1136 args = [self._curl, "--disable", "-s", "--path-as-is"]
1137 if 'CURL_TEST_EVENT' in os.environ:
1138 args.append('--test-event')
1140 if self._socks_args:
1141 args.extend(self._socks_args)
1143 if with_headers:
1144 args.extend(["-D", self._headerfile])
1145 if def_tracing is not False and not self._silent:
1146 args.extend(['-v', '--trace-ids', '--trace-time'])
1147 if self.env.verbose > 1:
1148 args.extend(['--trace-config', 'http/2,http/3,h2-proxy,h1-proxy'])
1150 active_options = options
1151 if options is not None and '--next' in options:
1152 active_options = options[options.index('--next') + 1:]
1154 for url in urls:
1155 args.extend(url_sep)
1156 if url_options is not None:
1157 url_sep = ['--next']
1159 u = urlparse(url)
1160 if url_options is not None and url in url_options:
1161 args.extend(url_options[url])
1162 if options:
1163 args.extend(options)
1164 if alpn_proto is not None:
1165 if alpn_proto not in self.ALPN_ARG:
1166 raise EnvError(f'unknown ALPN protocol: "{alpn_proto}"')
1167 args.append(self.ALPN_ARG[alpn_proto])
1169 if u.scheme == 'http':
1170 pass
1171 elif insecure:
1172 args.append('--insecure')
1173 elif active_options and ("--cacert" in active_options or
1174 "--capath" in active_options):
1175 pass
1176 elif u.hostname:
1177 args.extend(["--cacert", self.env.ca.cert_file])
1179 if force_resolve and u.hostname and u.hostname != 'localhost' \
1180 and not re.match(r'^(\d+|\[|:).*', u.hostname):
1181 port = u.port or 443
1182 args.extend([
1183 '--resolve', f'{u.hostname}:{port}:{self._server_addr}',
1184 ])
1185 if timeout is not None and int(timeout) > 0:
1186 args.extend(["--connect-timeout", str(int(timeout))])
1187 args.append(url)
1188 return args
1190 def _parse_headerfile(self, headerfile: str, r: Optional[ExecResult] = None) -> ExecResult:
1191 with open(headerfile) as fd:
1192 lines = fd.readlines()
1193 if r is None:
1194 r = ExecResult(args=[], exit_code=0, stdout=[], stderr=[])
1196 response = None
1198 def fin_response(resp):
1199 if resp:
1200 r.add_response(resp)
1202 expected = ['status']
1203 for line in lines:
1204 line = line.strip()
1205 if re.match(r'^$', line):
1206 if 'trailer' in expected:
1207 # end of trailers
1208 fin_response(response)
1209 response = None
1210 expected = ['status']
1211 elif 'header' in expected:
1212 # end of header, another status or trailers might follow
1213 expected = ['status', 'trailer']
1214 else:
1215 assert False, f"unexpected line: '{line}'"
1216 continue
1217 if 'status' in expected:
1218 # log.debug("reading 1st response line: %s", line)
1219 m = re.match(r'^(\S+) (\d+)( .*)?$', line)
1220 if m:
1221 fin_response(response)
1222 response = {
1223 "protocol": m.group(1),
1224 "status": int(m.group(2)),
1225 "description": m.group(3),
1226 "header": {},
1227 "trailer": {},
1228 "body": r.outraw
1230 expected = ['header']
1231 continue
1232 if 'trailer' in expected:
1233 m = re.match(r'^([^:]+):\s*(.*)$', line)
1234 if m:
1235 response['trailer'][m.group(1).lower()] = m.group(2)
1236 continue
1237 if 'header' in expected:
1238 m = re.match(r'^([^:]+):\s*(.*)$', line)
1239 if m:
1240 response['header'][m.group(1).lower()] = m.group(2)
1241 continue
1242 assert False, f"unexpected line: '{line}, expected: {expected}'"
1244 fin_response(response)
1245 return r
1247 def _perf_collapse(self, perf: PerfProfile, file_err):
1248 if not os.path.exists(perf.file):
1249 raise EnvError(f'perf output file does not exist: {perf.file}')
1250 fg_collapse = os.path.join(self._fg_dir, 'stackcollapse-perf.pl')
1251 if not os.path.exists(fg_collapse):
1252 raise EnvError(f'FlameGraph script not found: {fg_collapse}')
1253 stacks_collapsed = f'{perf.file}.collapsed'
1254 log.info(f'collapsing stacks into {stacks_collapsed}')
1255 with open(stacks_collapsed, 'w') as cout, open(file_err, 'w') as cerr:
1256 subprocess.run([fg_collapse, perf.file],
1257 stdout=cout, stderr=cerr, cwd=self._run_dir, shell=False, check=True)
1258 return stacks_collapsed
1260 def _dtrace_collapse(self, dtrace: DTraceProfile, file_err):
1261 if not os.path.exists(dtrace.file):
1262 raise EnvError(f'dtrace output file does not exist: {dtrace.file}')
1263 fg_collapse = os.path.join(self._fg_dir, 'stackcollapse.pl')
1264 if not os.path.exists(fg_collapse):
1265 raise EnvError(f'FlameGraph script not found: {fg_collapse}')
1266 stacks_collapsed = f'{dtrace.file}.collapsed'
1267 log.info(f'collapsing stacks into {stacks_collapsed}')
1268 with open(stacks_collapsed, 'w') as cout, open(file_err, 'a') as cerr:
1269 subprocess.run([fg_collapse, dtrace.file],
1270 stdout=cout, stderr=cerr, cwd=self._run_dir, shell=False, check=True)
1271 return stacks_collapsed
1273 def _generate_flame(self, curl_args: List[str],
1274 dtrace: Optional[DTraceProfile] = None,
1275 perf: Optional[PerfProfile] = None):
1276 fg_gen_flame = os.path.join(self._fg_dir, 'flamegraph.pl')
1277 file_svg = os.path.join(self._run_dir, 'curl.flamegraph.svg')
1278 if not os.path.exists(fg_gen_flame):
1279 raise EnvError(f'FlameGraph script not found: {fg_gen_flame}')
1281 log.info('waiting a sec for perf/dtrace to finish flushing')
1282 time.sleep(2)
1283 log.info('generating flame graph for this run')
1284 file_err = os.path.join(self._run_dir, 'curl.flamegraph.stderr')
1285 if perf:
1286 stacks_collapsed = self._perf_collapse(perf, file_err)
1287 elif dtrace:
1288 stacks_collapsed = self._dtrace_collapse(dtrace, file_err)
1289 else:
1290 raise EnvError('no stacks measure given')
1292 log.info(f'generating graph into {file_svg}')
1293 cmdline = ' '.join(curl_args)
1294 if len(cmdline) > 80:
1295 title = f'{cmdline[:80]}...'
1296 subtitle = f'...{cmdline[-80:]}'
1297 else:
1298 title = cmdline
1299 subtitle = ''
1300 with open(file_svg, 'w') as cout, open(file_err, 'a') as cerr:
1301 subprocess.run([fg_gen_flame, '--colors', 'green', '--title', title, '--subtitle',
1302 subtitle, stacks_collapsed],
1303 stdout=cout, stderr=cerr, cwd=self._run_dir, shell=False, check=True)
1305 def mk_altsvc_file(self, name, src_alpn, src_host, src_port,
1306 dest_alpn, dest_host, dest_port):
1307 fpath = os.path.join(self.run_dir, f'{name}.altsvc')
1308 ts = datetime.now(timezone.utc) + timedelta(hours=1)
1309 ts = ts.strftime('%Y%m%d %H:%M:%S')
1310 with open(fpath, 'w') as fd:
1311 fd.write(f'{src_alpn} {src_host} {src_port} {dest_alpn} {dest_host} {dest_port} "{ts}" 1 0\n')
1312 return fpath
Diagnostics4 git calls · 159 ms
CallStatusSizeTime0159 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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
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=2
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
fetch20011 KiB153 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=150
git.response.bytes=11710
git.response.cache=MISS
git.response.duration_ms=153
git.fetch.wants=952feddd7f13b47ed9704f148e80cc98a18f8ce6
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=11710
git.pkt.payload.max=11689
git.sideband.band1.bytes=11688
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
a5e2d7e68b1814c2
Request
af9a0d01…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format