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
27from typing import Generator
29import pytest
30from testenv import CurlClient, Dnsd, Env
32log = logging.getLogger(__name__)
35@pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug")
36@pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPSRR'), reason="no HTTPSRR support")
37class TestHTTPSRR:
39 @pytest.fixture(scope='class')
40 @classmethod
41 def dnsd(cls, env: Env) -> Generator[Dnsd, None, None]:
42 dnsd = Dnsd(env=env)
43 assert dnsd.initial_start()
44 yield dnsd
45 dnsd.stop()
47 def dns_settings(self, dns_method, dnsd):
48 run_env = os.environ.copy()
49 run_env['CURL_QUICK_EXIT'] = '1'
50 run_env['CURL_DEBUG'] = 'dns,https-connect'
51 run_env['CURL_DBG_AWAIT_HTTPSRR'] = '1'
52 xargs = []
53 if dns_method == 'DoH':
54 if not Env.curl_can_doh():
55 pytest.skip(reason="curl built without DoH")
56 xargs = ['--doh-insecure', '--doh-url', f'http://127.0.0.1:{dnsd.port}/']
57 else:
58 if not Env.curl_override_dns():
59 pytest.skip(reason="no DNS override")
60 run_env['CURL_DNS_SERVER'] = f'127.0.0.1:{dnsd.port}'
61 return run_env, xargs
63 # dnsd a HTTPS-RR that prefers HTTP/1.1.
64 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
65 def test_22_01_httpsrr_h1(self, env: Env, httpd, dnsd, dns_method):
66 dnsd.set_answers(addr_a=['127.0.0.1'],
67 https=['10 . alpn=http/1.1'])
68 run_env, xargs = self.dns_settings(dns_method, dnsd)
69 curl = CurlClient(env=env, run_env=run_env, force_resolv=False)
70 url = f'https://{env.authority_for(env.domain1, "http/1.1")}/data.json'
71 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
72 r.check_exit_code(0)
73 r.check_stats(count=1, http_status=200, exitcode=0)
74 assert r.stats[0]['http_version'] == '1.1', f'{r}'
76 # dnsd a HTTPS-RR that prefers HTTP/2, this overrides the --http3 option.
77 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
78 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
79 def test_22_02_httpsrr_h3(self, env: Env, httpd, dnsd, nghttpx, dns_method):
80 dnsd.set_answers(addr_a=['127.0.0.1'],
81 https=['10 . alpn=h2'])
82 run_env, xargs = self.dns_settings(dns_method, dnsd)
83 xargs.append('--http3')
84 curl = CurlClient(env=env, run_env=run_env, force_resolv=False)
85 url = f'https://{env.authority_for(env.domain1, "http/1.1")}/data.json'
86 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
87 r.check_exit_code(0)
88 r.check_stats(count=1, http_status=200, exitcode=0)
89 assert r.stats[0]['http_version'] == '2', f'{r}'
91 # dnsd a HTTPS-RR that prefers HTTP/3.
92 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
93 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
94 def test_22_03_httpsrr_h3(self, env: Env, httpd, dnsd, nghttpx, dns_method):
95 dnsd.set_answers(addr_a=['127.0.0.1'],
96 https=['10 . alpn=h3,h2'])
97 run_env, xargs = self.dns_settings(dns_method, dnsd)
98 curl = CurlClient(env=env, run_env=run_env, force_resolv=False)
99 url = f'https://{env.authority_for(env.domain1, "http/1.1")}/data.json'
100 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
101 r.check_exit_code(0)
102 r.check_stats(count=1, http_status=200, exitcode=0)
103 assert r.stats[0]['http_version'] == '3', f'{r}'
105 # dnsd a HTTPS-RR that prefers HTTP/1.1 for another target, so ignored.
106 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
107 def test_22_04_httpsrr_wrong_target(self, env: Env, httpd, dnsd, dns_method):
108 dnsd.set_answers(addr_a=['127.0.0.1'],
109 https=['10 another alpn=http/1.1'])
110 run_env, xargs = self.dns_settings(dns_method, dnsd)
111 curl = CurlClient(env=env, run_env=run_env, force_resolv=False)
112 url = f'https://{env.authority_for(env.domain1, "http/1.1")}/data.json'
113 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
114 r.check_exit_code(0)
115 r.check_stats(count=1, http_status=200, exitcode=0)
116 assert r.stats[0]['http_version'] == '2', f'{r}'
118 # dnsd a HTTPS-RR with no-default-alpn, ignored by curl for now
119 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
120 def test_22_05_httpsrr_no_default_alpn(self, env: Env, httpd, dnsd, dns_method):
121 dnsd.set_answers(addr_a=['127.0.0.1'],
122 https=['10 . no-default-alpn alpn=http/1.1'])
123 run_env, xargs = self.dns_settings(dns_method, dnsd)
124 curl = CurlClient(env=env, run_env=run_env, force_resolv=False)
125 url = f'https://{env.authority_for(env.domain1, "http/1.1")}/data.json'
126 r = curl.http_download(urls=[url], with_stats=True, extra_args=xargs)
127 r.check_exit_code(0)
128 r.check_stats(count=1, http_status=200, exitcode=0)
129 assert r.stats[0]['http_version'] == '2', f'{r}'
131 # download https: via https: proxytunnel
132 @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'),
133 reason='curl lacks HTTPS-proxy support')
134 @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available")
135 @pytest.mark.parametrize("dns_method", ["DNS", "DoH"])
136 def test_22_06_httpsrr_proxy(self, env: Env, httpd, nghttpx_fwd, dnsd, dns_method):
137 dnsd.set_answers(addr_a=['127.0.0.1'],
138 https=['10 . alpn=http/1.1'])
139 run_env, xargs = self.dns_settings(dns_method, dnsd)
140 curl = CurlClient(env=env, run_env=run_env)
141 url = f'https://localhost:{env.https_port}/data.json'
142 xargs.extend(curl.get_proxy_args(tunnel=True))
143 r = curl.http_download(urls=[url], alpn_proto='h2', with_stats=True,
144 extra_args=xargs)
145 r.check_response(count=1, http_status=200)
146 assert r.stats[0]['http_version'] == '1.1', f'{r}'
Diagnostics4 git calls · 443 ms
CallStatusSizeTime0443 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.8 KiB438 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=438 git.response.bytes=1851 git.response.cache=MISS git.response.duration_ms=438 git.fetch.wants=840bbfc48fb7f4e961adb1639697f8a66abb2e51 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=1851 git.pkt.payload.max=1830 git.sideband.band1.bytes=1829 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
- a5e200eb4adb70b8
- Request
- bdb8eb30…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format