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#
25import logging
26import os
27import socket
28from threading import Thread
29from typing import Generator
31import pytest
32from testenv import CurlClient, Env
34log = logging.getLogger(__name__)
37class UDSFaker:
39 def __init__(self, path):
40 self._uds_path = path
41 self._done = False
42 self._socket = None
43 self._thread = None
45 @property
46 def path(self):
47 return self._uds_path
49 def start(self):
50 def process(self):
51 self._socket.listen(1)
52 self._process()
54 try:
55 os.unlink(self._uds_path)
56 except OSError:
57 if os.path.exists(self._uds_path):
58 raise
59 self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
60 self._socket.bind(self._uds_path)
61 self._thread = Thread(target=process, daemon=True, args=[self])
62 self._thread.start()
64 def stop(self):
65 self._done = True
66 self._socket.close()
68 def _process(self):
69 while self._done is False:
70 try:
71 c, _client_address = self._socket.accept()
72 try:
73 c.recv(16)
74 c.sendall(b"""HTTP/1.1 200 Ok
75Server: UdsFaker
76Content-Type: application/json
77Content-Length: 19
79{ "host": "faked" }""")
80 finally:
81 c.close()
83 except OSError:
84 self._done = True
87class TestUnix:
89 @pytest.fixture(scope='class')
90 @classmethod
91 def uds_faker(cls, env: Env) -> Generator[UDSFaker, None, None]:
92 uds_path = os.path.join(env.gen_dir, 'uds_11.sock')
93 faker = UDSFaker(path=uds_path)
94 faker.start()
95 yield faker
96 faker.stop()
98 # download http: via Unix socket
99 def test_11_01_unix_connect_http(self, env: Env, httpd, uds_faker):
100 curl = CurlClient(env=env)
101 url = f'http://{env.domain1}:{env.http_port}/data.json'
102 r = curl.http_download(urls=[url], with_stats=True,
103 extra_args=[
104 '--unix-socket', uds_faker.path,
105 ])
106 r.check_response(count=1, http_status=200)
107 assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}'
108 assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}'
110 # download https: via Unix socket
111 @pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason="curl without SSL")
112 def test_11_02_unix_connect_http(self, env: Env, httpd, uds_faker):
113 curl = CurlClient(env=env)
114 url = f'https://{env.domain1}:{env.https_port}/data.json'
115 r = curl.http_download(urls=[url], with_stats=True,
116 extra_args=[
117 '--unix-socket', uds_faker.path,
118 ])
119 r.check_response(exitcode=35, http_status=None)
120 assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}'
121 assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}'
123 # download HTTP/3 via Unix socket
124 @pytest.mark.skipif(condition=not Env.have_h3(), reason='h3 not supported')
125 def test_11_03_unix_connect_quic(self, env: Env, httpd, uds_faker):
126 curl = CurlClient(env=env)
127 url = f'https://{env.domain1}:{env.https_port}/data.json'
128 r = curl.http_download(urls=[url], with_stats=True,
129 alpn_proto='h3',
130 extra_args=[
131 '--unix-socket', uds_faker.path,
132 ])
133 r.check_response(exitcode=96, http_status=None)
134 assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}'
135 assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}'
137 # download http: via Unix socket, ignore proxy args
138 def test_11_04_unix_connect_http(self, env: Env, httpd, uds_faker):
139 curl = CurlClient(env=env)
140 url = f'http://{env.domain1}:{env.http_port}/data.json'
141 xargs = curl.get_proxy_args(proto='http/1.1', use_ip=True, proxys=False)
142 xargs.extend([
143 '--unix-socket', uds_faker.path,
144 ])
145 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
146 r.check_response(count=1, http_status=200)
147 assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}'
148 assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}'
Diagnostics4 git calls · 34 ms
CallStatusSizeTime034 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 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 · hit6 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=5 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=6 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 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=25 git.response.bytes=1717 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=8b6d7877bc153b30420ffa10d4d7b78ed6176329 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=1717 git.pkt.payload.max=1696 git.sideband.band1.bytes=1695 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
- a5e2f417ba407089
- Request
- 1c2a01d1…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format